Skip to content

Commit

Permalink
cicd: update testing workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <[email protected]>
  • Loading branch information
hdonnay committed Mar 25, 2024
1 parent 23a8c33 commit 05340f7
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 148 deletions.
48 changes: 23 additions & 25 deletions .github/workflows/config-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,50 @@ on:
- release-4.*

jobs:
config:
runs-on: ubuntu-latest
outputs:
go_versions: ${{ steps.config.outputs.go_versions }}
steps:
- id: config
run: |
echo 'go_versions=["1.20", "1.19"]' >> "$GITHUB_OUTPUT"
commit-check:
name: Commit Check
runs-on: ubuntu-latest
steps:
- name: commit check
- name: Commit Check
uses: gsactions/commit-message-checker@v2
with:
pattern: |
^(.*):\s*(.*)\n.*$
^[^:!]+: .+\n\n.*$
error: 'Commit must begin with <scope>: <subject>'
flags: 'gm'
excludeTitle: true
excludeDescription: true
checkAllCommitMessages: true
accessToken: ${{ secrets.GITHUB_TOKEN }}

tidy:
name: Tidy
needs: ['config']
runs-on: ubuntu-latest
strategy:
matrix:
go:
- ${{ fromJSON(needs.config.outputs.go_versions)[0] }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- uses: ./.github/actions/go-tidy
- name: Checkout
id: checkout
if: ${{ !cancelled() }}
uses: actions/checkout@v4
- name: Setup Go
id: setupgo
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' }}
uses: actions/setup-go@v5
with:
go: ${{ matrix.go }}
dir: ./config
cache: false
go-version-file: ./config/go.mod
- name: Go Tidy
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' && steps.setupgo.conclusion == 'success' }}
working-directory: ./config
run: |
trap 'echo "::error file=go.mod,title=Tidy Check::Commit would leave go.mod untidy"' ERR
go mod tidy
git diff --exit-code
tests:
needs: ['config']
name: Tests
if: ${{ !cancelled() }}
uses: ./.github/workflows/tests.yml
with:
cd: config
package_expr: ./...
go_versions: ${{ needs.config.outputs.go_versions }}
qemu: false
70 changes: 31 additions & 39 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,63 +12,54 @@ on:
- release-4.*

jobs:
config:
lints:
name: Lints
runs-on: ubuntu-latest
outputs:
go_versions: ${{ steps.config.outputs.go_versions }}
steps:
- id: config
run: |
echo 'go_versions=["1.20"]' >> "$GITHUB_OUTPUT"
commit-check:
name: Commit Check
runs-on: ubuntu-latest
steps:
- name: commit check
- name: Commit Check
uses: gsactions/commit-message-checker@v2
with:
pattern: |
^(.*):\s*(.*)\n.*$
^[^:!]+: .+\n\n.*$
error: 'Commit must begin with <scope>: <subject>'
flags: 'gm'
excludeTitle: true
excludeDescription: true
checkAllCommitMessages: true
accessToken: ${{ secrets.GITHUB_TOKEN }}

api-reference-check:
name: API Reference Check
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
if: ${{ !cancelled() }}
uses: actions/checkout@v4
- name: gen api reference
- name: Check Filenames
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' }}
run: | # Check for all the characters Windows hates.
git ls-files -- ':/:*[<>:"|?*]*' | while read -r file; do
printf '::error file=%s,title=Bad Filename::Disallowed character in file name\n' "$file"
done
exit $(git ls-files -- ':/:*[<>:"|?*]*' | wc -l)
- name: Check API Reference
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' }}
run: |
npx widdershins --search false --language_tabs 'python:Python' 'go:Golang' 'javascript:Javascript' --summary ./openapi.yaml -o ./Documentation/reference/api.md
- name: diff
run: |
git diff --exit-code
tidy:
name: Tidy
needs: ['config']
runs-on: ubuntu-latest
strategy:
matrix:
go:
- ${{ fromJSON(needs.config.outputs.go_versions)[0] }}
steps:
- uses: actions/setup-go@v5
- name: Setup Go
id: 'setupgo'
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@v4
- uses: ./.github/actions/go-tidy
with:
go: ${{ matrix.go }}
cache: false
go-version-file: ./go.mod
- name: Go Tidy
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' && steps.setupgo.conclusion == 'success' }}
run: |
trap 'echo "::error file=go.mod,title=Tidy Check::Commit would leave go.mod untidy"' ERR
go mod tidy
git diff --exit-code
documentation:
name: Documentation
needs: ['lints']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -77,8 +68,9 @@ jobs:
publish: false

tests:
needs: ['config']
name: Tests
needs: ['lints']
uses: ./.github/workflows/tests.yml
with:
package_expr: ./...
go_versions: ${{ needs.config.outputs.go_versions }}
qemu: false
33 changes: 9 additions & 24 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,31 @@ on:
required: false
type: string
description: 'Package expression(s) passed to `go test`'
go_versions:
required: false
type: string
description: 'JSON array of go versions to use for tests'
platforms:
required: false
type: string
description: 'JSON array of platforms to test'

jobs:
defaults:
name: Check Input
runs-on: ubuntu-latest
outputs:
package_expr: ${{ steps.config.outputs.package_expr }}
go_versions: ${{ steps.config.outputs.go_versions }}
platforms: ${{ steps.config.outputs.platforms }}
steps:
- uses: actions/checkout@v4
- id: config
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Make package expressions
id: config
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' }}
run: |
if test -n "${{ inputs.package_expr }}"; then
printf 'package_expr=%s\n' '${{ inputs.package_expr }}' >> "$GITHUB_OUTPUT"
else
printf 'package_expr=%s\n' "$(go list -m github.com/quay/clair{core,}/... | awk '{printf("%s/... ",$1)}')" >> "$GITHUB_OUTPUT"
fi
if test -n "${{ inputs.go_versions }}"; then
printf 'go_versions=%s\n' '${{ inputs.go_versions }}' >> "$GITHUB_OUTPUT"
else
printf 'go_versions=["1.20"]\n' >> "$GITHUB_OUTPUT"
fi
if test -n "${{ inputs.platforms }}"; then
printf 'platforms=%s\n' '${{ inputs.platforms }}' >> "$GITHUB_OUTPUT"
else
printf 'platforms=["linux/arm64", "linux/ppc64le", "linux/s390x"]\n' >> "$GITHUB_OUTPUT"
fi
tests:
name: Tests
needs: ['defaults']
uses: ./.github/workflows/tests.yml
with:
package_expr: ${{ needs.defaults.outputs.package_expr }}
go_versions: ${{ needs.defaults.outputs.go_versions }}
platforms: ${{ needs.defaults.outputs.platforms }}
qemu: true
Loading

0 comments on commit 05340f7

Please sign in to comment.