Update pr.yml

pull/7267/head
zomars 2023-02-17 20:12:06 -07:00
parent e834b42e87
commit 1676d9070b
1 changed files with 16 additions and 51 deletions

View File

@ -1,7 +1,6 @@
name: PR Update name: PR Update
on: on:
push:
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
@ -10,6 +9,8 @@ env:
pr_id: ${{ github.event.number }} pr_id: ${{ github.event.number }}
# last_commit_sha: ${{ github.event.pull_request.head.sha }} # last_commit_sha: ${{ github.event.pull_request.head.sha }}
gh_action_name: pull_request gh_action_name: pull_request
bsr_filename_txt: bundle-size-report.txt
stale_build_files_find_args: -maxdepth 1 -type f -regextype posix-egrep -regex ".*\.(json|js|css|map|txt)$"
merge_base_cmd: git merge-base origin/${{ github.base_ref }} ${{ github.event.pull_request.head.sha }} merge_base_cmd: git merge-base origin/${{ github.base_ref }} ${{ github.event.pull_request.head.sha }}
concurrency: concurrency:
@ -19,9 +20,10 @@ concurrency:
jobs: jobs:
setup: setup:
name: Yarn install & cache name: Yarn install & cache
uses: ./.github/workflows/yarn-install.yml uses: ./.github/workflows/yarn_install.yml
secrets: secrets:
node_version: ${{ secrets.NODE_VERSION }} node_version: ${{ secrets.NODE_VERSION }}
lint: lint:
name: Linters name: Linters
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -47,21 +49,29 @@ jobs:
name: Production build name: Production build
needs: setup needs: setup
uses: ./.github/workflows/production-build.yml uses: ./.github/workflows/production-build.yml
with:
pr_id: ${{ github.event.number }}
secrets: secrets:
node_version: ${{ env.node_version }} node_version: ${{ secrets.NODE_VERSION }}
e2e-test: e2e-test:
name: E2E tests name: E2E tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [lint, build] needs: [lint, build]
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
name: Set nodeJs version name: Set nodeJs version
with: with:
node-version: ${{ env.node_version }} node-version: ${{ env.node_version }}
- name: Restore node_modules from cache - name: Restore node_modules from cache
uses: actions/cache@v3 uses: actions/cache@v3
env: env:
@ -70,54 +80,9 @@ jobs:
with: with:
path: node_modules path: node_modules
key: ${{ runner.os }}-${{ env.cache_name }}-${{ env.cache_fingerprint }} key: ${{ runner.os }}-${{ env.cache_name }}-${{ env.cache_fingerprint }}
# figure the better way supporting all the packages # figure the better way supporting all the packages
- name: Fake yarn postinstall - name: Fake yarn postinstall
run: yarn playwright install run: yarn playwright install
- name: Run tests - name: Run tests
run: yarn test-e2e run: yarn e2e
bundle-size-report:
name: Bundle size report
runs-on: ubuntu-latest
needs: [build]
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 20
- run: git fetch --no-tags --prune --depth=20 origin main
- uses: actions/setup-node@v3
name: Set nodeJs version
with:
node-version: ${{ env.node_version }}
- name: Restore node_modules from cache
uses: actions/cache@v3
env:
cache_name: node-modules-yarn
cache_fingerprint: ${{ env.node_version }}-${{ hashFiles('yarn.lock') }}
with:
path: node_modules
key: ${{ runner.os }}-${{ env.cache_name }}-${{ env.cache_fingerprint }}
- name: Restore exact production build from cache
uses: actions/cache@v3
env:
cache_name: prod-build
key_1: ${{ env.node_version }}-${{ hashFiles('yarn.lock') }}
key_2: ${{ hashFiles('gatsby.config.ts','gatsby.node.ts','gatsby-ssr.tsx','src/html.tsx','src/gatsby-hooks/*.*') }}
with:
path: |
public
.cache
key: ${{ runner.os }}-${{ env.cache_name }}-${{ env.key_1 }}-${{ env.key_2 }}-${{ github.sha }}
- name: Find the "merge-base" between target branch and last PR commit
run: echo "merge_base_sha=$(${{ env.merge_base_cmd }})" >> $GITHUB_ENV