Skip to content

Commit 15e1e45

Browse files
authored
Merge branch 'main' into auto-logging
2 parents 6053f42 + c2c05a1 commit 15e1e45

File tree

84 files changed

+2745
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2745
-326
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This composite action is used to report the local build size to New Relic
2+
# You must build the agent before running this action
3+
4+
name: 'Report Build Size to New Relic'
5+
6+
inputs:
7+
nr-api-key:
8+
description: 'NR API Key for reporting events'
9+
required: true
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Install dependencies
15+
run: npm install --silent --no-progress --prefix $GITHUB_ACTION_PATH/..
16+
shell: bash
17+
- name: Get local stats
18+
id: get-stats
19+
shell: bash
20+
run: |
21+
rum=$(cat ./build/nr-rum-standard.stats.json); echo "rum=$rum" >> $GITHUB_OUTPUT;
22+
full=$(cat ./build/nr-full-standard.stats.json); echo "full=$full" >> $GITHUB_OUTPUT;
23+
spa=$(cat ./build/nr-spa-standard.stats.json); echo "spa=$spa" >> $GITHUB_OUTPUT;
24+
- name: Report rum size to NR
25+
uses: metal-messiah/webpack-build-size-action@main
26+
with:
27+
nr-api-key: ${{ inputs.nr-api-key }}
28+
nr-account-id: '550352'
29+
nr-env: 'staging'
30+
analysis-file-contents: ${{ steps.get-stats.outputs.rum }}
31+
file-name-filter: '.min.js'
32+
- name: Report full size to NR
33+
uses: metal-messiah/webpack-build-size-action@main
34+
with:
35+
nr-api-key: ${{ inputs.nr-api-key }}
36+
nr-account-id: '550352'
37+
nr-env: 'staging'
38+
analysis-file-contents: ${{ steps.get-stats.outputs.full }}
39+
file-name-filter: '.min.js'
40+
- name: Report spa size to NR
41+
uses: metal-messiah/webpack-build-size-action@main
42+
with:
43+
nr-api-key: ${{ inputs.nr-api-key }}
44+
nr-account-id: '550352'
45+
nr-env: 'staging'
46+
analysis-file-contents: ${{ steps.get-stats.outputs.spa }}
47+
file-name-filter: '.min.js'

.github/actions/post-release-updates/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ if (args.openPullRequest) {
4646

4747
gitRunner = new GitCliRunner(REPO_ROOT_PATH, args.githubLogin, args.githubToken, args.githubUserName, args.githubEmail)
4848
await gitRunner.setUser()
49-
await gitRunner.checkoutBranch(REPO_BASE, true)
5049
try {
5150
await gitRunner.deleteLocalBranch(PR_BRANCH_NAME)
5251
} catch (error) {
@@ -82,6 +81,13 @@ await spawnAsync(
8281
DEFAULT_SPAWN_OPTIONS
8382
)
8483

84+
console.log('Updating LambdaTest webview assets')
85+
await spawnAsync(
86+
`npm${os.platform() === 'win32' ? '.cmd' : ''}`,
87+
['run', 'lt:upload-webview-assets'],
88+
DEFAULT_SPAWN_OPTIONS
89+
)
90+
8591
console.log('Updating third-party licenses')
8692
await spawnAsync(
8793
`npm${os.platform() === 'win32' ? '.cmd' : ''}`,
@@ -111,7 +117,8 @@ if (args.openPullRequest) {
111117
'tools/browsers-lists/*.json',
112118
'third_party_manifest.json',
113119
'THIRD_PARTY_NOTICES.md',
114-
'tools/test-builds/**/package.json'
120+
'tools/test-builds/**/package.json',
121+
'tools/lambda-test/webview-asset-ids.mjs'
115122
],
116123
COMMIT_MESSAGE,
117124
true
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This composite action is used to delete files from a S3 bucket.
2+
3+
name: 'S3 File Deletion'
4+
5+
inputs:
6+
aws_access_key_id:
7+
description: 'AWS access key id used for authentication.'
8+
required: true
9+
aws_secret_access_key:
10+
description: 'AWS secret access key used for authentication.'
11+
required: true
12+
aws_region:
13+
description: "AWS region where S3 bucket is located."
14+
required: false
15+
default: us-east-1
16+
aws_role:
17+
description: "AWS role ARN that needs to be used for authentication."
18+
required: true
19+
aws_bucket_name:
20+
description: "S3 bucket name where files need to be deleted."
21+
required: true
22+
dry_run:
23+
description: "Indicates if we should just list files to deleted without actually deleting them."
24+
required: false
25+
bucket_dir:
26+
description: 'A sub directory where the files are located within the S3 bucket.'
27+
required: false
28+
29+
outputs:
30+
results:
31+
description: "Array of objects containing information about each file uploaded"
32+
value: ${{ steps.action-script.outputs.results }}
33+
34+
runs:
35+
using: "composite"
36+
steps:
37+
- name: Install dependencies
38+
run: npm install --silent --no-progress --prefix $GITHUB_ACTION_PATH/..
39+
shell: bash
40+
- name: Run action script
41+
id: action-script
42+
env:
43+
AWS_ACCESS_KEY_ID: ${{ inputs.aws_access_key_id }}
44+
AWS_SECRET_ACCESS_KEY: ${{ inputs.aws_secret_access_key }}
45+
run: |
46+
node $GITHUB_ACTION_PATH/index.js \
47+
--region ${{ inputs.aws_region }} \
48+
--bucket ${{ inputs.aws_bucket_name }} \
49+
--role ${{ inputs.aws_role }} \
50+
${{ inputs.dry_run && '--dry' || '' }} \
51+
${{ inputs.bucket_dir && format('--dir {0}', inputs.bucket_dir) || '' }}
52+
shell: bash

.github/actions/s3-delete/args.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import process from 'process'
2+
import yargs from 'yargs'
3+
import { hideBin } from 'yargs/helpers'
4+
5+
export const args = yargs(hideBin(process.argv))
6+
.usage('$0 [options]')
7+
8+
.string('role')
9+
.describe('role', 'S3 role ARN')
10+
11+
.string('bucket')
12+
.describe('bucket', 'S3 bucket name')
13+
14+
.string('region')
15+
.describe('region', 'AWS region location of S3 bucket. Defaults to us-east-1.')
16+
.default('region', 'us-east-1')
17+
18+
.boolean('dry')
19+
.default('dry', false)
20+
.describe('dry', 'Runs the action script without actually uploading files.')
21+
.alias('dry', 'dry-run')
22+
23+
.string('dir')
24+
.describe('dir', 'Bucket sub-directory name. Leave empty to refer to the root of the bucket.')
25+
26+
.demandOption(['bucket', 'role'])
27+
.argv

.github/actions/s3-delete/index.js

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import * as core from '@actions/core'
2+
import { AssumeRoleCommand, STSClient } from '@aws-sdk/client-sts'
3+
import { S3Client, S3ServiceException, paginateListObjectsV2, DeleteObjectsCommand, waitUntilObjectNotExists } from '@aws-sdk/client-s3'
4+
import { args } from './args.js'
5+
6+
const stsClient = new STSClient({ region: args.region })
7+
const s3Credentials = await stsClient.send(new AssumeRoleCommand({
8+
RoleArn: args.role,
9+
RoleSessionName: 'deleteExperimentFromS3Session',
10+
DurationSeconds: 900
11+
}))
12+
13+
const s3Client = new S3Client({
14+
region: args.region,
15+
credentials: {
16+
accessKeyId: s3Credentials.Credentials.AccessKeyId,
17+
secretAccessKey: s3Credentials.Credentials.SecretAccessKey,
18+
sessionToken: s3Credentials.Credentials.SessionToken
19+
}
20+
})
21+
22+
async function collectKeysToDelete(bucketName, bucketDir) {
23+
const keys = []
24+
core.info("Bucket name: " + bucketName)
25+
core.info(`Looking up files with prefix '${bucketDir}'`)
26+
27+
try {
28+
const params = {
29+
Bucket: bucketName,
30+
Prefix:bucketDir
31+
}
32+
const paginator = paginateListObjectsV2({ client: s3Client }, params)
33+
for await (const page of paginator) {
34+
page.Contents?.forEach(obj => {
35+
keys.push(obj.Key)
36+
})
37+
}
38+
core.info(`Found ${keys.length} matching files`)
39+
core.info(keys.map(k => ` • ${k}`).join('\n'))
40+
return keys
41+
} catch (err) {
42+
if (err instanceof S3ServiceException) {
43+
core.setFailed(
44+
`Error from S3 while listing objects for "${bucketName}". ${err.name}: ${err.message}`,
45+
)
46+
} else {
47+
core.setFailed(`Error while listing objects for "${bucketName}". ${err.name}: ${err.message}`)
48+
}
49+
process.exit(1)
50+
}
51+
}
52+
53+
async function deleteFiles(bucketName, keys) {
54+
try {
55+
core.info('Deleting...')
56+
57+
const { Deleted } = await s3Client.send(
58+
new DeleteObjectsCommand({
59+
Bucket: bucketName,
60+
Delete: {
61+
Objects: keys.map((k) => ({ Key: k })),
62+
},
63+
}),
64+
)
65+
66+
for (const key in keys) {
67+
await waitUntilObjectNotExists(
68+
{ client: s3Client },
69+
{ Bucket: bucketName, Key: key },
70+
)
71+
}
72+
core.info(
73+
`Successfully deleted ${Deleted?.length || 0} objects.`,
74+
)
75+
core.info(Deleted?.map((d) => ` • ${d.Key}`).join("\n"))
76+
} catch (err) {
77+
if (err instanceof S3ServiceException) {
78+
core.setFailed(
79+
`Error from S3 while deleting objects for "${bucketName}". ${err.name}: ${err.message}`,
80+
)
81+
} else {
82+
core.setFailed(`Error while deleting objects for "${bucketName}". ${err.name}: ${err.message}`)
83+
}
84+
process.exit(1)
85+
}
86+
}
87+
88+
if (args.dry) {
89+
core.info('This is a dry run.')
90+
}
91+
const keysToBeDeleted = await collectKeysToDelete(args.bucket, args.dir)
92+
if (!args.dry) {
93+
if (keysToBeDeleted.length > 0) {
94+
await deleteFiles(args.bucket, keysToBeDeleted)
95+
} else {
96+
core.info('No files found to delete')
97+
}
98+
}
99+
core.info('Completed successfully')
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow will run automatically when a branch is deleted.
2+
3+
name: Branch Cleanup
4+
5+
on: delete
6+
7+
jobs:
8+
branch-delete:
9+
if: github.event.ref_type == 'branch'
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 5
12+
defaults:
13+
run:
14+
shell: bash
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
20+
- name: Clean up for deleted branch
21+
id: cleanup-start
22+
run: echo "Clean up for branch ${{ github.event.ref }}"
23+
- name: Delete dev experiment
24+
id: s3-delete-dev
25+
uses: ./.github/actions/s3-delete
26+
with:
27+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
28+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
29+
aws_role: ${{ secrets.AWS_ROLE_ARN }}
30+
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
31+
bucket_dir: experiments/dev/${{ github.event.ref }}
32+
dry_run: true
33+
- name: Delete staging experiment
34+
id: s3-delete-staging
35+
uses: ./.github/actions/s3-delete
36+
with:
37+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
38+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
39+
aws_role: ${{ secrets.AWS_ROLE_ARN }}
40+
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
41+
bucket_dir: experiments/staging/${{ github.event.ref }}
42+
dry_run: true
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow can be run on any branch.
2+
# Given an environment, this workflow will delete the branch's experiment from S3
3+
4+
name: Delete Experiment
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
nr_environment:
10+
description: 'Target New Relic environment'
11+
required: true
12+
type: choice
13+
options:
14+
- dev
15+
- staging
16+
17+
jobs:
18+
delete-experiment-on-s3:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 5
21+
defaults:
22+
run:
23+
shell: bash
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
29+
- name: Clean branch name
30+
id: clean-branch-name
31+
run: echo "results=$(echo '${{ github.ref }}' | sed 's/refs\/heads\///g' | sed 's/[^[:alnum:].-]/-/g')" >> $GITHUB_OUTPUT
32+
- name: Delete experiment
33+
id: s3-delete
34+
uses: ./.github/actions/s3-delete
35+
with:
36+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
37+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38+
aws_role: ${{ secrets.AWS_ROLE_ARN }}
39+
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
40+
bucket_dir: experiments/${{ inputs.nr_environment }}/${{ steps.clean-branch-name.outputs.results }}

.github/workflows/eslint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
ref: ${{ inputs.ref || github.ref }}
2626
- uses: actions/setup-node@v4
2727
with:
28-
node-version: lts/*
28+
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
2929
- name: Install project dependencies
3030
run: npm ci
3131
- name: Run eslint

.github/workflows/jest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
ref: ${{ inputs.ref || github.ref }}
4040
- uses: actions/setup-node@v4
4141
with:
42-
node-version: lts/*
42+
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
4343
- name: Install project dependencies
4444
run: npm ci
4545
- name: Run unit tests

.github/workflows/nightly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v4
2626
- uses: actions/setup-node@v4
2727
with:
28-
node-version: lts/*
28+
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
2929
- name: Verify a/b assets
3030
uses: ./.github/actions/fastly-verify
3131
with:
@@ -52,7 +52,7 @@ jobs:
5252
- name: Set up Node.js
5353
uses: actions/setup-node@v4
5454
with:
55-
node-version: 'lts/*'
55+
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
5656
- name: Authenticate with npm
5757
run: npm config set "//registry.npmjs.org/:_authToken" "${{ secrets.BROWSER_NPM_TOKEN }}"
5858
- name: Deprecate old versions

0 commit comments

Comments
 (0)