Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reusable-performance-report-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
env:
BASE_SHA: ${{ steps.base-sha.outputs.result }}
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
HOST_NAME: www.codevitals.run
HOST_NAME: codevitals.run
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes avoid the redirects

run: |
if [ -z "$CODEVITALS_PROJECT_TOKEN" ]; then
echo "Performance results could not be published. 'CODEVITALS_PROJECT_TOKEN' is not set"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ jobs:
env:
BASE_SHA: ${{ steps.base-sha.outputs.result }}
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
HOST_NAME: "www.codevitals.run"
HOST_NAME: "codevitals.run"
run: |
if [ -z "$CODEVITALS_PROJECT_TOKEN" ]; then
echo "Performance results could not be published. 'CODEVITALS_PROJECT_TOKEN' is not set"
Expand Down
71 changes: 35 additions & 36 deletions tests/performance/log-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
/**
* External dependencies.
*/
const https = require( 'https' );
const [ token, branch, hash, baseHash, date, host ] =
process.argv.slice( 2 );
const { median, parseFile, accumulateValues } = require( './utils' );
Expand Down Expand Up @@ -82,40 +81,40 @@ for ( const { title, results } of afterStats ) {
}
}

const data = new TextEncoder().encode(
JSON.stringify( {
branch,
hash,
baseHash,
timestamp: date,
metrics: metrics,
baseMetrics: baseMetrics,
} )
);

const options = {
hostname: host,
port: 443,
path: '/api/log?token=' + token,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length,
},
};

const req = https.request( options, ( res ) => {
console.log( `statusCode: ${ res.statusCode }` );

res.on( 'data', ( d ) => {
process.stdout.write( d );
} );
const data = JSON.stringify( {
branch,
hash,
baseHash,
timestamp: date,
metrics: metrics,
baseMetrics: baseMetrics,
} );

req.on( 'error', ( error ) => {
console.error( error );
process.exit( 1 );
} );

req.write( data );
req.end();
( async () => {
try {
const response = await fetch(
`https://${ host }/api/log?token=${ token }`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: data,
}
);

console.log( `statusCode: ${ response.status }` );

const responseText = await response.text();
if ( responseText ) {
console.log( responseText );
}

if ( ! response.ok ) {
process.exit( 1 );
}
} catch ( error ) {
console.error( error );
process.exit( 1 );
}
} )();
Loading