notebooks/.github/workflows/ws-frontend-test.yml

83 lines
2.5 KiB
YAML

name: Frontend - Build and Test
permissions:
contents: read
on:
push:
branches:
- main
- notebooks-v2
- v*-branch
pull_request:
paths:
- workspaces/frontend/**
branches:
- main
- notebooks-v2
- v*-branch
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
working-directory: workspaces/frontend
run: npm install
- name: Clean
working-directory: workspaces/frontend
run: npm run build:clean
- name: Build
working-directory: workspaces/frontend
run: npm run build
- name: Run tests
working-directory: workspaces/frontend
# use id to skip archiving artifacts if running the tests was skipped, usually due to failure in steps above
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#steps-context
id: run-tests
run: npm run test
- name: Upload Cypress test report
uses: actions/upload-artifact@v4
if: "!cancelled() && steps.run-tests.outcome != 'skipped'"
with:
name: cypress-report
path: |
workspaces/frontend/src/__tests__/cypress/results/mocked/index.html
workspaces/frontend/src/__tests__/cypress/results/mocked/junit-report.xml
- name: Upload Cypress screenshots (on failure)
uses: actions/upload-artifact@v4
if: "failure() && steps.run-tests.outcome == 'failure'"
with:
name: cypress-screenshots
path: workspaces/frontend/src/__tests__/cypress/results/mocked/screenshots
- name: Upload Cypress video recordings (on failure)
uses: actions/upload-artifact@v4
if: "failure() && steps.run-tests.outcome == 'failure'"
with:
name: cypress-videos
path: workspaces/frontend/src/__tests__/cypress/results/mocked/videos
- name: Check if there are uncommitted file changes
working-directory: workspaces/frontend
run: |
clean=$(git status --porcelain)
if [[ -z "$clean" ]]; then
echo "Empty git status --porcelain: $clean"
else
echo "Uncommitted file changes detected: $clean"
git diff
exit 1
fi