Skip to content
New issue

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

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

Already on GitHub? # to your account

ci: update ci workflows #460

Merged
merged 6 commits into from
Oct 12, 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
67 changes: 15 additions & 52 deletions .github/parse-tests.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
const readline = require("readline");
const readline = require('readline');

// Create readline interface
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false,
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);
});
let content = '';

// Read stdin content
rl.on('line', (line) => {
content += line + '\n';
});

rl.on('close', () => {
// Escape special characters
const escapedContent = content.replace(/"/g, ' ');
// Convert the JSON object to a string
const jsonStr = JSON.stringify(escapedContent);
const jsonStr2 = jsonStr.slice(1, -1);
console.log(jsonStr2);
});
32 changes: 21 additions & 11 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on: pull_request
name: pull_request
jobs:
staticcheck:
runs-on: ubuntu-22.04-16core
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -38,10 +38,10 @@ jobs:

test:
runs-on: ubuntu-22.04-16core
needs:
- staticcheck
permissions:
pull-requests: write
outputs:
failures: ${{ steps.generate-job-summary.outputs.failures }}
steps:
- name: checkout code
uses: actions/checkout@v4
Expand All @@ -65,20 +65,29 @@ jobs:
- 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
go test -json -v -short -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee /tmp/gotest.log
go test -json -v -tags=purego -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
go test -json -v -race -timeout=30m ./ecc/bn254/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
GOARCH=386 go test -json -short -v -timeout=30m ./ecc/bn254/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log

- name: Generate job summary
id: generate-job-summary
if: ${{ always() }}
run: |
cat /tmp/gotest.log | node .github/parse-tests.js > /tmp/gotest.md
cat /tmp/gotest.md > $GITHUB_STEP_SUMMARY
if [ -s /tmp/gotest.log ]; then
cat /tmp/gotest.log > $GITHUB_STEP_SUMMARY
echo "failures=$(cat /tmp/gotest.log | node .github/parse-tests.js)" > $GITHUB_OUTPUT
else
echo "## Success ✅" > $GITHUB_STEP_SUMMARY
echo "failures=" > $GITHUB_OUTPUT
fi

# if we failed a test, we want to comment on the PR with the log
- name: PR comment with file
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@v2
with:
filePath: /tmp/gotest.md
filePath: /tmp/gotest.log

slack-workflow-status-failed:
if: failure()
Expand All @@ -99,7 +108,8 @@ jobs:
"status": "FAIL",
"title": "${{ github.event.pull_request.title }}",
"pr": "${{ github.event.pull_request.head.ref }}",
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/"
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/",
"message": "${{ needs.test.outputs.failures }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
name: push_master
jobs:
staticcheck:
runs-on: ubuntu-22.04-16core
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -47,6 +47,8 @@ jobs:
runs-on: ${{ matrix.os }}
needs:
- staticcheck
outputs:
failures: ${{ steps.generate-job-summary.outputs.failures }}
steps:
- name: checkout code
uses: actions/checkout@v4
Expand All @@ -67,21 +69,29 @@ jobs:
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'
if: matrix.os != 'ubuntu-22.04-16core'
run: |
go test -short -v -timeout=60m ./...
- name: Test (ubuntu - race and solc)
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-22.04-16core'
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
go test -json -v -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee /tmp/gotest.log
go test -json -v -tags=purego -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
go test -json -v -race -timeout=30m ./ecc/bn254/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
GOARCH=386 go test -json -short -v -timeout=30m ./ecc/bn254/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log

- name: Generate job summary
if: matrix.os == 'ubuntu-latest'
id: generate-job-summary
if: matrix.os == 'ubuntu-22.04-16core' && ${{ always() }}
run: |
cat /tmp/gotest.log | node .github/parse-tests.js > $GITHUB_STEP_SUMMARY
if [ -s /tmp/gotest.log ]; then
cat /tmp/gotest.log > $GITHUB_STEP_SUMMARY
echo "failures=$(cat /tmp/gotest.log | node .github/parse-tests.js)" > $GITHUB_OUTPUT
else
echo "## Success ✅" > $GITHUB_STEP_SUMMARY
echo "failures=" > $GITHUB_OUTPUT
fi

slack-workflow-status-failed:
if: failure()
Expand Down
39 changes: 39 additions & 0 deletions .gotestfmt/downloads.gotpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- /*gotype: github.com/gotesttools/gotestfmt/v2/parser.Downloads*/ -}}
{{- /*
This template contains the format for a package download.
*/ -}}
{{- $settings := .Settings -}}
{{- if or .Packages .Reason -}}
{{- if or (not .Settings.HideSuccessfulDownloads) .Failed -}}
::group::
{{- if .Failed -}}
{{ "\033" }}[0;31m❌
{{- else -}}
{{ "\033" }}[0;34m📥
{{- end -}}
{{ " " }}Dependency downloads
{{- "\033" }}[0m{{ "\n" -}}

{{- range .Packages -}}
{{- if or (not $settings.HideSuccessfulDownloads) .Failed -}}
{{- " " -}}
{{- if .Failed -}}
{{ "\033" }}[0;31m❌
{{- else -}}
📦
{{- end -}}
{{- " " -}}
{{- .Package }} {{ .Version -}}
{{- "\033" }}[0m
{{- "\n" -}}
{{ with .Reason -}}
{{- " " -}}{{ . -}}{{ "\n" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- with .Reason -}}
{{- " " -}}{{- "\033" }}[0;31m🛑 {{ . }}{{- "\033" }}[0m{{ "\n" -}}
{{- end -}}
::endgroup::
{{- end -}}
{{- end -}}
42 changes: 42 additions & 0 deletions .gotestfmt/package.gotpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- /*gotype: github.com/gotesttools/gotestfmt/v2/parser.Package*/ -}}

{{- $settings := .Settings -}}
{{- if and (or (not $settings.HideSuccessfulPackages) (ne .Result "PASS")) (or (not $settings.HideEmptyPackages) (ne .Result "SKIP") (ne (len .TestCases) 0)) -}}
📦 `{{ .Name }}`
{{- with .Coverage -}}
({{ . }}% coverage)
{{- end -}}
{{- "\n" -}}
{{- with .Reason -}}
{{- " " -}}🛑 {{ . -}}{{- "\n" -}}
{{- end -}}
{{- with .Output -}}
```{{- "\n" -}}
{{- . -}}{{- "\n" -}}
```{{- "\n" -}}
{{- end -}}
{{- with .TestCases -}}
{{- range . -}}
{{- if or (not $settings.HideSuccessfulTests) (ne .Result "PASS") -}}
{{- if eq .Result "PASS" -}}
{{- else if eq .Result "SKIP" -}}
🚧
{{- else -}}
{{- end -}}
{{ " " }}`{{- .Name -}}` {{ .Duration -}}
{{- "\n" -}}

{{- with .Output -}}
```{{- "\n" -}}
{{- formatTestOutput . $settings -}}{{- "\n" -}}
```{{- "\n" -}}
{{- end -}}

{{- "\n" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- "\n" -}}
{{- end -}}
10 changes: 6 additions & 4 deletions field/generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ func TestIntegration(t *testing.T) {
}
packageDir := filepath.Join(wd, rootDir) + string(filepath.Separator) + "..."
cmd := exec.Command("go", "test", packageDir)
out, err := cmd.CombinedOutput()
fmt.Println(string(out))
if err != nil {
t.Fatal(err)
if err := cmd.Run(); err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
t.Fatal(string(exitErr.Stderr))
} else {
t.Fatal(err)
}
}

}