browsertrix/.github/workflows/frontend-build-check.yaml
Emma Segal-Grossman 99dd9b4acb
Remove non-prod & optional dependencies when building frontend in ci (#1455)
Fixes #1454 

## Motivation

We've had a number of cases recently where a build dependency is added
to `devDependencies`, the PR passes the frontend build check
(`frontend-build-check.yaml`) in the branch, and then fails the cluster
run (`k3d-ci.yaml`) in `main` because the frontend build check installs
all dependencies, whereas the cluster run uses the frontend Dockerfile,
which skips everything but prod dependencies.

## Changes

This runs an additional step in the frontend build check, after running
unit tests and the l10n build but before doing the build, that re-runs
`yarn` with the same arguments as are in the frontend Dockerfile,
installing just prod dependencies.

This results in slightly longer frontend build check runtimes, but
should save us some wasted time fixing broken `main`.
2024-01-10 11:46:17 -08:00

45 lines
1.3 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: 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