Testing
parent
af018f0e8b
commit
2a9afdc4ac
|
@ -0,0 +1,126 @@
|
|||
name: PR Update
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
node_version: 16.x
|
||||
pr_id: ${{ github.event.number }}
|
||||
# last_commit_sha: ${{ github.event.pull_request.head.sha }}
|
||||
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 }}
|
||||
|
||||
concurrency:
|
||||
group: pr-update-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Yarn install & cache
|
||||
uses: ./.github/workflows/yarn-install.yml
|
||||
secrets:
|
||||
node_version: ${{ env.node_version }}
|
||||
lint:
|
||||
name: Linters
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- 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: lint the code
|
||||
run: yarn lint
|
||||
build:
|
||||
name: Production build
|
||||
needs: setup
|
||||
uses: ./.github/workflows/production_build.yml
|
||||
with:
|
||||
pr_id: ${{ github.event.number }}
|
||||
secrets:
|
||||
node_version: ${{ env.node_version }}
|
||||
|
||||
e2e-test:
|
||||
name: E2E tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, build]
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- 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 }}
|
||||
# figure the better way supporting all the packages
|
||||
- name: Fake yarn postinstall
|
||||
run: yarn playwright install
|
||||
- name: Run tests
|
||||
run: yarn test-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
|
|
@ -0,0 +1,60 @@
|
|||
name: Production Build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
node_version:
|
||||
required: true
|
||||
|
||||
concurrency:
|
||||
group: prod-build-${{ github.sha }}
|
||||
|
||||
env:
|
||||
staleBuildFilesFindArgs: -maxdepth 1 -type f -regextype posix-egrep -regex ".*\.(json|js|css|map|txt)$"
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
name: Set nodeJs version
|
||||
with:
|
||||
node-version: ${{ secrets.NODE_VERSION }}
|
||||
|
||||
- name: Cache production build
|
||||
id: prod-build-cache
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: prod-build
|
||||
key-1: ${{ secrets.NODE_VERSION }}-${{ hashFiles('yarn.lock') }}
|
||||
key-2: ${{ hashFiles('apps/web/next.config.js') }}
|
||||
with:
|
||||
path: |
|
||||
public
|
||||
.cache
|
||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ github.sha }}
|
||||
restore-keys: |-
|
||||
${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-
|
||||
${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-
|
||||
|
||||
- name: Restore node_modules from cache
|
||||
# skip build on exact cache hit
|
||||
if: steps.prod-build-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: node-modules-yarn
|
||||
cache-key: ${{ secrets.NODE_VERSION }}-${{ hashFiles('yarn.lock') }}
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.cache-key }}
|
||||
|
||||
- name: Gatsby production build
|
||||
if: steps.prod-build-cache.outputs.cache-hit != 'true'
|
||||
run: yarn build
|
|
@ -0,0 +1,43 @@
|
|||
name: Yarn install
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
node_version:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Yarn install & cache
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
concurrency:
|
||||
group: yarn-install-${{ github.sha }}
|
||||
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
name: Set nodeJs version
|
||||
with:
|
||||
node-version: ${{ secrets.NODE_VERSION }}
|
||||
|
||||
# node_module cache helps to avoid 1 minute copying from yarn cache on every job run
|
||||
- name: node_modules cache
|
||||
id: node-modules-cache
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: node-modules-yarn
|
||||
cache-key: ${{ secrets.NODE_VERSION }}-${{ hashFiles('yarn.lock') }}
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.cache-key }}
|
||||
restore-keys: ${{ runner.os }}-${{ env.cache-name }}-
|
||||
|
||||
- name: Yarn install
|
||||
if: steps.node-modules-cache.outputs.cache-hit != 'true'
|
||||
run: yarn install --prefer-offline --frozen-lockfile
|
Loading…
Reference in New Issue