mirror of
https://github.com/coreos/ignition.git
synced 2026-02-06 18:47:54 +01:00
87 lines
2.4 KiB
YAML
87 lines
2.4 KiB
YAML
# 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.23.x, 1.24.x]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Set up Go 1.x
|
|
uses: actions/setup-go@v5
|
|
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: Check Go formatting (gofmt)
|
|
shell: bash
|
|
run: |
|
|
GO_FILES=$(find . -name '*.go' -not -path "./vendor/*")
|
|
UNFORMATTED_FILES=$(gofmt -l $GO_FILES)
|
|
if [ -n "$UNFORMATTED_FILES" ]; then
|
|
echo "Go files are not formatted. Please run 'gofmt -w .' on your code."
|
|
gofmt -d $UNFORMATTED_FILES
|
|
exit 1
|
|
fi
|
|
echo "All Go files are correctly formatted."
|
|
- name: Run linter
|
|
uses: golangci/golangci-lint-action@v8
|
|
with:
|
|
version: v2.1.6
|
|
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@v5
|
|
with:
|
|
go-version: 1.24.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
|