Merge pull request #1977 from coreosbot-releng/repo-templates #2197
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
# Maintained in https://github.com/coreos/repo-templates | |
# Do not edit downstream. | |
name: Go | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
permissions: | |
contents: read | |
# don't waste job slots on superseded code | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Test | |
strategy: | |
matrix: | |
go-version: [1.22.x, 1.23.x] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Install Linux dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install libblkid-dev | |
- name: Check modules | |
run: go mod verify | |
- name: Build | |
run: ./build | |
- name: Test | |
run: ./test | |
- name: Run linter | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.61.0 | |
args: -E=gofmt --timeout=30m0s | |
regenerate: | |
name: Regenerate | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.23.x | |
- name: Install schematyper | |
run: | | |
# "go install github.com/idubinskiy/schematyper:latest" fails with | |
# current Go. Use fix from fork. We can't "go install" directly from | |
# the fork; it complains about mismatched package paths. | |
# https://github.com/idubinskiy/schematyper/pull/22 | |
git clone -b gomod https://github.com/bgilbert/schematyper | |
cd schematyper | |
go install . | |
- name: Regenerate | |
run: ./generate | |
- name: Check whether generated output is current | |
run: | | |
if [ -n "$(git status --porcelain config docs)" ]; then | |
echo "Found local changes after regenerating:" | |
git --no-pager diff --color=always config docs | |
echo "Rerun './generate'." | |
exit 1 | |
fi |