Skip to content

statetransition: implement VerifyAggregatedZKProof #76

statetransition: implement VerifyAggregatedZKProof

statetransition: implement VerifyAggregatedZKProof #76

Workflow file for this run

name: Build and Test
on:
push:
branches:
- dev
- stage
- main
- release**
pull_request:
jobs:
job_go_checks:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Print github env vars
run: |
echo github.event_name: ${{ github.event_name }}
echo github.ref: ${{ github.ref }}
echo github.ref_name: ${{ github.ref_name }}
echo github.head_ref: ${{ github.head_ref }}
echo github.base_ref: ${{ github.base_ref }}
- name: Checkout code
uses: actions/checkout@v4
with:
# By default, actions/checkout does a shallow clone with depth=1.
# For job_go_checks, we can keep that.
fetch-depth: 1
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Tidy go module
run: |
go mod tidy
if [[ $(git status --porcelain) ]]; then
git diff
echo
echo "go mod tidy made these changes, please run 'go mod tidy' and include those changes in a commit"
exit 1
fi
- name: Run gofumpt
run: diff -u <(echo -n) <(go run mvdan.cc/[email protected] -d .)
- name: Run go vet
run: go vet ./...
- name: Run go generate
run: |
go generate ./...
if [[ $(git status --porcelain) ]]; then
git diff
echo
echo "go generate made these changes, please run 'go generate ./...' and include those changes in a commit"
exit 1
fi
- name: Run staticcheck
run: |
go install honnef.co/go/tools/cmd/[email protected]
staticcheck -debug.version
staticcheck ./... 2> staticcheck-stderr
- name: Check staticcheck stderr (this step isn't needed because we are using actions/setup-go@v5 on GitHub hosted runner)
run: |
if cat staticcheck-stderr | grep "matched no packages" ; then
echo "staticcheck step did nothing, due to https://github.com/vocdoni/vocdoni-node/issues/444"
echo "Please re-run job."
# seize the opportunity to fix the underlying problem: a permissions error in ~/.cache
epoch=$(date +%s)
if [ -d ~/.cache ] && find ~/.cache -not -user "$(id --user)" -print0 | grep -qz . ; then
echo "~/.cache had broken permissions, moving it away... (cache will be rebuilt with usage)"
mv -v ~/.cache ~/.cache-broken-by-root-$epoch
fi
exit 2
fi
job_go_test:
# We want to run on a self-hosted runner with labels: self-hosted, z
runs-on: [self-hosted, z]
env:
LOG_PANIC_ON_INVALIDCHARS: true # check that log lines contain no invalid chars
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Ensure we have enough history for HEAD^
fetch-depth: 2
- uses: benjlevesque/[email protected]
# sets env.SHA to the first 7 chars of github.sha
- uses: actions/setup-go@v5
with:
go-version: '1.23'
# Step to detect changes in /circuits
- name: Check if /circuits changed
id: check_circuits
run: |
# Decide what to compare against based on event type
if [ "${{ github.event_name }}" = "pull_request" ]; then
# For PRs, compare HEAD with base branch (fetching base if needed)
git fetch origin ${{ github.base_ref }} --depth=1
DIFF_TARGET="origin/${{ github.base_ref }}"
else
# For pushes, attempt HEAD^
# If HEAD^ doesn't exist (e.g., only 1 commit), fallback to HEAD
if git rev-parse --quiet --verify HEAD^ >/dev/null; then
DIFF_TARGET="HEAD^"
else
echo "HEAD^ not found, falling back to HEAD"
DIFF_TARGET="HEAD"
fi
fi
echo "Comparing HEAD to $DIFF_TARGET"
if git diff --name-only "$DIFF_TARGET" HEAD | grep '^circuits/'; then
echo "RUN_CIRCUIT_TESTS=true" >> "$GITHUB_ENV"
echo "Found changes under /circuits."
else
echo "RUN_CIRCUIT_TESTS=false" >> "$GITHUB_ENV"
echo "No changes under /circuits."
fi
- run: mkdir -p "$PWD/gocoverage-unit/"
- name: Run Go test -race
id: go-test-race
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GORACE: atexit_sleep_ms=10
RUN_CIRCUIT_TESTS: ${{ env.RUN_CIRCUIT_TESTS }}
run: |
go test ./... \
-race \
-timeout=1h \
-vet=off \
-cover \
-coverpkg=./... \
-covermode=atomic \
-args -test.gocoverdir="$PWD/gocoverage-unit/"
- name: Run Go test
if: steps.go-test-race.outcome == 'skipped'
# quicker, non-race test in case it's a PR or push to dev
env:
RUN_CIRCUIT_TESTS: ${{ env.RUN_CIRCUIT_TESTS }}
run: go test ./... -timeout=1h