browsertrix/.github/workflows/frontend-build-check.yaml
Emma Segal-Grossman 9a799cc8ab
Ensure that CI fails if extracted strings don't match (#2078)
- Ensures extracted strings get formatted before checking against index
- Fixes index check by switching from `git diff-index` to `git diff`,
and ensures the proper `--exit-code` flag is present (implicitly turned
on by `--quiet`)
- Adds actionable error message when the check fails
- Updates Github's actions versions from v3 to v4 (major version bump is
primarily just for default node version updates, but this way we'll get
future updates)
- Adds formatting step to npm script for extracting messages
- Runs a string extraction & format against current main
2024-09-16 16:48:33 -04:00

65 lines
2.1 KiB
YAML

name: Frontend Build Check
on:
pull_request:
paths:
- 'frontend/src/**'
- 'frontend/*.json'
- 'frontend/*.js'
- 'frontend/*.ts'
- '.github/workflows/frontend-build-check.yaml'
jobs:
setup-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
cache-dependency-path: frontend/yarn.lock
- name: Restore cache
uses: actions/cache@v4
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
# TODO Reenable when https://github.com/webrecorder/browsertrix-cloud/issues/1618 is addressed
# run: yarn format:check
run: echo "yarn format:check disabled"
- name: Unit tests
working-directory: frontend
run: yarn test
- name: Check extracted strings
working-directory: frontend
run: yarn localize:extract && if ! git diff --quiet -- ; then echo "Error extracting strings, please run \`yarn localize:extract\` from the \`frontend\` directory and commit the results."; false; fi
- name: Localization build
working-directory: frontend
run: yarn localize:build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
- name: Build Frontend
uses: docker/build-push-action@v3
with:
context: frontend
load: true
tags: webrecorder/browsertrix-frontend:latest
cache-from: type=gha,scope=frontend
cache-to: type=gha,scope=frontend,mode=max