Skip to content

Commit

Permalink
github: use depth=2 to see changes on /circuits
Browse files Browse the repository at this point in the history
Signed-off-by: p4u <[email protected]>
  • Loading branch information
p4u committed Jan 7, 2025
1 parent 2ddc0fa commit df6bcea
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


name: Build and Test

on:
Expand Down Expand Up @@ -28,6 +26,10 @@ jobs:
- 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
Expand All @@ -45,7 +47,6 @@ jobs:
fi
- name: Run gofumpt
# Run gofumpt first, as it's quick and issues are common.
run: diff -u <(echo -n) <(go run mvdan.cc/[email protected] -d .)

- name: Run go vet
Expand Down Expand Up @@ -74,19 +75,24 @@ jobs:
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
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:
- uses: actions/checkout@v4
- 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
Expand All @@ -101,12 +107,18 @@ jobs:
run: |
# Decide what to compare against based on event type
if [ "${{ github.event_name }}" = "pull_request" ]; then
# For PRs, compare HEAD with base branch
# 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, compare HEAD with HEAD^
DIFF_TARGET="HEAD^"
# 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"
Expand All @@ -122,11 +134,9 @@ jobs:

- name: Run Go test -race
id: go-test-race
# note that -race can easily make the crypto stuff 10x slower
# this is further limited to selected branches at the beginning of this file
if: github.event_name == 'push' && github.ref != 'refs/heads/release'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GORACE: atexit_sleep_ms=10 # the default of 1000 makes every Go package test sleep for 1s
GORACE: atexit_sleep_ms=10
RUN_CIRCUIT_TESTS: ${{ env.RUN_CIRCUIT_TESTS }}
run: |
go test ./... \
Expand Down

0 comments on commit df6bcea

Please sign in to comment.