Skip to content

Commit

Permalink
chore: update pr workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley committed Jul 13, 2023
1 parent 8a6f319 commit 9a554a1
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 79 deletions.
155 changes: 82 additions & 73 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,109 +2,49 @@ name: 'Pull Request Checks'

on:
workflow_dispatch:
pull_request:

jobs:
find-pull-request:
name: Find pull request target
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
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 -->
# Jobs for pull_request events

jest-unit:
name: Jest unit tests
needs: find-pull-request
if: github.event_name == 'pull_request'
uses: ./.github/workflows/jest.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
ref: ${{ github.ref }}
collection: 'unit'
coverage: true
secrets: inherit

jest-component:
name: Jest component tests
needs: find-pull-request
if: github.event_name == 'pull_request'
uses: ./.github/workflows/jest.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
ref: ${{ github.ref }}
collection: 'component'
coverage: true
secrets: inherit

eslint:
name: ESLint
needs: find-pull-request
if: github.event_name == 'pull_request'
uses: ./.github/workflows/eslint.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'

wdio-coverage:
name: WDIO coverage
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
additional-flags: -v
secrets: inherit
ref: ${{ github.ref }}

size-check:
runs-on: ubuntu-latest
needs: find-pull-request
if: github.event_name == 'pull_request'
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
ref: ${{ github.ref }}
- uses: actions/setup-node@v3
with:
node-version: lts/*
Expand All @@ -131,7 +71,7 @@ jobs:
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
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
Expand All @@ -143,8 +83,77 @@ jobs:
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
additional-flags: -v
secrets: inherit

wdio:
name: WDIO
if: github.event_name == 'workflow_dispatch'
needs: [find-pull-request,wdio-coverage]
uses: ./.github/workflows/wdio-all-browsers.yml
with:
Expand All @@ -154,8 +163,8 @@ jobs:

complete-status-comment-pull-request:
name: Comment pull request
needs: [find-pull-request,jest-unit,jest-component,eslint,wdio-coverage,size-check,wdio]
if: ${{ always() && needs.find-pull-request.result == 'success' }}
if: github.event_name == 'workflow_dispatch' && needs.find-pull-request.result == 'success'
needs: [find-pull-request,wdio-coverage,wdio]
runs-on: ubuntu-latest
defaults:
run:
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a554a1

Please sign in to comment.