github.com/consensys/gnark@v0.11.0/.github/workflows/pr.yml (about) 1 on: pull_request 2 name: pull_request 3 jobs: 4 staticcheck: 5 runs-on: ubuntu-latest 6 steps: 7 - name: checkout code 8 uses: actions/checkout@v4 9 with: 10 fetch-depth: 0 11 - name: install Go 12 uses: actions/setup-go@v5 13 with: 14 go-version: 1.23.x 15 16 - name: install deps 17 run: go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest 18 - name: gofmt 19 run: if [[ -n $(gofmt -l .) ]]; then echo "please run gofmt"; exit 1; fi 20 - name: generated files should not be modified 21 run: | 22 go generate ./... 23 git update-index --assume-unchanged go.mod 24 git update-index --assume-unchanged go.sum 25 if [[ -n $(git status --porcelain) ]]; then echo "git repo is dirty after running go generate -- please don't modify generated files"; echo $(git diff);echo $(git status --porcelain); exit 1; fi 26 27 # hack to ensure golanglint process generated files 28 - name: remove "generated by" comments from generated files 29 run: | 30 find . -type f -name '*.go' -exec sed -i 's/Code generated by .* DO NOT EDIT/FOO/g' {} \; 31 # on macos: find . -type f -name '*.go' -exec sed -i '' -E 's/Code generated by .* DO NOT EDIT/FOO/g' {} \; 32 - name: golangci-lint 33 uses: golangci/golangci-lint-action@v6 34 with: 35 version: v1.60 36 args: -v --timeout=5m 37 38 test: 39 runs-on: ubuntu-latest-128 40 permissions: 41 pull-requests: write 42 outputs: 43 failures: ${{ steps.generate-job-summary.outputs.failures }} 44 steps: 45 - name: checkout code 46 uses: actions/checkout@v4 47 - name: install Go 48 uses: actions/setup-go@v5 49 with: 50 go-version: 1.23.x 51 52 - name: install deps 53 run: | 54 go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest 55 go install github.com/consensys/gnark-solidity-checker@v0.1.0 56 go install github.com/ethereum/go-ethereum/cmd/abigen@v1.14.8 57 sudo add-apt-repository ppa:ethereum/ethereum 58 sudo apt-get update 59 sudo apt-get install solc 60 61 # Install gotestfmt on the VM running the action. 62 - name: Set up gotestfmt 63 uses: gotesttools/gotestfmt-action@v2 64 with: 65 # Optional: pass GITHUB_TOKEN to avoid rate limiting. 66 token: ${{ secrets.GITHUB_TOKEN }} 67 68 # Run tests with nice formatting. Save the original log in /tmp/gotest.log 69 - name: Run tests 70 run: | 71 set -euo pipefail 72 go test -json -v -p 4 -short -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee /tmp/gotest.log 73 go test -json -v -p 4 -tags=release_checks,solccheck . 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log 74 go test -json -v -p 4 -tags=prover_checks ./test/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log 75 go test -json -v -p 4 -tags=prover_checks ./examples/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log 76 go test -json -v -run=NONE -fuzz=FuzzIntcomp -fuzztime=30s ./internal/backend/ioutils 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log 77 78 - name: Generate job summary 79 id: generate-job-summary 80 if: ${{ always() }} 81 run: | 82 if [ -s /tmp/gotest.log ]; then 83 cat /tmp/gotest.log > $GITHUB_STEP_SUMMARY 84 echo "failures=$(cat /tmp/gotest.log | node .github/parse-tests.js)" > $GITHUB_OUTPUT 85 else 86 echo "## Success ✅" > $GITHUB_STEP_SUMMARY 87 echo "failures=" > $GITHUB_OUTPUT 88 fi 89 90 slack-workflow-status-failed: 91 if: failure() 92 name: post workflow status to slack 93 needs: 94 - staticcheck 95 - test 96 runs-on: ubuntu-latest 97 steps: 98 - name: Notify slack -- workflow failed 99 id: slack 100 uses: slackapi/slack-github-action@v1.26.0 101 with: 102 payload: | 103 { 104 "actor": "${{ github.actor }}", 105 "repo": "${{ github.repository }}", 106 "status": "FAIL", 107 "title": "${{ github.event.pull_request.title }}", 108 "pr": "${{ github.event.pull_request.head.ref }}", 109 "failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/", 110 "message": "${{ needs.test.outputs.failures }}" 111 } 112 env: 113 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 114 115 slack-workflow-status-success: 116 if: success() 117 name: post workflow status to slack 118 needs: 119 - staticcheck 120 - test 121 runs-on: ubuntu-latest 122 steps: 123 - name: Notify slack -- workflow succeeded 124 id: slack 125 uses: slackapi/slack-github-action@v1.26.0 126 with: 127 payload: | 128 { 129 "actor": "${{ github.actor }}", 130 "repo": "${{ github.repository }}", 131 "status": "SUCCESS", 132 "title": "${{ github.event.pull_request.title }}", 133 "pr": "${{ github.event.pull_request.head.ref }}" 134 } 135 env: 136 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_SUCCESS }}