Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-messiah committed Jan 16, 2025
2 parents 1c34e1d + 86943eb commit 1fe2412
Show file tree
Hide file tree
Showing 178 changed files with 4,982 additions and 3,230 deletions.
7 changes: 6 additions & 1 deletion .github/actions/build-ab/templates/released.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ window.NREUM={
},
performance: {
capture_marks: false,
capture_measures: true
capture_measures: true,
resources: {
enabled: true,
ignore_newrelic: false,
first_party_domains: ['dev-one.nr-assets.net', 'staging-one.nr-assets.net', 'one.nr-assets.net', 'nr-assets.net']
}
},
proxy: {},
user_actions: {elementAttributes: ['id', 'className', 'tagName', 'type', 'innerText', 'textContent', 'ariaLabel', 'alt', 'title']}
Expand Down
47 changes: 47 additions & 0 deletions .github/actions/nr-report-build-size/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This composite action is used to report the local build size to New Relic
# You must build the agent before running this action

name: 'Report Build Size to New Relic'

inputs:
nr-api-key:
description: 'NR API Key for reporting events'
required: true

runs:
using: "composite"
steps:
- name: Install dependencies
run: npm install --silent --no-progress --prefix $GITHUB_ACTION_PATH/..
shell: bash
- name: Get local stats
id: get-stats
shell: bash
run: |
rum=$(cat ./build/nr-rum-standard.stats.json); echo "rum=$rum" >> $GITHUB_OUTPUT;
full=$(cat ./build/nr-full-standard.stats.json); echo "full=$full" >> $GITHUB_OUTPUT;
spa=$(cat ./build/nr-spa-standard.stats.json); echo "spa=$spa" >> $GITHUB_OUTPUT;
- name: Report rum size to NR
uses: metal-messiah/webpack-build-size-action@main
with:
nr-api-key: ${{ inputs.nr-api-key }}
nr-account-id: '550352'
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.rum }}
file-name-filter: '.min.js'
- name: Report full size to NR
uses: metal-messiah/webpack-build-size-action@main
with:
nr-api-key: ${{ inputs.nr-api-key }}
nr-account-id: '550352'
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.full }}
file-name-filter: '.min.js'
- name: Report spa size to NR
uses: metal-messiah/webpack-build-size-action@main
with:
nr-api-key: ${{ inputs.nr-api-key }}
nr-account-id: '550352'
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.spa }}
file-name-filter: '.min.js'
11 changes: 9 additions & 2 deletions .github/actions/post-release-updates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ if (args.openPullRequest) {

gitRunner = new GitCliRunner(REPO_ROOT_PATH, args.githubLogin, args.githubToken, args.githubUserName, args.githubEmail)
await gitRunner.setUser()
await gitRunner.checkoutBranch(REPO_BASE, true)
try {
await gitRunner.deleteLocalBranch(PR_BRANCH_NAME)
} catch (error) {
Expand Down Expand Up @@ -82,6 +81,13 @@ await spawnAsync(
DEFAULT_SPAWN_OPTIONS
)

console.log('Updating LambdaTest webview assets')
await spawnAsync(
`npm${os.platform() === 'win32' ? '.cmd' : ''}`,
['run', 'lt:upload-webview-assets'],
DEFAULT_SPAWN_OPTIONS
)

console.log('Updating third-party licenses')
await spawnAsync(
`npm${os.platform() === 'win32' ? '.cmd' : ''}`,
Expand Down Expand Up @@ -111,7 +117,8 @@ if (args.openPullRequest) {
'tools/browsers-lists/*.json',
'third_party_manifest.json',
'THIRD_PARTY_NOTICES.md',
'tools/test-builds/**/package.json'
'tools/test-builds/**/package.json',
'tools/lambda-test/webview-asset-ids.mjs'
],
COMMIT_MESSAGE,
true
Expand Down
52 changes: 52 additions & 0 deletions .github/actions/s3-delete/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This composite action is used to delete files from a S3 bucket.

name: 'S3 File Deletion'

inputs:
aws_access_key_id:
description: 'AWS access key id used for authentication.'
required: true
aws_secret_access_key:
description: 'AWS secret access key used for authentication.'
required: true
aws_region:
description: "AWS region where S3 bucket is located."
required: false
default: us-east-1
aws_role:
description: "AWS role ARN that needs to be used for authentication."
required: true
aws_bucket_name:
description: "S3 bucket name where files need to be deleted."
required: true
dry_run:
description: "Indicates if we should just list files to deleted without actually deleting them."
required: false
bucket_dir:
description: 'A sub directory where the files are located within the S3 bucket.'
required: false

outputs:
results:
description: "Array of objects containing information about each file uploaded"
value: ${{ steps.action-script.outputs.results }}

runs:
using: "composite"
steps:
- name: Install dependencies
run: npm install --silent --no-progress --prefix $GITHUB_ACTION_PATH/..
shell: bash
- name: Run action script
id: action-script
env:
AWS_ACCESS_KEY_ID: ${{ inputs.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.aws_secret_access_key }}
run: |
node $GITHUB_ACTION_PATH/index.js \
--region ${{ inputs.aws_region }} \
--bucket ${{ inputs.aws_bucket_name }} \
--role ${{ inputs.aws_role }} \
${{ inputs.dry_run && '--dry' || '' }} \
${{ inputs.bucket_dir && format('--dir {0}', inputs.bucket_dir) || '' }}
shell: bash
27 changes: 27 additions & 0 deletions .github/actions/s3-delete/args.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import process from 'process'
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'

export const args = yargs(hideBin(process.argv))
.usage('$0 [options]')

.string('role')
.describe('role', 'S3 role ARN')

.string('bucket')
.describe('bucket', 'S3 bucket name')

.string('region')
.describe('region', 'AWS region location of S3 bucket. Defaults to us-east-1.')
.default('region', 'us-east-1')

.boolean('dry')
.default('dry', false)
.describe('dry', 'Runs the action script without actually uploading files.')
.alias('dry', 'dry-run')

.string('dir')
.describe('dir', 'Bucket sub-directory name. Leave empty to refer to the root of the bucket.')

.demandOption(['bucket', 'role'])
.argv
99 changes: 99 additions & 0 deletions .github/actions/s3-delete/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import * as core from '@actions/core'
import { AssumeRoleCommand, STSClient } from '@aws-sdk/client-sts'
import { S3Client, S3ServiceException, paginateListObjectsV2, DeleteObjectsCommand, waitUntilObjectNotExists } from '@aws-sdk/client-s3'
import { args } from './args.js'

const stsClient = new STSClient({ region: args.region })
const s3Credentials = await stsClient.send(new AssumeRoleCommand({
RoleArn: args.role,
RoleSessionName: 'deleteExperimentFromS3Session',
DurationSeconds: 900
}))

const s3Client = new S3Client({
region: args.region,
credentials: {
accessKeyId: s3Credentials.Credentials.AccessKeyId,
secretAccessKey: s3Credentials.Credentials.SecretAccessKey,
sessionToken: s3Credentials.Credentials.SessionToken
}
})

async function collectKeysToDelete(bucketName, bucketDir) {
const keys = []
core.info("Bucket name: " + bucketName)
core.info(`Looking up files with prefix '${bucketDir}'`)

try {
const params = {
Bucket: bucketName,
Prefix:bucketDir
}
const paginator = paginateListObjectsV2({ client: s3Client }, params)
for await (const page of paginator) {
page.Contents?.forEach(obj => {
keys.push(obj.Key)
})
}
core.info(`Found ${keys.length} matching files`)
core.info(keys.map(k => ` • ${k}`).join('\n'))
return keys
} catch (err) {
if (err instanceof S3ServiceException) {
core.setFailed(
`Error from S3 while listing objects for "${bucketName}". ${err.name}: ${err.message}`,
)
} else {
core.setFailed(`Error while listing objects for "${bucketName}". ${err.name}: ${err.message}`)
}
process.exit(1)
}
}

async function deleteFiles(bucketName, keys) {
try {
core.info('Deleting...')

const { Deleted } = await s3Client.send(
new DeleteObjectsCommand({
Bucket: bucketName,
Delete: {
Objects: keys.map((k) => ({ Key: k })),
},
}),
)

for (const key in keys) {
await waitUntilObjectNotExists(
{ client: s3Client },
{ Bucket: bucketName, Key: key },
)
}
core.info(
`Successfully deleted ${Deleted?.length || 0} objects.`,
)
core.info(Deleted?.map((d) => ` • ${d.Key}`).join("\n"))
} catch (err) {
if (err instanceof S3ServiceException) {
core.setFailed(
`Error from S3 while deleting objects for "${bucketName}". ${err.name}: ${err.message}`,
)
} else {
core.setFailed(`Error while deleting objects for "${bucketName}". ${err.name}: ${err.message}`)
}
process.exit(1)
}
}

if (args.dry) {
core.info('This is a dry run.')
}
const keysToBeDeleted = await collectKeysToDelete(args.bucket, args.dir)
if (!args.dry) {
if (keysToBeDeleted.length > 0) {
await deleteFiles(args.bucket, keysToBeDeleted)
} else {
core.info('No files found to delete')
}
}
core.info('Completed successfully')
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
42 changes: 42 additions & 0 deletions .github/workflows/branch-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will run automatically when a branch is deleted.

name: Branch Cleanup

on: delete

jobs:
branch-delete:
if: github.event.ref_type == 'branch'
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
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.
- name: Clean up for deleted branch
id: cleanup-start
run: echo "Clean up for branch ${{ github.event.ref }}"
- name: Delete dev experiment
id: s3-delete-dev
uses: ./.github/actions/s3-delete
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_role: ${{ secrets.AWS_ROLE_ARN }}
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
bucket_dir: experiments/dev/${{ github.event.ref }}
dry_run: true
- name: Delete staging experiment
id: s3-delete-staging
uses: ./.github/actions/s3-delete
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_role: ${{ secrets.AWS_ROLE_ARN }}
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
bucket_dir: experiments/staging/${{ github.event.ref }}
dry_run: true
40 changes: 40 additions & 0 deletions .github/workflows/delete-experiment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow can be run on any branch.
# Given an environment, this workflow will delete the branch's experiment from S3

name: Delete Experiment

on:
workflow_dispatch:
inputs:
nr_environment:
description: 'Target New Relic environment'
required: true
type: choice
options:
- dev
- staging

jobs:
delete-experiment-on-s3:
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
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.
- name: Clean branch name
id: clean-branch-name
run: echo "results=$(echo '${{ github.ref }}' | sed 's/refs\/heads\///g' | sed 's/[^[:alnum:].-]/-/g')" >> $GITHUB_OUTPUT
- name: Delete experiment
id: s3-delete
uses: ./.github/actions/s3-delete
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_role: ${{ secrets.AWS_ROLE_ARN }}
aws_bucket_name: ${{ secrets.AWS_BUCKET }}
bucket_dir: experiments/${{ inputs.nr_environment }}/${{ steps.clean-branch-name.outputs.results }}
2 changes: 1 addition & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
ref: ${{ inputs.ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: lts/*
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.
- name: Install project dependencies
run: npm ci
- name: Run eslint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
ref: ${{ inputs.ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: lts/*
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.
- name: Install project dependencies
run: npm ci
- name: Run unit tests
Expand Down
Loading

0 comments on commit 1fe2412

Please sign in to comment.