ci: Enable forks to run CI (#910)

* ci: Enable forks to run CI

All steps that require tokens are optional for forks,
and will be skipped if the owner is not "coder".

* Empty commit to force CI
This commit is contained in:
Kyle Carberry
2022-04-07 08:33:10 -05:00
committed by GitHub
parent 23f989127d
commit 770d212094
4 changed files with 22 additions and 124 deletions

View File

@ -4,13 +4,13 @@
# by storing snapshots.
#
# SEE: https://www.chromatic.com/docs/ci
name: "Chromatic"
name: chromatic
# Chromatic works best with push events, not pull_request or other event types.
on: push
jobs:
chromatic-deployment:
deploy:
# REMARK: this is only used to build storybook and deploy it to Chromatic.
runs-on: ubuntu-latest
@ -33,7 +33,9 @@ jobs:
with:
buildScriptName: "storybook:build"
exitOnceUploaded: true
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
# Chromatic states its fine to make this token public. See:
# https://www.chromatic.com/docs/github-actions#forked-repositories
projectToken: 695c25b6cb65
workingDir: "./site"
# This is a separate step for mainline only that auto accepts and changes
@ -48,5 +50,5 @@ jobs:
with:
autoAcceptChanges: true
buildScriptName: "storybook:build"
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
projectToken: 695c25b6cb65
workingDir: "./site"

View File

@ -1,98 +0,0 @@
# This workflow (aka The Gauntlet) is a high-iteration run of our tests,
# used to evaluate stability and shake out intermittent failures.
name: coder-test-stability
on:
schedule:
# Run everyday around midnight Central.
- cron: "0 6 * * *"
pull_request:
branches:
- main
paths:
- .github/workflows/coder-test-stability.yaml
workflow_dispatch:
inputs:
iterationCount:
description: "Iteration Count"
required: false
default: "10"
# Cancel in-progress runs for pull requests when developers push
# additional changes, and serialize builds in branches.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
coder-test-stability:
name: "test/go/stability/${{ matrix.os }}/${{ matrix.instance }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-2022
instance:
- 1
- 2
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: "~1.18"
- uses: actions/cache@v3
with:
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-
- run: go install gotest.tools/gotestsum@latest
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.1.2
terraform_wrapper: false
- name: Test with Mock Database
shell: bash
env:
GOCOUNT: ${{ github.event.inputs.iterationCount || 10 }}
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-timeout=15m -count=$GOCOUNT -race -short -failfast
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: fake
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml
- name: Test with PostgreSQL Database
if: runner.os == 'Linux'
env:
GOCOUNT: ${{ github.event.inputs.iterationCount || 10 }}
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m
-count=$GOCOUNT -race -parallel=2 -failfast
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: postgresql
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml

View File

@ -2,15 +2,6 @@ name: coder
on:
push:
branches:
- main
- "release/*"
tags:
- "*"
pull_request:
branches:
- "*"
workflow_dispatch:
@ -178,7 +169,7 @@ jobs:
-timeout=3m -count=$GOCOUNT -short -failfast
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: fake
@ -187,7 +178,7 @@ jobs:
run: go run scripts/datadog-cireport/main.go gotests.xml
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
@ -264,7 +255,7 @@ jobs:
-count=1 -parallel=2 -race -failfast
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: postgresql
@ -272,17 +263,17 @@ jobs:
run: go run scripts/datadog-cireport/main.go gotests.xml
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-${{ matrix.os }}
flags: unittest-go-postgres-${{ matrix.os }}
fail_ci_if_error: true
deploy:
name: "deploy"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
permissions:
contents: read
id-token: write
@ -391,7 +382,7 @@ jobs:
working-directory: site
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./site/coverage/lcov.info
@ -399,7 +390,7 @@ jobs:
fail_ci_if_error: true
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_CATEGORY: unit
@ -413,10 +404,6 @@ jobs:
matrix:
os:
- ubuntu-latest
- macos-latest
# TODO: Get `make build` running on Windows 2022
# https://github.com/coder/coder/issues/384
# - windows-2022
steps:
- uses: actions/checkout@v3
@ -483,7 +470,7 @@ jobs:
working-directory: site
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && github.repository_owner == 'coder'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_CATEGORY: e2e

View File

@ -6,6 +6,13 @@ comment:
coverage:
notify:
flags:
# Wait to notify until coverage has properly been reported.
# This can prevent incorrect statuses.
- unittest-go-ubuntu-latest
- unittest-go-postgres-ubuntu-latest
- unittest-go-macos-latest
- unittest-go-windows-2022
slack:
default:
url: secret:v1::ALa1/e2X+k36fPseab5D7+kBFc9bJyIoIQioD0IMA5jr+0HXVpBRNDCHZhHjCdGc67yff6PPixPEOLwEZpxC37rM23RBZOYlqAq9A5e0MeZVlEoVq19aOYN4Xel17hMJ6GGm7n17wrYpCpcvlVSqNrN0+cr3guVDyG10kQyfh2Y=