Fix the build after my previous PR #461
Workflow file for this run
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: Validate PRs | |
on: | |
pull_request: | |
branches: [ main ] | |
jobs: | |
go: | |
name: Check sources | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-latest, windows-latest, ubuntu-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: Check go.mod | |
shell: bash | |
run: | | |
go mod tidy | |
if ! git diff --quiet; then | |
echo "Go modules need tidying (go mod tidy)" | |
exit 1 | |
fi | |
- name: Check format | |
shell: bash | |
run: | | |
go fmt ./... | |
if ! git diff --quiet; then | |
echo "Files are not formatted (go fmt ./...)" | |
exit 1 | |
fi | |
- name: Check license headers | |
shell: bash | |
run: | | |
go install github.com/google/addlicense@latest | |
if ! addlicense --check -s -l apache -c "The KitOps Authors." $(find . -name '*.go'); then | |
echo "License headers missing from Go files (see above)." | |
echo "Install addlicense via 'go install github.com/google/addlicense@latest'" | |
echo "And run 'addlicense -s -l apache -c "The KitOps Authors." $(find . -name '*.go')" | |
exit 1 | |
fi | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: './frontend/dev-mode/.nvmrc' | |
- uses: pnpm/action-setup@v3 | |
name: Install pnpm | |
with: | |
version: 8.0.0 | |
- name: Generate embeds | |
run: | | |
go generate ./... | |
- name: Check build | |
shell: bash | |
run: | | |
if ! go build -o kit; then | |
echo "Project does not build" | |
exit 1 | |
fi | |
- name: Run tests | |
shell: bash | |
run: | | |
if ! go test ./... -v; then | |
echo "Project tests failed" | |
exit 1 | |
fi | |
- name: Check for trailing whitespace | |
shell: bash | |
run: | | |
files=$(grep -E -lI --exclude '*.svg' --exclude 'docs/*' --exclude 'frontend/*' " +$" $(git ls-files) || true) | |
if [ ! -z $files ]; then | |
echo "Trailing whitespace in files:" | |
echo "$files" | |
exit 1 | |
fi | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pr-artifacts-${{ matrix.os }} | |
retention-days: 3 | |
path: | | |
./kit* |