Check generated code is up-to-date #3
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: Full checks | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- ready_for_review | |
workflow_dispatch: | |
concurrency: | |
group: main-${{ github.head_ref || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
go-version: ["stable", "oldstable"] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
exclude: | |
# TODO: Tests on windows are failing, paths are not crossplatform | |
- os: "windows-latest" | |
# TMP | |
- os: "macos-latest" | |
- go-version: "oldstable" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- run: go test -race -v -timeout 60s ${{ !startsWith(matrix.os, 'ubuntu') && '-short' || '' }} ./... | |
# builds: | |
# strategy: | |
# matrix: | |
# go-version: ["stable", "oldstable"] | |
# os: [ubuntu-latest, macos-latest, windows-latest] | |
# runs-on: ${{ matrix.os }} | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: actions/setup-go@v5 | |
# with: | |
# go-version: ${{ matrix.go-version }} | |
# - name: Build fabric and plugins | |
# uses: goreleaser/goreleaser-action@v6 | |
# with: | |
# distribution: goreleaser | |
# version: '~> v2' | |
# args: build --snapshot --clean --single-target | |
# golangci-lint: | |
# permissions: | |
# # Required: allow read access to the content for analysis. | |
# contents: read | |
# # Optional: allow read access to pull request. Use with `only-new-issues` option. | |
# pull-requests: read | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: actions/setup-go@v5 | |
# with: | |
# go-version: "stable" | |
# - name: golangci-lint | |
# uses: golangci/golangci-lint-action@v6 | |
# with: | |
# version: v1.59 | |
# only-new-issues: true | |
# codegen-check: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Fetch all tags | |
# # checkout only gets the latest commit, so it has no tag info | |
# run: git fetch --depth=1 --tags | |
# - uses: actions/setup-go@v5 | |
# with: | |
# go-version: "stable" | |
# - name: Restore cached codegen tools | |
# id: cache-tools | |
# uses: actions/cache/restore@v4 | |
# with: | |
# key: codegen-tools-${{ runner.os }}-${{ hashFiles('./codegen/install.sh') }} | |
# path: ~/go/bin/ | |
# - name: Install codegen tools | |
# if: steps.cache-tools.outputs.cache-hit != 'true' | |
# run: ./codegen/install.sh | |
# - name: Cache codegen tools | |
# if: steps.cache-tools.outputs.cache-hit != 'true' | |
# uses: actions/cache/save@v4 | |
# with: | |
# key: ${{ steps.cache-tools.outputs.cache-primary-key }} | |
# path: ~/go/bin/ | |
# - name: Regenerate code | |
# run: | | |
# ./codegen/rm_gen.sh | |
# ./codegen/gen.sh | |
# - name: Get changed files | |
# uses: tj-actions/verify-changed-files@v20 | |
# id: codegen-changed-files | |
# - name: Format code | |
# run: | | |
# git reset --hard HEAD | |
# ./codegen/format.sh | |
# - name: Get changed files | |
# uses: tj-actions/verify-changed-files@v20 | |
# id: format-changed-files | |
# - name: Verify that code is correctly generated and formatted | |
# if: steps.codegen-changed-files.outputs.files_changed == 'true' || steps.format-changed-files.outputs.files_changed == 'true' | |
# env: | |
# CODEGEN_CHANGED_FILES: ${{ steps.codegen-changed-files.outputs.changed_files }} | |
# FORMAT_CHANGED_FILES: ${{ steps.format-changed-files.outputs.changed_files }} | |
# run: | | |
# if [ -n "$CODEGEN_CHANGED_FILES" ]; then | |
# echo "Attempted to commit non up-to-date generated files:" >> $GITHUB_STEP_SUMMARY | |
# for file in $CODEGEN_CHANGED_FILES; do | |
# echo "* $file" >> $GITHUB_STEP_SUMMARY | |
# done | |
# cat <<"EOF" >> $GITHUB_STEP_SUMMARY | |
# Make sure that you have correct tools installed by running `./codegen/install.sh` and regenerate the files by running `./codegen/gen.sh` (`./codegen/rm_gen.sh` will remove all generated files) | |
# EOF | |
# echo "::error title=Need to regenerate code::Stale generated files: $CODEGEN_CHANGED_FILES" | |
# fi | |
# if [ -n "$FORMAT_CHANGED_FILES" ]; then | |
# echo "Attempted to commit non-formatted files:" >> $GITHUB_STEP_SUMMARY | |
# for file in $FORMAT_CHANGED_FILES; do | |
# echo "* $file" >> $GITHUB_STEP_SUMMARY | |
# done | |
# cat <<"EOF" >> $GITHUB_STEP_SUMMARY | |
# Format the code by running `./codegen/format.sh` | |
# EOF | |
# echo "::error title=Incorrect formatting::Badly formatted files: $FORMAT_CHANGED_FILES" | |
# fi | |
# exit 1 |