Skip to content

Commit

Permalink
Build/Test Tools: Fix incorrect commit time being reported to WordPre…
Browse files Browse the repository at this point in the history
…ss Code Vitals Dashboard.

2nd attempt of [59570].

Props mukesh27, ayeshrajans, swissspidy, desrosj.
Fixes #62766.


git-svn-id: https://develop.svn.wordpress.org/trunk@59582 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
felixarntz committed Jan 6, 2025
1 parent d49258b commit 4a9a928
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/reusable-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,14 @@ jobs:
- name: Set commit details
# Only needed when publishing results.
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! inputs.memcached && ! inputs.multisite }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: commit-timestamp
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commit_details = await github.rest.git.getCommit({ owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha });
return parseInt((new Date( commit_details.data.author.date ).getTime() / 1000).toFixed(0))
# Write to an environment variable to have the output available in later steps of the job.
run: echo "COMMITTED_AT=$(git show -s $GITHUB_SHA --format='%cI')" >> $GITHUB_ENV

- name: Publish performance results
# Only publish results on pushes to trunk.
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! inputs.memcached && ! inputs.multisite }}
env:
BASE_SHA: ${{ steps.base-sha.outputs.result }}
COMMITTED_AT: ${{ steps.commit-timestamp.outputs.result }}
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
HOST_NAME: "www.codevitals.run"
run: |
Expand Down
4 changes: 2 additions & 2 deletions tests/performance/log-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* External dependencies.
*/
const https = require( 'https' );
const [ token, branch, hash, baseHash, timestamp, host ] =
const [ token, branch, hash, baseHash, date, host ] =
process.argv.slice( 2 );
const { median, parseFile, accumulateValues } = require( './utils' );

Expand Down Expand Up @@ -87,7 +87,7 @@ const data = new TextEncoder().encode(
branch,
hash,
baseHash,
timestamp: parseInt( timestamp, 10 ),
timestamp: date,
metrics: metrics,
baseMetrics: baseMetrics,
} )
Expand Down

0 comments on commit 4a9a928

Please sign in to comment.