Skip to content

testing CI workflow #15

testing CI workflow

testing CI workflow #15

Workflow file for this run

name: 'CI'
on:
push:
branches-ignore:
- gh-pages
paths-ignore:
- '*.md'
pull_request:
branches-ignore:
- gh-pages
paths-ignore:
- '*.md'
workflow_dispatch: {}
# Avoid overlapping runs and cancel in-progress runs on newer commits
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Reduce default permissions for security
permissions:
contents: read
checks: write
actions: read
jobs:
# Build (produce production artifacts)
build:
runs-on: ubuntu-latest
needs: []
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }} (with cache)
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: react/package-lock.json
- name: Build
run: rm -rf node_modules && rm -rf package-lock.json && npm install && npm run build
working-directory: react
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: react-build
path: ./react/build/
# Lint & Audit
audit_lint:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }} (with cache)
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: react/package-lock.json
- name: Install dependencies
run: npm install
working-directory: react
- name: Audit
run: npm run audit
working-directory: react
- name: ESLint
run: npm run lint
working-directory: react
# Unit tests + coverage
unit_tests:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }} (with cache)
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: react/package-lock.json
- name: Install dependencies
run: npm install
working-directory: react
- name: Run unit tests with coverage
run: npm run test:CI
working-directory: react
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./react/reports/coverage/coverage-final.json
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: reports-coverage
path: ./react/reports/coverage/
# Duplication analysis
duplication:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }} (with cache)
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: react/package-lock.json
- name: Install dependencies
run: npm install
working-directory: react
- name: Run duplication analysis
run: npm run duplication
working-directory: react
- name: Upload duplication HTML report
uses: actions/upload-artifact@v4
with:
name: reports-duplication
path: ./react/reports/duplication/html/
# Playwright E2E
# e2e:
# runs-on: ubuntu-latest
# needs: [unit_tests]
# strategy:
# matrix:
# node-version: [22.x]
# steps:
# - uses: actions/checkout@v4
# - name: Download build artifact
# uses: actions/download-artifact@v4
# with:
# name: react-build
# path: ./react/build
# - name: Use Node.js ${{ matrix.node-version }} (with cache)
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# cache: 'npm'
# cache-dependency-path: react/package-lock.json
# - name: Run Playwright tests
# run: rm -rf node_modules && rm -rf package-lock.json && npm install && npx playwright install --with-deps && npx playwright test
# working-directory: react
# - name: Upload playwright reports
# uses: actions/upload-artifact@v4
# with:
# name: reports-playwright
# path: ./react/reports/playwright/
# Mutation testing
# stryker:
# if: "github.ref == 'refs/heads/main'"
# runs-on: ubuntu-latest
# needs: [unit_tests]
# strategy:
# matrix:
# node-version: [22.x]
# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js ${{ matrix.node-version }} (with cache)
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# cache: 'npm'
# cache-dependency-path: react/package-lock.json
# - name: Install dependencies
# run: npm install
# working-directory: react
# - name: Run Stryker tests
# run: npx stryker run
# working-directory: react
# - name: Upload mutation reports
# uses: actions/upload-artifact@v4
# with:
# name: reports-mutation
# path: ./react/reports/mutation/
# Deploy reports to GitHub Pages under /reports/
deploy_reports:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
# needs: [stryker, e2e, unit_tests, duplication]
needs: [unit_tests, duplication]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Switch to gh-pages branch
run: |
git fetch origin gh-pages
git checkout gh-pages || git checkout --orphan gh-pages
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
name: reports-coverage
path: reports/coverage
# - name: Download mutation reports
# uses: actions/download-artifact@v4
# with:
# name: reports-mutation
# path: reports/mutation
# - name: Download playwright reports
# uses: actions/download-artifact@v4
# with:
# name: reports-playwright
# path: reports/playwright
- name: Download duplication report
uses: actions/download-artifact@v4
with:
name: reports-duplication
path: reports/duplication
- name: Setup Git user
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Commit and push reports
run: ls -alF reports
# run: |
# git add reports/
# git commit -m "Update reports" || echo "No changes to commit"
# git push origin gh-pages
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}