Skip to content

Pull Request Checks #234

Pull Request Checks

Pull Request Checks #234

name: 'Pull Request Checks'
on:
workflow_dispatch:
pull_request:
jobs:
# Jobs for pull_request events
jest-unit:
name: Jest unit tests
if: github.event_name == 'pull_request'
uses: ./.github/workflows/jest.yml
with:
ref: ${{ github.ref }}
collection: 'unit'
coverage: true
secrets: inherit
jest-component:
name: Jest component tests
if: github.event_name == 'pull_request'
uses: ./.github/workflows/jest.yml
with:
ref: ${{ github.ref }}
collection: 'component'
coverage: true
secrets: inherit
eslint:
name: ESLint
if: github.event_name == 'pull_request'
uses: ./.github/workflows/eslint.yml
with:
ref: ${{ github.ref }}
size-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- 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: ${{ github.event.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
# Jobs for workflow_dispatch events
find-pull-request:
name: Find pull request target
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
outputs:
pull-request-target: ${{ steps.pull-request-target.outputs.results }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Find pull request target
id: pull-request-target
uses: ./.github/actions/find-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_required: true
pending-comment-pull-request:
name: Pending comment pull request
if: github.event_name == 'workflow_dispatch'
needs: find-pull-request
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Setup runner
run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y git tzdata
- 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: 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
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-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 }})
comment_tag: <!-- browser_agent pull request checks -->
wdio-coverage:
name: WDIO coverage
if: github.event_name == 'workflow_dispatch'
needs: find-pull-request
uses: ./.github/workflows/wdio-single-browser.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
browser-target: chrome@latest
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
wdio:
name: WDIO
if: github.event_name == 'workflow_dispatch'
needs: find-pull-request
uses: ./.github/workflows/wdio-all-browsers.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
build-number: PR${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number}}-job-${{ github.run_number }}-attempt-${{ github.run_attempt }}
secrets: inherit
jil:
name: JIL
if: github.event_name == 'workflow_dispatch'
needs: [find-pull-request,wdio-coverage,wdio]
uses: ./.github/workflows/jil-all-browsers.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
build-number: PR${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number}}-job-${{ github.run_number }}-attempt-${{ github.run_attempt }}
secrets: inherit
complete-status-comment-pull-request:
name: Comment pull request
if: always() && github.event_name == 'workflow_dispatch' && needs.find-pull-request.result == 'success'
needs: [find-pull-request,wdio-coverage,wdio,jil]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Setup container
run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y git tzdata
- 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: 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 -->