Skip to content

Commit

Permalink
Use env vars for current ref and branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1m committed Nov 29, 2024
1 parent da7ce1b commit 3b77216
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/perf_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup Environment (PR)
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo "LAST_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> ${GITHUB_ENV}
- name: Setup Environment (Push)
if: ${{ github.event_name == 'push' }}
shell: bash
run: |
echo "LAST_COMMIT_SHA=${GITHUB_SHA}" >> ${GITHUB_ENV}
- run: rake docker_test_perf
env:
STATS_API_SECRET: ${{ secrets.STATS_API_SECRET }}
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ end
task docker_test_perf: :docker_build_clang_release do
sh "docker run #{docker_run_flags} " \
"-e STATS_API_SECRET=#{(ENV['STATS_API_SECRET'] || '').inspect} " \
"-e GIT_SHA=#{(ENV['LAST_COMMIT_SHA'] || '').inspect} " \
"-e GIT_REF=#{(ENV['GITHUB_HEAD_REF'] || '').inspect} " \
'--rm ' \
'--entrypoint rake ' \
"natalie_clang_#{ruby_version_string}_release test_perf"
Expand Down
4 changes: 2 additions & 2 deletions spec/support/test_perf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
pp totals

stats = {
commit: `git rev-parse HEAD`.strip,
branch: `git rev-parse --abbrev-ref HEAD`.strip,
commit: ENV.fetch('GIT_SHA'),
branch: ENV.fetch('GIT_REF'),
ir: totals
}

Expand Down

0 comments on commit 3b77216

Please sign in to comment.