Makes sure code quality stays high by checking that code is linted & formatted in CI. ### Reason Frustration — so that [things like this](https://github.com/webrecorder/browsertrix-cloud/pull/1500#issuecomment-1920087667) don't happen in the future. I tried to merge `main` into a branch to get it up to date with main, and main isn't totally formatted or linted properly, and then formatting the codebase introduced a whole bunch of unrelated changes. Running a formatter or linter shouldn't cause unrelated code changes, and `main` should always be in a correct state in terms of linting and formatting. ### Testing - [x] Test run with failing lint checks errors: https://github.com/webrecorder/browsertrix-cloud/actions/runs/7733354321/job/21085236200 - [x] Test run with failing formatting check errors: https://github.com/webrecorder/browsertrix-cloud/actions/runs/7733501666/job/21085717519 - [x] Test run with both passing lint & formatting checks passes: https://github.com/webrecorder/browsertrix-cloud/actions/runs/7733529142/job/21085796727
51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
name: Frontend Build Check
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'frontend/src/**'
|
|
- 'frontend/*.json'
|
|
- 'frontend/*.js'
|
|
- 'frontend/*.ts'
|
|
jobs:
|
|
setup-and-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '16'
|
|
cache: 'yarn'
|
|
cache-dependency-path: frontend/yarn.lock
|
|
- name: Restore cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: frontend/dist
|
|
key: ${{ runner.os }}-btrix-frontend-build-${{ hashFiles('frontend/dist') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-btrix-frontend-build-
|
|
- name: Install dependencies
|
|
working-directory: frontend
|
|
env:
|
|
HUSKY: 0
|
|
run: yarn install --frozen-lockfile
|
|
- name: Lint
|
|
working-directory: frontend
|
|
run: yarn lint:check
|
|
- name: Format
|
|
working-directory: frontend
|
|
run: yarn format:check
|
|
- name: Unit tests
|
|
working-directory: frontend
|
|
run: yarn test
|
|
- name: Localization build
|
|
working-directory: frontend
|
|
run: yarn localize:prepare
|
|
- name: Remove non-production dependencies
|
|
working-directory: frontend
|
|
run: yarn install --frozen-lockfile --ignore-optional --production
|
|
- name: Webpack build
|
|
working-directory: frontend
|
|
run: yarn build
|