From 514921e3e91b1cb69ba97843506271acaf6efaca Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Thu, 7 Apr 2022 01:57:36 +0000 Subject: [PATCH 1/2] 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". --- .github/workflows/chromatic.yaml | 6 +- .github/workflows/coder-test-stability.yaml | 98 --------------------- .github/workflows/coder.yaml | 27 ++---- 3 files changed, 13 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/coder-test-stability.yaml diff --git a/.github/workflows/chromatic.yaml b/.github/workflows/chromatic.yaml index 9d38266b46e5a..b0a70bb2b1655 100644 --- a/.github/workflows/chromatic.yaml +++ b/.github/workflows/chromatic.yaml @@ -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" diff --git a/.github/workflows/coder-test-stability.yaml b/.github/workflows/coder-test-stability.yaml deleted file mode 100644 index 998fa4440444f..0000000000000 --- a/.github/workflows/coder-test-stability.yaml +++ /dev/null @@ -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 diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index 7b7344ceb0b0b..17a0d69e5910a 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -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 }} - fail_ci_if_error: true + fail_ci_if_error: ${{ github.repository_owner == 'coder' }} 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 @@ -483,7 +474,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 From fde0d7778df53b369849632578656cded156b2a9 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Thu, 7 Apr 2022 02:11:09 +0000 Subject: [PATCH 2/2] Empty commit to force CI --- .github/workflows/chromatic.yaml | 4 ++-- .github/workflows/coder.yaml | 8 ++------ codecov.yaml | 7 +++++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/chromatic.yaml b/.github/workflows/chromatic.yaml index b0a70bb2b1655..298c389490079 100644 --- a/.github/workflows/chromatic.yaml +++ b/.github/workflows/chromatic.yaml @@ -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 diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index 17a0d69e5910a..57b3d56210272 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -267,8 +267,8 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} files: ./gotests.coverage - flags: unittest-go-${{ matrix.os }} - fail_ci_if_error: ${{ github.repository_owner == 'coder' }} + flags: unittest-go-postgres-${{ matrix.os }} + fail_ci_if_error: true deploy: name: "deploy" @@ -404,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 diff --git a/codecov.yaml b/codecov.yaml index db1a9afa06cf0..476883876c3c5 100644 --- a/codecov.yaml +++ b/codecov.yaml @@ -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=