Skip to content

Commit 5182c61

Browse files
committed
ci: speed up frontend Docker build caching and parallelize CI checks
- frontend/Dockerfile: install deps from manifests before copying source and add a BuildKit yarn cache mount so the dependency layer stays cached across source changes (mirrors server/Dockerfile) - continuous-integration.yml: split lint/format/type-check into a parallel static-checks job so failures surface without waiting on Cypress setup - restrict SBOM generation to release builds; PR/dev image builds skip it via a new opt-in 'sbom' input on the showcase-build-* actions Signed-off-by: Emiliano Suñé <2395873+esune@users.noreply.github.com>
1 parent 30ac210 commit 5182c61

5 files changed

Lines changed: 47 additions & 10 deletions

File tree

.github/actions/showcase-build-frontend/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ inputs:
1717
github_token:
1818
description: Token with packages write (typically secrets.GITHUB_TOKEN)
1919
required: true
20+
sbom:
21+
description: Generate an SBOM (enable for released images; skip for ephemeral PR/dev builds to save time)
22+
required: false
23+
default: 'false'
2024

2125
runs:
2226
using: composite
@@ -51,7 +55,7 @@ runs:
5155
labels: ${{ steps.meta.outputs.labels }}
5256
annotations: ${{ steps.meta.outputs.annotations }}
5357
provenance: mode=min
54-
sbom: true
58+
sbom: ${{ inputs.sbom }}
5559
cache-from: type=gha
5660
cache-to: type=gha,mode=max
5761
build-args: |

.github/actions/showcase-build-server/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
github_token:
1111
description: Token with packages write (typically secrets.GITHUB_TOKEN)
1212
required: true
13+
sbom:
14+
description: Generate an SBOM (enable for released images; skip for ephemeral PR/dev builds to save time)
15+
required: false
16+
default: 'false'
1317

1418
runs:
1519
using: composite
@@ -45,6 +49,6 @@ runs:
4549
labels: ${{ steps.meta.outputs.labels }}
4650
annotations: ${{ steps.meta.outputs.annotations }}
4751
provenance: mode=min
48-
sbom: true
52+
sbom: ${{ inputs.sbom }}
4953
cache-from: type=gha
5054
cache-to: type=gha,mode=max

.github/workflows/build_packages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
labels: ${{ steps.meta.outputs.labels }}
124124
annotations: ${{ steps.meta.outputs.annotations }}
125125
provenance: mode=min
126-
sbom: true
126+
sbom: ${{ github.event_name == 'release' }}
127127
cache-from: type=gha
128128
cache-to: type=gha,mode=max
129129

@@ -176,7 +176,7 @@ jobs:
176176
labels: ${{ steps.meta.outputs.labels }}
177177
annotations: ${{ steps.meta.outputs.annotations }}
178178
provenance: mode=min
179-
sbom: true
179+
sbom: ${{ github.event_name == 'release' }}
180180
cache-from: type=gha
181181
cache-to: type=gha,mode=max
182182
build-args: |

.github/workflows/continuous-integration.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ jobs:
5353
- name: Run frontend unit tests
5454
run: yarn workspace frontend test:unit
5555

56-
cypress-run:
57-
name: Cypress E2E Tests
56+
static-checks:
57+
name: Lint, Format & Types
5858
runs-on: ubuntu-latest
59-
timeout-minutes: 45
59+
timeout-minutes: 15
6060
steps:
6161
- name: Checkout
6262
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -78,6 +78,22 @@ jobs:
7878
- name: Compile
7979
run: yarn check-types
8080

81+
cypress-run:
82+
name: Cypress E2E Tests
83+
runs-on: ubuntu-latest
84+
timeout-minutes: 45
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
88+
89+
- name: Setup NodeJS
90+
uses: ./.github/actions/setup-node
91+
with:
92+
node-version: 22
93+
94+
- name: Install dependencies
95+
run: yarn install --frozen-lockfile
96+
8197
# Cypress: only the Vite dev server is started. cypress.config.ts sets apiUrl to :5000 for
8298
# specs that hit the API—if CI runs those, also start the server (e.g. concurrently) or align with build_packages.yml (yarn dev).
8399
- name: Cypress run

frontend/Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1+
# syntax=docker/dockerfile:1
12
ARG build_image=node:22-alpine
23
ARG runtime_image=caddy:alpine
34

45
# build stage
56
FROM ${build_image} AS build-stage
67
WORKDIR /app
7-
ENV HUSKY=0
8-
COPY . .
8+
ENV HUSKY=0 \
9+
YARN_NETWORK_CONCURRENCY=8
10+
11+
# Install deps first so this layer stays cached unless a manifest/lockfile changes.
12+
# The whole workspace is resolved against the root lockfile, so every member
13+
# package.json must be present for `--frozen-lockfile` to succeed.
14+
COPY package.json yarn.lock ./
15+
COPY frontend/package.json ./frontend/
16+
COPY server/package.json ./server/
17+
RUN --mount=type=cache,target=/root/.cache/yarn \
18+
yarn install --frozen-lockfile --network-timeout 600000 --non-interactive
19+
920
# CI passes legacy secret names (REACT_APP_*). Map them to Vite env for `vite build`.
1021
ARG REACT_APP_INSIGHTS_PROJECT_ID
1122
ARG REACT_APP_HOST_BACKEND
1223
ENV VITE_INSIGHTS_PROJECT_ID=$REACT_APP_INSIGHTS_PROJECT_ID
1324
ENV VITE_HOST_BACKEND=$REACT_APP_HOST_BACKEND
14-
RUN yarn install --frozen-lockfile --network-timeout 600000 --non-interactive
25+
26+
# Copy source last so edits don't invalidate the dependency layer above.
27+
COPY frontend ./frontend
1528
RUN yarn workspace frontend build
1629

1730
# production stage

0 commit comments

Comments
 (0)