From 9b9f63acb55366f4701ece8a9ce7add4e77104b9 Mon Sep 17 00:00:00 2001 From: Fraz Arshad Date: Mon, 18 Nov 2024 12:35:47 +0500 Subject: [PATCH 1/2] ci: add more labels in test metrics --- .github/actions/ci-test-result.cjs | 5 ++++- .github/actions/post-test/action.yml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/ci-test-result.cjs b/.github/actions/ci-test-result.cjs index 0c66ece5848..6626578e959 100644 --- a/.github/actions/ci-test-result.cjs +++ b/.github/actions/ci-test-result.cjs @@ -3,7 +3,8 @@ const fs = require('node:fs'); const process = require('node:process'); const { sendMetricsToGCP, makeTimeSeries } = require('./gcp-monitoring.cjs'); -const resultFiles = process.argv.slice(2); +const resultFiles = process.argv.slice(3); +const branchName = process.argv[2]; const tapResultRegex = new RegExp( `(^(?not )?ok (?[0-9]+) - (?.+?)(?: %ava-dur=(?[0-9]+)ms)?(?:# (?.+?))?$(?(\n^#.+?$)*)(?(\n^(?:(?!(?:not|ok) ))[^\n\r]+?$)*))`, @@ -39,6 +40,8 @@ function processTAP(packageName, tapbody) { labels: { test_name: testCaseName, package: packageName, + branch: branchName, + duration: m.groups.duration ? parseInt(m.groups.duration, 10) : null, test_status: succeeded && !(todo || skipped) ? 'succeeded' diff --git a/.github/actions/post-test/action.yml b/.github/actions/post-test/action.yml index 6515ff3ef53..f8eef7e0318 100644 --- a/.github/actions/post-test/action.yml +++ b/.github/actions/post-test/action.yml @@ -63,4 +63,4 @@ runs: env: GCP_CREDENTIALS: ${{ inputs.gcp-credentials }} run: | - node .github/actions/ci-test-result.cjs ./packages/*/_testoutput.txt + node .github/actions/ci-test-result.cjs ${{ github.ref_name }} ./packages/*/_testoutput.txt From 785171a3d9e1ebf856bf2b284451c1da93bb3bc6 Mon Sep 17 00:00:00 2001 From: Fraz Arshad Date: Mon, 18 Nov 2024 12:37:13 +0500 Subject: [PATCH 2/2] test --- .github/actions/gcp-monitoring.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/gcp-monitoring.cjs b/.github/actions/gcp-monitoring.cjs index d6bea4ea25a..c2c8d2ef246 100644 --- a/.github/actions/gcp-monitoring.cjs +++ b/.github/actions/gcp-monitoring.cjs @@ -34,7 +34,7 @@ async function sendMetricsToGCP(timeSeries) { function makeTimeSeries(testData) { const timeSeries = testData.map(({ labels, value }) => ({ metric: { - type: `custom.googleapis.com/github/test-results`, + type: `custom.googleapis.com/github-test/test-results`, labels, }, resource: {