mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
ci: skip ts or go tests based on changed files (#7134)
* chore: skip ts or go tests based on files changed * comments * chore: add 'required' job * fixup! chore: add 'required' job * fake go modification * merge main into dean/skip-tests-fe-be * fix typo * remove x_test.go * remove duplicate setup-node action * condition test-go-race too * skip ete on docs changes * allows tests to run if changes are made .github directory --------- Co-authored-by: Atif Ali <atif@coder.com>
This commit is contained in:
co-authored by
Atif Ali
parent
71c908974c
commit
634e146032
+91
-55
@@ -27,6 +27,71 @@ 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 }}
|
||||
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
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
all:
|
||||
- "**"
|
||||
docs:
|
||||
- "docs/**"
|
||||
- "README.md"
|
||||
# For testing:
|
||||
# - ".github/**"
|
||||
go:
|
||||
- "**.sql"
|
||||
- "**.go"
|
||||
- "**.golden"
|
||||
- "go.mod"
|
||||
- "go.sum"
|
||||
# Other non-Go files that may affect Go code:
|
||||
- "**.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/**"
|
||||
- "examples/**"
|
||||
- "provisioner/**"
|
||||
- "provisionerd/**"
|
||||
- "provisionersdk/**"
|
||||
- "pty/**"
|
||||
- "scaletest/**"
|
||||
- "tailnet/**"
|
||||
- "testutil/**"
|
||||
ts:
|
||||
- "site/**"
|
||||
- "Makefile"
|
||||
k8s:
|
||||
- "helm/**"
|
||||
- "scripts/Dockerfile"
|
||||
- "scripts/Dockerfile.base"
|
||||
- "scripts/helm.sh"
|
||||
ci:
|
||||
- ".github/**"
|
||||
- id: debug
|
||||
run: |
|
||||
echo "${{ toJSON(steps.filter )}}"
|
||||
|
||||
lint:
|
||||
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||
steps:
|
||||
@@ -79,44 +144,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' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
if: needs.changes.outputs.docs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
@@ -182,6 +214,8 @@ jobs:
|
||||
|
||||
test-go:
|
||||
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-4vcpu-ubuntu-2204' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xl' || matrix.os == 'windows-2019' && github.repository_owner == 'coder' && 'windows-latest-8-cores' || matrix.os }}
|
||||
needs: changes
|
||||
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -192,11 +226,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
|
||||
@@ -257,6 +286,8 @@ jobs:
|
||||
|
||||
test-go-pg:
|
||||
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||
needs: changes
|
||||
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
|
||||
@@ -310,6 +341,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' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -355,11 +388,6 @@ jobs:
|
||||
- name: Set up Google Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v1
|
||||
|
||||
- uses: buildjet/setup-go@v4
|
||||
with:
|
||||
cache: false
|
||||
go-version: ${{ env.CODER_GO_VERSION }}
|
||||
|
||||
- uses: ./.github/actions/setup-go
|
||||
- uses: ./.github/actions/setup-node
|
||||
|
||||
@@ -426,13 +454,15 @@ jobs:
|
||||
|
||||
test-js:
|
||||
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||
needs: changes
|
||||
if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: ./.github/actions/setup-node
|
||||
|
||||
- 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
|
||||
@@ -448,10 +478,9 @@ jobs:
|
||||
flags: unittest-js
|
||||
|
||||
test-e2e:
|
||||
needs:
|
||||
- changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
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
|
||||
@@ -464,10 +493,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
|
||||
@@ -492,9 +517,8 @@ jobs:
|
||||
chromatic:
|
||||
# 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'
|
||||
needs: changes
|
||||
if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
@@ -538,3 +562,15 @@ jobs:
|
||||
buildScriptName: "storybook:build"
|
||||
projectToken: 695c25b6cb65
|
||||
workingDir: "./site"
|
||||
|
||||
required:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test-go, test-go-pg, test-js]
|
||||
# allow this job to run even if the previous jobs are skipped
|
||||
if: |
|
||||
always() &&
|
||||
!contains(needs.*.result, 'failure') &&
|
||||
!contains(needs.*.result, 'cancelled')
|
||||
steps:
|
||||
- name: Ensure required checks
|
||||
run: echo "Required checks have passed"
|
||||
|
||||
Reference in New Issue
Block a user