Files
trufflehog/.github/workflows/performance.yml
renovate[bot]Cursorrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>Bryan Beverly
a904c69a58 Update github-actions (#5197)
* Update github-actions

* Match scripts/lint.sh golangci-lint version to CI workflow

The workflow moved to v2.13.1 while local linting stayed on v2.12.2. go1.27
support landed in golangci-lint v2.13.0, so with this PR bumping CI to Go 1.27
a developer on that toolchain would see `make lint` fail outright.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Bryan Beverly <[email protected]>
Co-authored-by: Cursor <[email protected]>
2026-08-25 09:17:27 -07:00

97 lines
3.1 KiB
YAML

name: Performance Test
on: [pull_request]
jobs:
speed:
# skip if PR is from a fork.
# TODO: this could probabaly be refactored a bit so that it runs on forks
if: ${{ ! github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Install Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version: "1.27"
- name: Run Head
run: |
go build -o current .
repo_tmp=$(mktemp -d)
git clone https://github.com/trufflesecurity/trufflehog.git $repo_tmp
cd $repo_tmp
git checkout v3.75.1
user_time_sum=0
for i in {1..5}
do
tmpfile=$(mktemp)
/usr/bin/time -o $tmpfile $GITHUB_WORKSPACE/current filesystem "$repo_tmp" --no-verification --no-update > out.txt
cat $tmpfile
time_output=$(cat $tmpfile)
rm $tmpfile
user_time=$(echo $time_output | awk '{print $1}' | sed 's/user//')
# Add the user time to the sum
user_time_sum=$(echo "$user_time_sum + $user_time" | bc)
done
average_user_time=$(echo "scale=3; $user_time_sum / 5" | bc)
echo HEAD_TIME=$average_user_time >> $GITHUB_ENV
- name: Figure out previous tag
run: |
git fetch --tags
git tag -l --sort=-v:refname | head -n 1 > previous_tag.txt
echo PREVIOUS_TAG=$(cat previous_tag.txt) >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
ref: ${{ env.PREVIOUS_TAG }}
- name: Run Previous
run: |
go build -o previous .
repo_tmp=$(mktemp -d)
git clone https://github.com/trufflesecurity/trufflehog.git $repo_tmp
cd $repo_tmp
git checkout v3.75.1
user_time_sum=0
for i in {1..5}
do
tmpfile=$(mktemp)
/usr/bin/time -o $tmpfile $GITHUB_WORKSPACE/previous filesystem "$repo_tmp" --no-verification --no-update > out.txt
cat $tmpfile
time_output=$(cat $tmpfile)
rm $tmpfile
user_time=$(echo $time_output | awk '{print $1}' | sed 's/user//')
# Add the user time to the sum
user_time_sum=$(echo "$user_time_sum + $user_time" | bc)
done
average_user_time=$(echo "scale=3; $user_time_sum / 5" | bc)
echo PREVIOUS_TIME=$average_user_time >> $GITHUB_ENV
- name: Compare Results
run: |
echo "head ($GITHUB_SHA) avg time (n=5): $HEAD_TIME"
echo "$PREVIOUS_TAG avg time (n=5): $PREVIOUS_TIME"
if [ $(echo "$HEAD_TIME > $PREVIOUS_TIME * 1.5" | bc) -eq 1 ]
then
echo "HEAD run time is at least 10% slower than PREVIOUS run time"
exit 1
fi