CI #548
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
workflow_run: | |
workflows: [image] | |
types: [completed] | |
permissions: | |
contents: read | |
pull-requests: read | |
jobs: | |
check-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
go: ${{ steps.filter.outputs.go }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
go: | |
- '**/*.go' | |
- go.mod | |
- go.sum | |
test: | |
needs: check-changes | |
if: ${{ needs.check-changes.outputs.go == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version-file: go.mod | |
- name: make test | |
run: | | |
# some tests are flaky because it's running against a dockerized obs | |
# instance, so just retry a few times or whatever to be certain | |
for _ in $(seq 1 5); do | |
if make test; then exit; fi | |
done | |
exit 1 | |
- run: go tool cover -func coverall.out | |
generate: | |
needs: check-changes | |
if: ${{ needs.check-changes.outputs.go == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version-file: go.mod | |
- run: make clean && make generate | |
- name: Ensure generated code is already checked in | |
if: success() | |
run: | | |
files="$(git diff --name-only)" | |
if [ -z "$files" ]; then exit 0; fi | |
echo "Files with diffs:" | |
echo "$files" | |
echo | |
echo | |
git diff | |
exit 1 |