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

Fraud Report Final Touches 🎉 #1339

Merged
merged 16 commits into from
Sep 12, 2023
36 changes: 36 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,31 @@ jobs:
PYROSCOPE_PATH: '${{ steps.pyroscope-path.outputs.PYROSCOPE_PATH }}'
APPLICATION_NAME: ${{ steps.coverage.outputs.flag }}

- name: Precompile Tests
working-directory: ${{ matrix.package }}
run: go test -run=nope ./...
env:
# no other containers are running at this point so we can use all available memory for compilation
GOMEMLIMIT: 5GiB
GOGC: -1

- name: Test
uses: nick-fields/retry@v2
with:
command: |
set -e
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation: Why the Script Didn't Stop on Errors

The provided script looped through each package and ran a series of commands on each package. If any command failed during this process, the script would simply continue to the next package in the list without stopping.

This behavior is due to the default nature of bash scripting. By default, a bash script won't terminate or exit just because a command inside it fails. Instead, it will continue executing subsequent commands.

If you want a bash script to exit immediately when a command fails, you need to add the set -e directive at the beginning of the script. The set -e directive instructs the shell to exit immediately if any command in the script returns a non-zero exit status (indicating failure).

Without the set -e directive, your script will continue running subsequent commands even if one of them fails, which is the behavior you observed.

cd ${{ matrix.package }}
echo "mode: atomic" > coverage.txt
for pkg in $(go list ./...); do
#$PYROSCOPE_PATH exec --apiKey=${{ secrets.PYROSCOPE_CLOUD_TOKEN }} -- go test -coverpkg="$pkg" -coverprofile=profile.cov $pkg
go test -coverpkg="$pkg" -coverprofile=profile.cov $pkg
if [ -f profile.cov ]; then
tail -n +2 profile.cov >> coverage.txt
rm profile.cov
fi
done
cp coverage.txt profile.cov
docker ps
max_attempts: 2
timeout_minutes: 60
env:
Expand All @@ -189,6 +201,30 @@ jobs:
ETHEREUM_RPC_URI: ${{ secrets.ETHEREUM_RPC_URI }}
GOPROXY: https://proxy.golang.org

# TODO: these 3 steps should be moved into a reusable action.
# also,should be noted these aren't comprehensive, as many of the containers are automatically removed
# and we'd need something like this for all logs: https://github.com/synapsecns/sanguine/pull/1280#discussion_r1320889916
# but this should be better than nothing as long as you don't assume the logs are complete
#
# there's a good case to have this in addition to the suggestions referenced in the comment above because
# logs are not collected there in the case of sigterms (because logs stop piping when app breaks), which are caught here
#
# in any case this should be considered an early implementation
- name: Collect docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
with:
dest: '/tmp/logs'
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./tmp/logs
- name: Upload logs to GitHub
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{matrix.package}}-logs.tgz
path: ./logs.tgz

- name: Send Coverage (Codecov)
uses: Wandalen/wretry.action@v1.0.36
with:
Expand Down
Loading