mirror of
https://github.com/suitenumerique/docs
synced 2026-04-21 13:37:20 +00:00
We got cases where the last-run is empty, but the last-failed flag is set to true. If that happens, the workflow will fail because the last-run is empty. We now check if the last-run is filled before setting the last-failed flag.
374 lines
11 KiB
YAML
374 lines
11 KiB
YAML
name: Frontend Workflow
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- "*"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
|
|
install-dependencies:
|
|
uses: ./.github/workflows/dependencies.yml
|
|
with:
|
|
node_version: '22.x'
|
|
with-front-dependencies-installation: true
|
|
|
|
test-front:
|
|
needs: install-dependencies
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Test App
|
|
run: cd src/frontend/ && yarn test
|
|
|
|
lint-front:
|
|
runs-on: ubuntu-latest
|
|
needs: install-dependencies
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Check linting
|
|
run: cd src/frontend/ && yarn lint
|
|
|
|
prepare-e2e:
|
|
runs-on: ubuntu-latest
|
|
needs: install-dependencies
|
|
timeout-minutes: 10
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Restore Playwright browsers cache
|
|
id: playwright-cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
|
|
restore-keys: |
|
|
playwright-${{ runner.os }}-
|
|
|
|
- name: Install Playwright browsers
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd src/frontend/apps/e2e
|
|
yarn install-playwright chromium firefox webkit
|
|
|
|
- name: Save Playwright browsers cache
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
|
|
|
|
test-e2e-chromium:
|
|
runs-on: ubuntu-latest
|
|
needs: prepare-e2e
|
|
timeout-minutes: 20
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Set e2e env variables
|
|
run: cat env.d/development/common.e2e >> env.d/development/common.local
|
|
|
|
- name: Restore Playwright browsers cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Free disk space before Docker
|
|
uses: ./.github/actions/free-disk-space
|
|
|
|
- name: Start Docker services
|
|
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
|
|
|
|
- name: Restore last-run cache
|
|
if: ${{ github.run_attempt > 1 }}
|
|
id: restore-last-run
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
key: playwright-last-run-${{ github.run_id }}-chromium
|
|
|
|
- name: Run e2e tests
|
|
env:
|
|
PLAYWRIGHT_LIST_PRINT_STEPS: true
|
|
FORCE_COLOR: true
|
|
run: |
|
|
cd src/frontend/
|
|
|
|
LAST_FAILED_FLAG=""
|
|
if [ "${{ github.run_attempt }}" != "1" ]; then
|
|
LAST_RUN_FILE="apps/e2e/test-results/.last-run.json"
|
|
if [ -f "$LAST_RUN_FILE" ]; then
|
|
FAILED_COUNT=$(jq '.failedTests | length' "$LAST_RUN_FILE" 2>/dev/null || echo "0")
|
|
if [ "${FAILED_COUNT:-0}" -gt "0" ]; then
|
|
LAST_FAILED_FLAG="--last-failed"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
yarn e2e:test --project='chromium' $LAST_FAILED_FLAG
|
|
|
|
- name: Save last-run cache
|
|
if: always()
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
key: playwright-last-run-${{ github.run_id }}-chromium
|
|
|
|
- name: Upload last-run artifact
|
|
if: always()
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: playwright-instance-last-run-chromium
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
include-hidden-files: true
|
|
if-no-files-found: warn
|
|
retention-days: 7
|
|
|
|
- uses: actions/upload-artifact@v6
|
|
if: always()
|
|
with:
|
|
name: playwright-chromium-report
|
|
path: src/frontend/apps/e2e/report/
|
|
retention-days: 7
|
|
|
|
test-e2e-other-browser:
|
|
runs-on: ubuntu-latest
|
|
needs: test-e2e-chromium
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Set e2e env variables
|
|
run: cat env.d/development/common.e2e >> env.d/development/common.local
|
|
|
|
- name: Restore Playwright browsers cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Free disk space before Docker
|
|
uses: ./.github/actions/free-disk-space
|
|
|
|
- name: Start Docker services
|
|
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
|
|
|
|
- name: Restore last-run cache
|
|
if: ${{ github.run_attempt > 1 }}
|
|
id: restore-last-run
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
key: playwright-last-run-${{ github.run_id }}-other-browser
|
|
|
|
- name: Run e2e tests
|
|
env:
|
|
PLAYWRIGHT_LIST_PRINT_STEPS: true
|
|
FORCE_COLOR: true
|
|
run: |
|
|
cd src/frontend/
|
|
|
|
LAST_FAILED_FLAG=""
|
|
if [ "${{ github.run_attempt }}" != "1" ]; then
|
|
LAST_RUN_FILE="apps/e2e/test-results/.last-run.json"
|
|
if [ -f "$LAST_RUN_FILE" ]; then
|
|
FAILED_COUNT=$(jq '.failedTests | length' "$LAST_RUN_FILE" 2>/dev/null || echo "0")
|
|
if [ "${FAILED_COUNT:-0}" -gt "0" ]; then
|
|
LAST_FAILED_FLAG="--last-failed"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
yarn e2e:test --project=firefox --project=webkit $LAST_FAILED_FLAG
|
|
|
|
- name: Save last-run cache
|
|
if: always()
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
key: playwright-last-run-${{ github.run_id }}-other-browser
|
|
|
|
- name: Upload last-run artifact
|
|
if: always()
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: playwright-instance-last-run-other-browser
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
include-hidden-files: true
|
|
if-no-files-found: warn
|
|
retention-days: 7
|
|
|
|
- uses: actions/upload-artifact@v6
|
|
if: always()
|
|
with:
|
|
name: playwright-other-report
|
|
path: src/frontend/apps/e2e/report/
|
|
retention-days: 7
|
|
|
|
bundle-size-check:
|
|
runs-on: ubuntu-latest
|
|
needs: install-dependencies
|
|
if: github.event_name == 'pull_request'
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
issues: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Detect relevant changes
|
|
id: changes
|
|
uses: dorny/paths-filter@v3
|
|
with:
|
|
filters: |
|
|
lock:
|
|
- 'src/frontend/**/yarn.lock'
|
|
app:
|
|
- 'src/frontend/apps/impress/**'
|
|
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Setup Node.js
|
|
if: steps.changes.outputs.lock == 'true' || steps.changes.outputs.app == 'true'
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
|
|
- name: Check bundle size changes
|
|
if: steps.changes.outputs.lock == 'true' || steps.changes.outputs.app == 'true'
|
|
uses: preactjs/compressed-size-action@v2
|
|
with:
|
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
build-script: "app:build"
|
|
pattern: "apps/impress/out/**/*.{css,js,html}"
|
|
exclude: "{**/*.map,**/node_modules/**}"
|
|
minimum-change-threshold: 500
|
|
compression: "gzip"
|
|
cwd: "./src/frontend"
|
|
show-total: true
|
|
strip-hash: "[-_.][a-f0-9]{8,}(?=\\.(?:js|css|html)$)"
|
|
omit-unchanged: true
|
|
install-script: "yarn install --frozen-lockfile"
|
|
|
|
uikit-theme-checker:
|
|
runs-on: ubuntu-latest
|
|
needs: install-dependencies
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Build theme
|
|
run: cd src/frontend/apps/impress && yarn build-theme
|
|
|
|
- name: Ensure theme is up to date
|
|
shell: bash
|
|
run: |
|
|
if [[ -n "$(git status --porcelain)" ]]; then
|
|
echo "Error: build-theme produced git changes (tracked or untracked)."
|
|
echo "--- git status --porcelain ---"
|
|
git status --porcelain
|
|
echo "--- git diff ---"
|
|
git --no-pager diff
|
|
exit 1
|
|
fi
|