github.com/consensys/gnark-crypto@v0.14.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 56 # Install gotestfmt on the VM running the action. 57 - name: Set up gotestfmt 58 uses: gotesttools/gotestfmt-action@v2 59 with: 60 # Optional: pass GITHUB_TOKEN to avoid rate limiting. 61 token: ${{ secrets.GITHUB_TOKEN }} 62 63 # Run tests with nice formatting. Save the original log in /tmp/gotest.log 64 - name: Run tests 65 run: | 66 set -euo pipefail 67 go test -json -v -short -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee /tmp/gotest.log 68 go test -json -v -tags=purego -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log 69 go test -json -v -race -timeout=30m ./ecc/bn254/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log 70 GOARCH=386 go test -json -short -v -timeout=30m ./ecc/bn254/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log 71 72 - name: Generate job summary 73 id: generate-job-summary 74 if: ${{ always() }} 75 run: | 76 if [ -s /tmp/gotest.log ]; then 77 cat /tmp/gotest.log > $GITHUB_STEP_SUMMARY 78 echo "failures=$(cat /tmp/gotest.log | node .github/parse-tests.js)" > $GITHUB_OUTPUT 79 else 80 echo "## Success ✅" > $GITHUB_STEP_SUMMARY 81 echo "failures=" > $GITHUB_OUTPUT 82 fi 83 84 # if we failed a test, we want to comment on the PR with the log 85 - name: PR comment with file 86 if: ${{ failure() }} 87 uses: thollander/actions-comment-pull-request@v2 88 with: 89 filePath: /tmp/gotest.log 90 91 slack-workflow-status-failed: 92 if: failure() 93 name: post workflow status to slack 94 needs: 95 - staticcheck 96 - test 97 runs-on: ubuntu-latest 98 steps: 99 - name: Notify slack -- workflow failed 100 id: slack 101 uses: slackapi/slack-github-action@v1.26.0 102 with: 103 payload: | 104 { 105 "actor": "${{ github.actor }}", 106 "repo": "${{ github.repository }}", 107 "status": "FAIL", 108 "title": "${{ github.event.pull_request.title }}", 109 "pr": "${{ github.event.pull_request.head.ref }}", 110 "failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/", 111 "message": "${{ needs.test.outputs.failures }}" 112 } 113 env: 114 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 115 116 slack-workflow-status-success: 117 if: success() 118 name: post workflow status to slack 119 needs: 120 - staticcheck 121 - test 122 runs-on: ubuntu-latest 123 steps: 124 - name: Notify slack -- workflow succeeded 125 id: slack 126 uses: slackapi/slack-github-action@v1.26.0 127 with: 128 payload: | 129 { 130 "actor": "${{ github.actor }}", 131 "repo": "${{ github.repository }}", 132 "status": "SUCCESS", 133 "title": "${{ github.event.pull_request.title }}", 134 "pr": "${{ github.event.pull_request.head.ref }}" 135 } 136 env: 137 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_SUCCESS }}