Skip to content

Commit

Permalink
Optimize detection what has changes. (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer authored Nov 4, 2024
1 parent aa9c515 commit 1c4f59d
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .github/filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This is used by the action https://github.com/dorny/paths-filter

go: &go
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- 'pkg/**'
- 'cmd/**'
- 'internal/**'
- 'contrib/**'

docs: &docs
- 'mkdocs.yml'
- 'docs/**'
- 'contrib/**'
- '**/*.md'
- 'LICENSE'

any:
- *go
- *docs
26 changes: 23 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ on:
- ready_for_review

jobs:
files-changed:
name: Detect file changes
runs-on: ubuntu-latest
outputs:
go: ${{ steps.changes.outputs.go }}
docs: ${{ steps.changes.outputs.docs }}
any: ${{ steps.changes.outputs.any }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for backend file changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: .github/filters.yml

evaluate:
name: Evaluate
runs-on: ubuntu-latest
Expand Down Expand Up @@ -54,7 +71,8 @@ jobs:
test:
name: Tests
needs: [ evaluate ]
needs: [ evaluate, files-changed ]
if: needs.files-changed.outputs.go == 'true'
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
Expand Down Expand Up @@ -104,7 +122,8 @@ jobs:
goveralls "-coverprofile=profile.cov" "-service=github" "-parallel" "-flagname=go-${{ matrix.os }}"
package:
name: Package
needs: [ evaluate ]
needs: [ evaluate, files-changed ]
if: needs.files-changed.outputs.go == 'true'
runs-on: "ubuntu-latest"
container:
image: ghcr.io/engity-com/build-images/go
Expand Down Expand Up @@ -152,7 +171,8 @@ jobs:
documentation:
name: Documentation
needs: [ evaluate ]
needs: [ evaluate, files-changed ]
if: needs.files-changed.outputs.docs == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@ on:
- cron: '0 18 * * 0'

jobs:
files-changed:
name: Detect file changes
runs-on: ubuntu-latest
outputs:
go: ${{ steps.changes.outputs.go }}
docs: ${{ steps.changes.outputs.docs }}
any: ${{ steps.changes.outputs.any }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for backend file changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: .github/filters.yml

analyze:
name: Analyze
runs-on: ubuntu-latest
needs: [ files-changed ]
if: needs.files-changed.outputs.go == 'true'

strategy:
fail-fast: false
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,28 @@ permissions:
contents: read

jobs:
files-changed:
name: Detect file changes
runs-on: ubuntu-latest
outputs:
go: ${{ steps.changes.outputs.go }}
docs: ${{ steps.changes.outputs.docs }}
any: ${{ steps.changes.outputs.any }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for backend file changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: .github/filters.yml

golangci:
name: "golangci-lint"
needs: [ files-changed ]
if: needs.files-changed.outputs.go == 'true'

strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
Expand Down
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

0 comments on commit 1c4f59d

Please sign in to comment.