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
12 changes: 11 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,29 @@ 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
go test -coverpkg="$pkg" -coverprofile=profile.cov $pkg
$PYROSCOPE_PATH exec --apiKey=${{ secrets.PYROSCOPE_CLOUD_TOKEN }} -- 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
max_attempts: 2
timeout_minutes: 60
env:
Expand Down