browsertrix/.github/workflows/frontend-build-prepare.yaml
Emma Segal-Grossman a35c311571
Redirect previous crawl paths to new paths under their workflow (#2214)
Closes #2213 

This ended up being a bit of a variety PR, but primarily this fixes
issues around archived item pages for crawls at URL locations we no
longer support — specifically, crawls, which now live at
`/orgs/{oid}/workflows/{workflow_id}/crawl/{crawl_id}`, rather than
`/orgs/{oid}/items/crawl/{crawl_id}`, including the QA pages at
sub-paths of these. Attempting to view a crawl at the old (unsupported)
URL will now redirect you to the correct URL!

Other changes include:
- Updated links in various parts of the app — nothing should link to the
old URL pattern anymore for crawls!
- Improved `APIRouter` and `ViewState` typing
- A couple extra `APIRouter` tests
- An addition to the route definition for crawls at
`/orgs/{oid}/items/crawl/{crawl_id}` that allows for redirections from
QA review page URLs, rather than 404 errors — this was the actual
reported problem!
- Caching in CI for playwright tests
- `needsLogin` conversion from the deprecated `LiteElement` to
`BtrixElement`, along with all the components that use it


---------

Co-authored-by: emma-sg <emma-sg@users.noreply.github.com>
2024-12-06 16:06:59 -08:00

113 lines
3.2 KiB
YAML

name: Frontend Prepare Build
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
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
# Setup:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- 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: Get installed Playwright version
working-directory: frontend
id: playwright-version
run: |
yarn add @yarnpkg/lockfile
echo "PLAYWRIGHT_VERSION=$(node scripts/get-resolved-playwright-version.js)" >> $GITHUB_ENV
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Install dependencies
working-directory: frontend
env:
HUSKY: 0
run: yarn install --frozen-lockfile
- name: Install Playwright Browsers
working-directory: frontend
env:
HUSKY: 0
run: yarn playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Install Playwright Deps
working-directory: frontend
env:
HUSKY: 0
run: yarn playwright install-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
# Lint:
- name: Lint
working-directory: frontend
run: yarn lint:check
# Localize:
- name: Extract strings
working-directory: frontend
run: yarn localize:extract
- name: Commit extracted strings
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply `localize:extract` changes
file_pattern: '**/*.xlf'
skip_fetch: true
skip_checkout: true
- name: Check localization build
working-directory: frontend
run: yarn localize:build
# Test:
- name: Unit tests
working-directory: frontend
run: yarn test
# Check 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