Skip to content

Commit

Permalink
feat: Remove img, jsonp, and xhrGet methods (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley authored Jun 21, 2023
1 parent 1371a53 commit f92f88e
Show file tree
Hide file tree
Showing 163 changed files with 3,870 additions and 3,275 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/ci.yml

This file was deleted.

20 changes: 17 additions & 3 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ on:
description: 'The collection of jest tests to run'
required: true
type: choice
options:
options:
- unit
- component
default: 'unit'
coverage:
description: 'Enable code coverage'
required: false
type: boolean
default: false
workflow_call:
inputs:
ref:
Expand All @@ -25,6 +30,11 @@ on:
required: false
type: string
default: 'unit'
coverage:
description: 'Enable code coverage'
required: false
type: boolean
default: false

jobs:
run:
Expand All @@ -36,6 +46,8 @@ jobs:
defaults:
run:
shell: bash
env:
COVERAGE: ${{ inputs.coverage }}
steps:
- name: Setup container
run: apt update && apt install -y git
Expand All @@ -51,11 +63,12 @@ jobs:
run: npm run test:${{ inputs.collection }} -- --coverage
- name: Find pull request
id: pull-request-target
if: ${{ inputs.coverage }}
uses: ./.github/actions/find-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload pr code coverage
if: ${{ steps.pull-request-target.outputs.results }}
if: ${{ inputs.coverage && steps.pull-request-target.outputs.results }}
uses: codecov/codecov-action@v3
env:
GITHUB_HEAD_REF: ${{ inputs.ref }}
Expand All @@ -65,13 +78,14 @@ jobs:
flags: jest-${{ inputs.collection }}
verbose: true
- name: Upload branch code coverage
if: ${{ !steps.pull-request-target.outputs.results }}
if: ${{ inputs.coverage && steps.pull-request-target.outputs.results }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: jest-${{ inputs.collection }}
verbose: true
- name: Archive code coverage results
if: ${{ inputs.coverage }}
uses: actions/upload-artifact@v3
with:
name: jest-${{ inputs.collection }}-code-coverage-report
Expand Down
118 changes: 115 additions & 3 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
pr_required: true

comment-pull-request:
name: Comment pull request
pending-comment-pull-request:
name: Pending comment pull request
needs: [find-pull-request]
runs-on: ubuntu-latest
container:
Expand All @@ -53,7 +53,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Pull Request Checks](https://github.com/newrelic/newrelic-browser-agent/actions/workflows/pull-request-checks.yml/badge.svg?branch=${{ github.ref_name }})](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Pending-yellow)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
Expand All @@ -66,6 +66,7 @@ jobs:
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
collection: 'unit'
coverage: true
secrets: inherit

jest-component:
Expand All @@ -75,6 +76,7 @@ jobs:
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
collection: 'component'
coverage: true
secrets: inherit

eslint:
Expand All @@ -94,3 +96,113 @@ jobs:
build-number: PR${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number}}-job-${{ github.run_number }}-attempt-${{ github.run_attempt }}
coverage: true
secrets: inherit

size-check:
runs-on: ubuntu-latest
needs: find-pull-request
timeout-minutes: 30
container:
image: ubuntu:latest
defaults:
run:
shell: bash
steps:
- name: Setup container
run: apt update && apt install -y git
- uses: actions/checkout@v3
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Running cdn build
run: npm run cdn:build:dev
- name: Running npm build
run: |
npm run build:npm
npm run tools:test-builds
- name: Generating npm build stats
run: node ./tools/scripts/npm-build-stats.js
- name: Generating asset size report
run: node ./tools/scripts/diff-sizes.mjs -o build
- name: Reading asset size report
id: asset-size-report
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "results<<$EOF" >> "$GITHUB_OUTPUT"
cat ./build/size_report.md >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Comment pull request
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: ${{ steps.asset-size-report.outputs.results }}
comment_tag: <!-- browser_agent asset size report -->
- name: Archive asset size report results
uses: actions/upload-artifact@v3
with:
name: asset-size-report
path: |
build/size_report.*
build/*.stats.html
build/*.stats.json
status-comment-pull-request:
name: Comment pull request
needs: [find-pull-request,jest-unit,jest-component,eslint,wdio-coverage]
if: ${{ always() && needs.find-pull-request.result == 'success' }}
runs-on: ubuntu-latest
container:
image: ubuntu:latest
defaults:
run:
shell: bash
steps:
- name: Setup container
run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y git tzdata
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Get workflow time
id: workflow-time
run: echo "results=$(TZ=America/Chicago date +'%B %d, %Y %H:%M:%S %Z')" >> $GITHUB_OUTPUT
- name: Comment pull request success
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Success-green)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
comment_tag: <!-- browser_agent pull request checks -->
- name: Comment pull request failed
if: ${{ contains(needs.*.result, 'failure') }}
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Failure-red)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
comment_tag: <!-- browser_agent pull request checks -->
- name: Comment pull request cancelled
if: ${{ contains(needs.*.result, 'cancelled') }}
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Cancelled-orange)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
comment_tag: <!-- browser_agent pull request checks -->
8 changes: 8 additions & 0 deletions .github/workflows/wdio-all-browsers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ jobs:
browser-target: android@*
build-number: $BUILD_NUMBER
secrets: inherit

ie:
uses: ./.github/workflows/wdio-single-browser.yml
with:
browser-target: ie@11
build-number: $BUILD_NUMBER
additional-flags: -P
secrets: inherit
6 changes: 4 additions & 2 deletions .github/workflows/wdio-single-browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
required: false
type: string
coverage:
description: 'Flag indicating if code coverage should be collected and reported to codecov'
description: 'Enable code coverage'
required: false
type: boolean
default: false
Expand All @@ -35,7 +35,7 @@ on:
required: false
type: string
coverage:
description: 'Flag indicating if code coverage should be collected and reported to codecov'
description: 'Enable code coverage'
required: false
type: boolean
default: false
Expand All @@ -56,6 +56,7 @@ jobs:
shell: bash
env:
BUILD_NUMBER: ${{ inputs.build-number }}
COVERAGE: ${{ inputs.coverage }}
NEWRELIC_ENVIRONMENT: ci
JIL_SAUCE_LABS_USERNAME: ${{ secrets.JIL_SAUCE_LABS_USERNAME }}
JIL_SAUCE_LABS_ACCESS_KEY: ${{ secrets.JIL_SAUCE_LABS_ACCESS_KEY }}
Expand Down Expand Up @@ -84,6 +85,7 @@ jobs:
${{ inputs.additional-flags || '' }}
- name: Find pull request
id: pull-request-target
if: ${{ inputs.coverage }}
uses: ./.github/actions/find-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 13 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
const process = require('process')

module.exports = function (api) {
module.exports = function (api, ...args) {
api.cache(true)

if (!process.env.BUILD_VERSION) {
process.env.BUILD_VERSION = process.env.VERSION_OVERRIDE || require('./package.json').version
}
if (!process.env.BUILD_ENV) {
process.env.BUILD_ENV = 'CDN'
}

const ignore = [
'**/*.test.js',
'**/*.component-test.js',
'**/__mocks__/*.js'
]
const presets = [
'@babel/preset-env'
]
Expand Down Expand Up @@ -34,6 +42,7 @@ module.exports = function (api) {
]
},
webpack: {
ignore,
plugins: [
[
'./tools/scripts/babel-plugin-transform-import',
Expand All @@ -44,6 +53,7 @@ module.exports = function (api) {
]
},
'webpack-ie11': {
ignore,
assumptions: {
iterableIsArray: false
},
Expand Down Expand Up @@ -72,6 +82,7 @@ module.exports = function (api) {
]
},
'npm-cjs': {
ignore,
presets: [
[
'@babel/preset-env', {
Expand All @@ -89,6 +100,7 @@ module.exports = function (api) {
]
},
'npm-esm': {
ignore,
presets: [
[
'@babel/preset-env', {
Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flag_management:
default_rules:
carryforward: true
2 changes: 1 addition & 1 deletion jest.component-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module.exports = {
coverageDirectory: 'coverage',
collectCoverageFrom: [
'src/**/*.js',
'!src/**/*.component-test.js',
'!src/**/*.test.js',
'!src/**/*.component-test.js',
'!src/index.js',
'!src/cdn/**/*.js',
'!src/features/*/index.js',
Expand Down
Loading

0 comments on commit f92f88e

Please sign in to comment.