Skip to content

fix: Address issues with dynamic require and Rollup.js (#1584) #1303

fix: Address issues with dynamic require and Rollup.js (#1584)

fix: Address issues with dynamic require and Rollup.js (#1584) #1303

Workflow file for this run

# This workflow runs on push to the main branch. This is to execute checks
# like jest, upload test coverage to keep codecov updates, and build and deploy
# the main branch changes to our internal dev and stage environment. This workflow
# can be manually executed but only on the main branch.
name: Publish Dev
on:
workflow_dispatch:
push:
branches:
- 'main'
# Only allow one instance of this workflow to run at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
jest-tests:
if: github.ref == 'refs/heads/main'
name: Jest tests
uses: ./.github/workflows/jest.yml
secrets: inherit
with:
coverage: true
# Build and publish the latest code from the main branch
publish-dev-to-s3:
needs: [jest-tests]
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
ref: main
- 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: Install project dependencies
run: npm ci
- name: Build dev
run: npm run cdn:build:dev
- name: Upload dev
id: s3-upload
uses: ./.github/actions/s3-upload
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 }}
local_dir: $GITHUB_WORKSPACE/build
bucket_dir: dev/
- name: Gather cdn purge paths
id: dev-purge-paths
run: echo "results=$(echo '${{ steps.s3-upload.outputs.results }}' | jq -j '.[].Key + " "')" >> $GITHUB_OUTPUT
- name: Purge production cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
purge_path: ${{ steps.dev-purge-paths.outputs.results }}
- name: Purge staging cdn
uses: ./.github/actions/fastly-purge
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
purge_path: ${{ steps.dev-purge-paths.outputs.results }}
- name: Verify production cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}
- name: Verify staging cdn assets
uses: ./.github/actions/fastly-verify
with:
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
fastly_service: staging-js-agent.newrelic.com
asset_path: ${{ join(fromJson(steps.s3-upload.outputs.results).*.Key, ' ') }}
# This step creates a new Change Tracking Marker
- name: New Relic Application Deployment Marker
uses: newrelic/deployment-marker-action@v2.3.0
with:
apiKey: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
guid: ${{ secrets.INTERNAL_STAGING_INGEST_ENTITY_GUID }}
commit: "${{ github.sha }}"
version: "${{ github.ref_name }}"
user: "${{ github.actor }}"
- 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 lite size to NR
uses: newrelic-apps/capture-build-size@v1.0.1
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.rum }}
file-name-filter: '.min.js'
trigger: 'publish-dev'
traverse: true
- name: Report pro size to NR
uses: newrelic-apps/capture-build-size@v1.0.1
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.full }}
file-name-filter: '.min.js'
trigger: 'publish-dev'
traverse: true
- name: Report spa size to NR
uses: newrelic-apps/capture-build-size@v1.0.1
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.spa }}
file-name-filter: '.min.js'
trigger: 'publish-dev'
traverse: true
# Publish dev to staging NRDB
# publish-dev-nr:
# needs: [publish-dev-to-s3]
# runs-on: ubuntu-latest
# timeout-minutes: 30
# defaults:
# run:
# shell: bash
# steps:
# - uses: actions/checkout@v4
# with:
# ref: main
# - 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: Publish dev loader to nr
# uses: ./.github/actions/nr-upload-dev
# with:
# nr_stage_api_key: ${{ secrets.NR_API_KEY_STAGING }}
# Rebuild and publish the dev environment A/B script
publish-dev-ab:
needs: [publish-dev-to-s3]
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
ref: main
- 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: Publish dev a/b script
uses: ./.github/actions/internal-ab
with:
nr_environment: dev
nrba_app_id: ${{ secrets.INTERNAL_DEV_APPLICATION_ID }}
nrba_license_key: ${{ secrets.INTERNAL_LICENSE_KEY }}
nrba_ab_app_id: ${{ secrets.INTERNAL_AB_DEV_APPLICATION_ID }}
nrba_ab_license_key: ${{ secrets.INTERNAL_AB_LICENSE_KEY }}
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 }}
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}
# Rebuild and publish the staging environment A/B script
publish-staging-ab:
needs: [publish-dev-to-s3]
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
ref: main
- 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: Deploy staging a/b script
uses: ./.github/actions/internal-ab
with:
nr_environment: staging
nrba_app_id: ${{ secrets.INTERNAL_STAGING_APPLICATION_ID }}
nrba_license_key: ${{ secrets.INTERNAL_LICENSE_KEY }}
nrba_ab_app_id: ${{ secrets.INTERNAL_AB_STAGING_APPLICATION_ID }}
nrba_ab_license_key: ${{ secrets.INTERNAL_AB_LICENSE_KEY }}
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 }}
fastly_key: ${{ secrets.FASTLY_PURGE_KEY }}