Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update ci workflows #447

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/parse-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const readline = require("readline");

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false,
});

const summary = { fail: [], pass: [], skip: [] };

rl.on("line", (line) => {
const output = JSON.parse(line);
if (
output.Action === "pass" ||
output.Action === "skip" ||
output.Action === "fail"
) {
if (output.Test) {
summary[output.Action].push(output);
}
}
});


rl.on("close", () => {
console.log("## Summary");
console.log("\n");
// console.log("| | # of Tests |");
// console.log("|--|--|");
console.log(
"✅ Passed: %d",
summary.pass.length
);
console.log(
"❌ Failed: %d",
summary.fail.length
);
console.log(
"🚧 Skipped: %d",
summary.skip.length
);

if (summary.fail.length > 0) {
console.log("\n## ❌ Failures\n");
}

summary.fail.forEach((test) => {
console.log("* `%s` (%s)", test.Test, test.Package);
});

// also display skipped tests.
if (summary.skip.length > 0) {
console.log("\n## 🚧 Skipped\n");
}

summary.skip.forEach((test) => {
console.log("* `%s` (%s)", test.Test, test.Package);
});

});

112 changes: 56 additions & 56 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,84 @@
on: pull_request
env:
GOPROXY: "https://proxy.golang.org"

name: pull_request
jobs:
staticcheck:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04-16core
steps:
- name: install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v3
- name: install Go
uses: actions/setup-go@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: gofmt
run: if [[ -n $(gofmt -l .) ]]; then echo "please run gofmt"; exit 1; fi
go-version: 1.21.x

- name: install deps
run: go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
- name: gofmt
run: if [[ -n $(gofmt -l .) ]]; then echo "please run gofmt"; exit 1; fi
- name: generated files should not be modified
run: |
go generate ./...
git update-index --assume-unchanged go.mod
git update-index --assume-unchanged go.sum
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
# A hack to get golangci-lint to examine generated files
- name: remove "generated by" comments
run: find . -type f -name "*.go" -exec perl -i -pe 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;

# hack to ensure golanglint process generated files
- name: remove "generated by" comments from generated files
run: |
find . -type f -name '*.go' -exec sed -i 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;
# on macos: find . -type f -name '*.go' -exec sed -i '' -E 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m

version: v1.54
args: -v --timeout=5m
skip-pkg-cache: true

test:
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-22.04-16core
needs:
- staticcheck
permissions:
pull-requests: write
steps:
- name: install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: checkout code
uses: actions/checkout@v3
- uses: actions/cache@v3
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
go-version: 1.21.x

- name: install deps
run: go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
- name: Test
run: |
go test -p=1 -v -timeout=30m ./...
go test -p=1 -tags=purego -v -timeout=30m ./...
- name: Test (32 bits & race)
if: (matrix.os == 'ubuntu-latest') && (matrix.go-version == '1.20.x')
go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest

# Install gotestfmt on the VM running the action.
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}

# Run tests with nice formatting. Save the original log in /tmp/gotest.log
- name: Run tests
run: |
set -euo pipefail
go test -json -v -short -timeout=30m ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
go test -json -v -tags=purego -timeout=30m ./... 2>&1 | tee -a /tmp/gotest.log | gotestfmt
go test -json -v -race -timeout=30m ./ecc/bn254/... 2>&1 | tee -a /tmp/gotest.log | gotestfmt
GOARCH=386 go test -json -short -v -timeout=30m ./ecc/bn254/... 2>&1 | tee -a /tmp/gotest.log | gotestfmt

- name: Generate job summary
run: |
go test -p=1 -v -timeout=30m -short -race ./ecc/bn254/...
go test -p=1 -v -timeout=30m -short -tags=noadx ./ecc/bn254/...
GOARCH=386 go test -p=1 -timeout=30m -short -v ./ecc/bn254/...
cat /tmp/gotest.log | node .github/parse-tests.js > /tmp/gotest.md
cat /tmp/gotest.md > $GITHUB_STEP_SUMMARY

- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
with:
filePath: /tmp/gotest.md

slack-workflow-status-failed:
if: failure()
Expand All @@ -91,15 +90,16 @@ jobs:
steps:
- name: Notify slack -- workflow failed
id: slack
uses: slackapi/slack-github-action@v1.23.0
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "FAIL",
"title": "${{ github.event.pull_request.title }}",
"pr": "${{ github.event.pull_request.head.ref }}"
"pr": "${{ github.event.pull_request.head.ref }}",
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand All @@ -114,7 +114,7 @@ jobs:
steps:
- name: Notify slack -- workflow succeeded
id: slack
uses: slackapi/slack-github-action@v1.23.0
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
on:
push:
branches:
- 'master'
name: push_master
jobs:
staticcheck:
runs-on: ubuntu-22.04-16core
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: install deps
run: go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
- name: gofmt
run: if [[ -n $(gofmt -l .) ]]; then echo "please run gofmt"; exit 1; fi
- name: generated files should not be modified
run: |
go generate ./...
git update-index --assume-unchanged go.mod
git update-index --assume-unchanged go.sum
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

# hack to ensure golanglint process generated files
- name: remove "generated by" comments from generated files
run: |
find . -type f -name '*.go' -exec sed -i 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;
# on macos: find . -type f -name '*.go' -exec sed -i '' -E 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: -v --timeout=5m
skip-pkg-cache: true

test:
strategy:
matrix:
go-version: [1.21.x]
os: [ubuntu-22.04-16core, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
needs:
- staticcheck
steps:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}


- name: install deps
run: |
go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
# Install gotestfmt on the VM running the action.
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Test (windows / mac)
# on macOS CI / Windows CI we avoid running the std/ tests (they are run on ubuntu CI)
if: matrix.os != 'ubuntu-latest'
run: |
go test -short -v -timeout=60m ./...
- name: Test (ubuntu - race and solc)
if: matrix.os == 'ubuntu-latest'
run: |
set -euo pipefail
go test -json -v -timeout=30m ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
go test -json -v -tags=purego -timeout=30m ./... 2>&1 | tee -a /tmp/gotest.log | gotestfmt
go test -json -v -race -timeout=30m ./ecc/bn254/... 2>&1 | tee -a /tmp/gotest.log | gotestfmt
GOARCH=386 go test -json -short -v -timeout=30m ./ecc/bn254/... 2>&1 | tee -a /tmp/gotest.log | gotestfmt
- name: Generate job summary
if: matrix.os == 'ubuntu-latest'
run: |
cat /tmp/gotest.log | node .github/parse-tests.js > $GITHUB_STEP_SUMMARY

slack-workflow-status-failed:
if: failure()
name: post workflow status to slack
needs:
- staticcheck
- test
runs-on: ubuntu-latest
steps:
- name: Notify slack -- workflow failed
id: slack
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "FAIL",
"title": "push to master ⚠",
"pr": "",
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

slack-workflow-status-success:
if: success()
name: post workflow status to slack
needs:
- staticcheck
- test
runs-on: ubuntu-latest
steps:
- name: Notify slack -- workflow succeeded
id: slack
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "SUCCESS",
"title": "push to master ✅",
"pr": ""
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_SUCCESS }}