From 3e45a82ec1b27922bc245fc2ddc28e5519aa3082 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Fri, 14 Apr 2023 13:33:01 +0000 Subject: [PATCH 01/12] chore: skip ts or go tests based on files changed --- .github/workflows/ci.yaml | 108 ++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 925fe1fa18dd6..c67303c1ea763 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,6 +28,65 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + changes: + runs-on: ubuntu-latest + outputs: + docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }} + sh: ${{ steps.filter.outputs.sh }} + go: ${{ steps.filter.outputs.go }} + ts: ${{ steps.filter.outputs.ts }} + k8s: ${{ steps.filter.outputs.k8s }} + steps: + - uses: actions/checkout@v3 + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + all: + - "**" + docs: + - "docs/**" + # For testing: + # - ".github/**" + sh: + - "**.sh" + go: + - "**.sql" + - "**.go" + - "**.golden" + - "go.mod" + - "go.sum" + # Other non-Go files that may affect Go code: + - "Makefile" + - "**.sh" + - "site/static/error.html" + # Main repo directories for completeness in case other files are + # touched: + - "agent/" + - "cli/" + - "cmd/" + - "coderd/" + - "enterprise/" + - "provisioner/" + - "provisionerd/" + - "provisionersdk/" + - "pty/" + - "scaletest/" + - "tailnet/" + - "testutil/" + ts: + - "site/**" + - "Makefile" + k8s: + - "helm/**" + - "scripts/Dockerfile" + - "scripts/Dockerfile.base" + - "scripts/helm.sh" + - id: debug + run: | + echo "${{ toJSON(steps.filter )}}" + lint: runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }} steps: @@ -95,44 +154,11 @@ jobs: - name: Check for AGPL code importing Enterprise... run: ./scripts/check_enterprise_imports.sh - changes: - runs-on: ubuntu-latest - outputs: - docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }} - sh: ${{ steps.filter.outputs.sh }} - ts: ${{ steps.filter.outputs.ts }} - k8s: ${{ steps.filter.outputs.k8s }} - steps: - - uses: actions/checkout@v3 - # For pull requests it's not necessary to checkout the code - - uses: dorny/paths-filter@v2 - id: filter - with: - filters: | - all: - - '**' - docs: - - 'docs/**' - # For testing: - # - '.github/**' - sh: - - "**.sh" - ts: - - 'site/**' - k8s: - - 'helm/**' - - scripts/Dockerfile - - scripts/Dockerfile.base - - scripts/helm.sh - - id: debug - run: | - echo "${{ toJSON(steps.filter )}}" - gen: timeout-minutes: 8 runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }} needs: changes - if: needs.changes.outputs.docs-only == 'false' + if: needs.changes.outputs.docs-only == 'false' || github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v3 @@ -240,6 +266,8 @@ jobs: test-go: runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }} + needs: changes + if: needs.changes.outputs.go == 'true' || github.ref == 'refs/heads/main' timeout-minutes: 20 strategy: matrix: @@ -329,6 +357,8 @@ jobs: test-go-psql: runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }} + needs: changes + if: needs.changes.outputs.go == 'true' || github.ref == 'refs/heads/main' # This timeout must be greater than the timeout set by `go test` in # `make test-postgres` to ensure we receive a trace of running # goroutines. Setting this to the timeout +5m should work quite well @@ -501,6 +531,8 @@ jobs: test-js: runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }} + needs: changes + if: needs.changes.outputs.ts == 'true' || github.ref == 'refs/heads/main' timeout-minutes: 20 steps: - uses: actions/checkout@v3 @@ -523,7 +555,7 @@ jobs: - name: Install node_modules run: ./scripts/yarn_install.sh - - run: yarn test:ci --max-workers ${{ steps.cpu-cores.outputs.count }} + - run: yarn test:ci --max-workers $(nproc) working-directory: site - uses: codecov/codecov-action@v3 @@ -539,8 +571,7 @@ jobs: flags: unittest-js test-e2e: - needs: - - changes + needs: changes if: needs.changes.outputs.docs-only == 'false' runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }} timeout-minutes: 20 @@ -611,8 +642,7 @@ jobs: chromatic: # REMARK: this is only used to build storybook and deploy it to Chromatic. runs-on: ubuntu-latest - needs: - - changes + needs: changes if: needs.changes.outputs.ts == 'true' steps: - uses: actions/checkout@v3 From 42af709f71c239a4d505bc7fef06b99391d6b556 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Mon, 17 Apr 2023 16:22:12 +0000 Subject: [PATCH 02/12] comments --- .github/workflows/ci.yaml | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c67303c1ea763..7ccf89a77e7d7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,7 +32,6 @@ jobs: runs-on: ubuntu-latest outputs: docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }} - sh: ${{ steps.filter.outputs.sh }} go: ${{ steps.filter.outputs.go }} ts: ${{ steps.filter.outputs.ts }} k8s: ${{ steps.filter.outputs.k8s }} @@ -47,10 +46,9 @@ jobs: - "**" docs: - "docs/**" + - "README.md" # For testing: # - ".github/**" - sh: - - "**.sh" go: - "**.sql" - "**.go" @@ -58,23 +56,28 @@ jobs: - "go.mod" - "go.sum" # Other non-Go files that may affect Go code: - - "Makefile" + - "**.rego" - "**.sh" + - "**.tpl" + - "**.gotmpl" + - "**.gotpl" + - "Makefile" - "site/static/error.html" # Main repo directories for completeness in case other files are # touched: - - "agent/" - - "cli/" - - "cmd/" - - "coderd/" - - "enterprise/" - - "provisioner/" - - "provisionerd/" - - "provisionersdk/" - - "pty/" - - "scaletest/" - - "tailnet/" - - "testutil/" + - "agent/**" + - "cli/**" + - "cmd/**" + - "coderd/**" + - "enterprise/**" + - "examples/**" + - "provisioner/**" + - "provisionerd/**" + - "provisionersdk/**" + - "pty/**" + - "scaletest/**" + - "tailnet/**" + - "testutil/**" ts: - "site/**" - "Makefile" From 67f6d43ececf2ab1d526a7632ebc269f086fb4a4 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Mon, 24 Apr 2023 02:45:36 +0000 Subject: [PATCH 03/12] chore: add 'required' job --- .github/workflows/ci.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7ccf89a77e7d7..cfb7b978a543f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -695,3 +695,16 @@ jobs: buildScriptName: "storybook:build" projectToken: 695c25b6cb65 workingDir: "./site" + + required: + runs-on: ubuntu-latest + needs: [test-go, test-go-psql, test-js] + # allow this job to run even if the previous jobs are skipped + if: | + always() && + (needs.test-go.outputs.result == 'success' || needs.test-go.outputs.result == 'skipped') && + (needs.test-go-psql.outputs.result == 'success' || needs.test-go-psql.outputs.result == 'skipped') && + (needs.test-js.outputs.result == 'success' || needs.test-js.outputs.result == 'skipped') + steps: + - name: Ensure required checks + run: echo "Required checks have passed" From e23cb5e8799fcc203a3a7559247b9d1dd397061c Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Mon, 24 Apr 2023 06:01:07 +0000 Subject: [PATCH 04/12] fixup! chore: add 'required' job --- .github/workflows/ci.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cfb7b978a543f..2cf9b9c9b3624 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -702,9 +702,8 @@ jobs: # allow this job to run even if the previous jobs are skipped if: | always() && - (needs.test-go.outputs.result == 'success' || needs.test-go.outputs.result == 'skipped') && - (needs.test-go-psql.outputs.result == 'success' || needs.test-go-psql.outputs.result == 'skipped') && - (needs.test-js.outputs.result == 'success' || needs.test-js.outputs.result == 'skipped') + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') steps: - name: Ensure required checks run: echo "Required checks have passed" From 352440db725737da667563d948ebf663bc0fb570 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Mon, 24 Apr 2023 06:04:01 +0000 Subject: [PATCH 05/12] fake go modification --- x_test.go | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 x_test.go diff --git a/x_test.go b/x_test.go new file mode 100644 index 0000000000000..1ad9c009ba1a2 --- /dev/null +++ b/x_test.go @@ -0,0 +1,7 @@ +package coderd + +import "testing" + +func Test_Test(t *testing.T) { + t.Log("hello world") +} From 8f0903d0c1b55f6d4c937b2eed91e570f82a62e9 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 9 Jun 2023 16:11:10 +0300 Subject: [PATCH 06/12] merge main into dean/skip-tests-fe-be --- .github/workflows/ci.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b66af13d97a37..6eefbeb059e81 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -223,11 +223,6 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: buildjet/setup-go@v4 - with: - cache: false - go-version: ${{ env.CODER_GO_VERSION }} - - uses: ./.github/actions/setup-go - uses: hashicorp/setup-terraform@v2 @@ -457,8 +452,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install node_modules - run: ./scripts/yarn_install.sh + - uses: ./.github/actions/setup-node - run: yarn test:ci --max-workers $(nproc) working-directory: site From e02a408df9272318d8e1d7febe04502ab8d2abac Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 9 Jun 2023 16:13:19 +0300 Subject: [PATCH 07/12] fix typo --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6eefbeb059e81..45e7e821e4243 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -561,7 +561,7 @@ jobs: required: runs-on: ubuntu-latest - needs: [test-go, test-go-psql, test-js] + needs: [test-go, test-go-pg, test-js] # allow this job to run even if the previous jobs are skipped if: | always() && From 8f9828c0a79e4c4a2840393e8a1130f3a54c8d73 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Fri, 9 Jun 2023 13:34:29 +0000 Subject: [PATCH 08/12] remove x_test.go --- x_test.go | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 x_test.go diff --git a/x_test.go b/x_test.go deleted file mode 100644 index 1ad9c009ba1a2..0000000000000 --- a/x_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package coderd - -import "testing" - -func Test_Test(t *testing.T) { - t.Log("hello world") -} From cfcc52ce7f77e16ac6daa505fc872fc689d4e8cc Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 9 Jun 2023 16:49:04 +0300 Subject: [PATCH 09/12] remove duplicate setup-node action --- .github/workflows/ci.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 45e7e821e4243..bc8bd7f11cee0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -485,10 +485,6 @@ jobs: terraform_version: 1.1.9 terraform_wrapper: false - - uses: buildjet/setup-node@v3 - with: - node-version: "16.16.0" - - name: Build run: | sudo npm install -g prettier From 7ff9c2c787e5fe65a106f1782f1ad18c1a439180 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 9 Jun 2023 17:04:30 +0300 Subject: [PATCH 10/12] condition test-go-race too --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bc8bd7f11cee0..9a68016be8c33 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -335,6 +335,8 @@ jobs: test-go-race: runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} + needs: changes + if: needs.changes.outputs.go == 'true' || github.ref == 'refs/heads/main' timeout-minutes: 25 steps: - uses: actions/checkout@v3 From 0695cb96166161b7833574c12056dbec3bf50b13 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 9 Jun 2023 17:08:35 +0300 Subject: [PATCH 11/12] skip ete on docs changes --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9a68016be8c33..41a67ce9a7295 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -473,7 +473,7 @@ jobs: test-e2e: needs: changes - if: needs.changes.outputs.docs-only == 'false' + if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || github.ref == 'refs/heads/main' runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} timeout-minutes: 20 steps: From 77162d91e6a7b503b3b6363ca1a9648f5b94d6b4 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 9 Jun 2023 17:13:53 +0300 Subject: [PATCH 12/12] allows tests to run if changes are made .github directory --- .github/workflows/ci.yaml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 41a67ce9a7295..0795733fa721f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,6 +34,7 @@ jobs: go: ${{ steps.filter.outputs.go }} ts: ${{ steps.filter.outputs.ts }} k8s: ${{ steps.filter.outputs.k8s }} + ci: ${{ steps.filter.outputs.ci }} steps: - uses: actions/checkout@v3 # For pull requests it's not necessary to checkout the code @@ -85,6 +86,8 @@ jobs: - "scripts/Dockerfile" - "scripts/Dockerfile.base" - "scripts/helm.sh" + ci: + - ".github/**" - id: debug run: | echo "${{ toJSON(steps.filter )}}" @@ -145,7 +148,7 @@ jobs: timeout-minutes: 8 runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} needs: changes - if: needs.changes.outputs.docs-only == 'false' || github.ref == 'refs/heads/main' + if: needs.changes.outputs.docs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v3 @@ -212,7 +215,7 @@ jobs: test-go: runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-4vcpu-ubuntu-2204' || matrix.os == 'windows-2019' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }} needs: changes - if: needs.changes.outputs.go == 'true' || github.ref == 'refs/heads/main' + if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' timeout-minutes: 20 strategy: matrix: @@ -281,7 +284,7 @@ jobs: test-go-pg: runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} needs: changes - if: needs.changes.outputs.go == 'true' || github.ref == 'refs/heads/main' + if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' # This timeout must be greater than the timeout set by `go test` in # `make test-postgres` to ensure we receive a trace of running # goroutines. Setting this to the timeout +5m should work quite well @@ -336,7 +339,7 @@ jobs: test-go-race: runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} needs: changes - if: needs.changes.outputs.go == 'true' || github.ref == 'refs/heads/main' + if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' timeout-minutes: 25 steps: - uses: actions/checkout@v3 @@ -449,7 +452,7 @@ jobs: test-js: runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} needs: changes - if: needs.changes.outputs.ts == 'true' || github.ref == 'refs/heads/main' + if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' timeout-minutes: 20 steps: - uses: actions/checkout@v3 @@ -472,9 +475,9 @@ jobs: flags: unittest-js test-e2e: - needs: changes - if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || github.ref == 'refs/heads/main' runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} + needs: changes + if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' timeout-minutes: 20 steps: - uses: actions/checkout@v3 @@ -512,7 +515,7 @@ jobs: # REMARK: this is only used to build storybook and deploy it to Chromatic. runs-on: ubuntu-latest needs: changes - if: needs.changes.outputs.ts == 'true' + if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v3 with: