mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
ci: optimize jobs with path filtering (#3074)
This commit is contained in:
@@ -6,8 +6,6 @@ on:
|
||||
- main
|
||||
tags:
|
||||
- "*"
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
|
||||
pull_request:
|
||||
|
||||
@@ -32,9 +30,48 @@ 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 }}
|
||||
sh: ${{ steps.filter.outputs.sh }}
|
||||
steps:
|
||||
# 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/**'
|
||||
go:
|
||||
- "**.go"
|
||||
- "**.mod"
|
||||
- "**.sum"
|
||||
sh:
|
||||
- "**.sh"
|
||||
- id: debug
|
||||
run: |
|
||||
echo "${{ toJSON(steps.filter )}}"
|
||||
|
||||
# Debug step
|
||||
show-changes:
|
||||
needs: changes
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: log
|
||||
run: |
|
||||
echo "${{ toJSON(needs.changes) }}"
|
||||
|
||||
style-lint-golangci:
|
||||
name: style/lint/golangci
|
||||
timeout-minutes: 5
|
||||
needs: changes
|
||||
if: needs.changes.outputs.go == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -50,6 +87,8 @@ jobs:
|
||||
name: style/lint/shellcheck
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.sh == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run ShellCheck
|
||||
@@ -62,6 +101,8 @@ jobs:
|
||||
style-lint-typescript:
|
||||
name: "style/lint/typescript"
|
||||
timeout-minutes: 5
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -89,6 +130,8 @@ jobs:
|
||||
name: "style/gen"
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
@@ -124,6 +167,8 @@ jobs:
|
||||
|
||||
style-fmt:
|
||||
name: "style/fmt"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
@@ -156,6 +201,8 @@ jobs:
|
||||
|
||||
test-go:
|
||||
name: "test/go"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
@@ -232,6 +279,8 @@ jobs:
|
||||
|
||||
test-go-postgres:
|
||||
name: "test/go/postgres"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
# This timeout must be greater than the timeout set by `go test` in
|
||||
# `make test-postgres` to ensure we receive a trace of running
|
||||
@@ -303,7 +352,10 @@ jobs:
|
||||
name: "deploy"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
|
||||
needs: changes
|
||||
if: |
|
||||
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
|
||||
&& needs.changes.outputs.docs-only == 'false'
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
@@ -409,6 +461,8 @@ jobs:
|
||||
|
||||
test-js:
|
||||
name: "test/js"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
@@ -462,6 +516,8 @@ jobs:
|
||||
|
||||
test-e2e:
|
||||
name: "test/e2e/${{ matrix.os }}"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.docs-only == 'false'
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
|
||||
Reference in New Issue
Block a user