Skip to content

Commit

Permalink
Moves package iteration from ci.yml to bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Aug 26, 2024
1 parent 16f41be commit 0689ae8
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 56 deletions.
63 changes: 7 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,90 +144,41 @@ jobs:
if: matrix.test-mode == 'defaults'
env:
TEST_STATE_SCHEME: path
run: |
packages=`go list ./...`
for package in $packages; do
echo running tests for $package
if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -tags=cionly > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then
exit 1
fi
done
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags cionly --timeout 20m --cover --write-full-log

- name: run tests without race detection and hash state scheme
if: matrix.test-mode == 'defaults'
env:
TEST_STATE_SCHEME: hash
run: |
packages=`go list ./...`
for package in $packages; do
echo running tests for $package
if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -timeout 20m -tags=cionly; then
exit 1
fi
done
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags cionly --timeout 20m

- name: run tests with race detection and path state scheme
if: matrix.test-mode == 'race'
env:
TEST_STATE_SCHEME: path
run: |
packages=`go list ./...`
for package in $packages; do
echo running tests for $package
if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -race -timeout 30m > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then
exit 1
fi
done
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --race --timeout 30m --write-full-log

- name: run tests with race detection and hash state scheme
if: matrix.test-mode == 'race'
env:
TEST_STATE_SCHEME: hash
run: |
packages=`go list ./...`
for package in $packages; do
echo running tests for $package
if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -race -timeout 30m; then
exit 1
fi
done
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --race --timeout 30m

- name: run redis tests
if: matrix.test-mode == 'defaults'
run: TEST_REDIS=redis://localhost:6379/0 gotestsum --format short-verbose -- -p 1 -run TestRedis ./arbnode/... ./system_tests/... -coverprofile=coverage-redis.txt -covermode=atomic -coverpkg=./...

- name: run challenge tests
if: matrix.test-mode == 'challenge'
run: |
packages=`go list ./...`
for package in $packages; do
echo running tests for $package
if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=challengetest -run=TestChallenge > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then
exit 1
fi
done
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags challengetest --run TestChallenge --cover --write-full-log

- name: run stylus tests
if: matrix.test-mode == 'stylus'
run: |
packages=`go list ./...`
for package in $packages; do
echo running tests for $package
if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramArbitrator" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then
exit 1
fi
done
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags stylustest --run TestProgramArbitrator --timeout 60m --cover --write-full-log

- name: run long stylus tests
if: matrix.test-mode == 'long'
run: |
packages=`go list ./...`
for package in $packages; do
echo running tests for $package
if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramLong" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then
exit 1
fi
done
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags stylustest --run TestProgramLong --timeout 60m --cover --write-full-log

- name: Archive detailed run log
uses: actions/upload-artifact@v3
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/gotestsum.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

check_missing_value() {
if [[ $1 -eq 0 || $2 == -* ]]; then
echo "missing $3 argument value"
exit 1
fi
}

timeout=""
tags=""
run=""
race=false
cover=false
write_full_log=false
while [[ $# -gt 0 ]]; do
case $1 in
--timeout)
shift
check_missing_value $# "$1" "--timeout"
timeout=$1
shift
;;
--tags)
shift
check_missing_value $# "$1" "--tags"
tags=$1
shift
;;
--run)
shift
check_missing_value $# "$1" "--run"
run=$1
shift
;;
--race)
race=true
shift
;;
--cover)
cover=true
shift
;;
--write-full-log)
write_full_log=true
shift
;;
*)
echo "Invalid argument: $1"
exit 1
;;
esac
done

packages=$(go list ./...)
for package in $packages; do
cmd="stdbuf -oL gotestsum --format short-verbose --packages=\"$package\" --rerun-fails=2 --no-color=false --"

if [ "$timeout" != "" ]; then
cmd="$cmd -timeout $timeout"
else
cmd="$cmd -timeout 20m"
fi

if [ "$tags" != "" ]; then
cmd="$cmd -tags=$tags"
fi

if [ "$run" != "" ]; then
cmd="$cmd -run=$run"
fi

if [ "$race" == true ]; then
cmd="$cmd -race"
fi

if [ "$cover" == true ]; then
cmd="$cmd -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/..."
fi

if [ "$write_full_log" == true ]; then
cmd="$cmd > >(stdbuf -oL tee -a full.log | grep -vE \"INFO|seal\")"
fi

echo ""
echo running tests for "$package"
echo "$cmd"

if ! eval "$cmd"; then
exit 1
fi
done

0 comments on commit 0689ae8

Please sign in to comment.