Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cicd: update go version #2016

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
82 changes: 43 additions & 39 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,63 +12,66 @@ 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
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@v4
- uses: ./.github/actions/go-tidy
- name: Check Container Versions
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' }}
run: |
# awk ...
version=$(sed -n '/^go /{s/go \(1\.[0-9]\+\)\.[0-9]\+/\1/;p;q}' go.mod)
{
find . -name Dockerfile |
xargs awk -v "want=$version" '/^ARG GO_VERSION/{split($2,ver,/=/);if(ver[2]!=want) printf "%s\t%d\n", FILENAME, FNR}'
awk -v "want=$version" '/&go-image/{split($3,ref,/:/);if(ref[2]!=want) printf "%s\t%d\n", FILENAME, FNR}' docker-compose.yaml
} |
awk -v "want=$version" '{printf "::error file=%s,line=%d,title=Go Version Skew::Go version does not match `go.mod`: want %s\n", $1, $2, want}'
- name: Setup Go
id: 'setupgo'
if: ${{ !cancelled() && steps.checkout.conclusion == 'success' }}
uses: actions/setup-go@v5
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: |
# go mod tidy
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 +80,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
Loading