Skip to content

Add test coverage reports #964

Add test coverage reports

Add test coverage reports #964

Workflow file for this run

---
name: PR Checks
permissions:
contents: read
on:
pull_request:
merge_group:
jobs:
pre-commit:
name: Pre-commit Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Compile Paraglide messages
run: npx @inlang/paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide
- name: Install hadolint
run: |
set -euo pipefail
HADOLINT_VERSION=v2.14.0
SYSTEM=$(uname -s)
ARCH=$(uname -m)
mkdir -p "$HOME/.local/bin"
curl -sL -o "$HOME/.local/bin/hadolint" "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-$SYSTEM-$ARCH"
chmod 755 "$HOME/.local/bin/hadolint"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Install Helm
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
- name: Cache pre-commit
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write # required by the coverage report action to comment on the PR
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run unit tests with coverage
run: npm run test:unit:coverage
# Reports overall + diff coverage as a job summary and a sticky PR comment.
# Informational only — coverage is not currently enforced as a merge gate.
- name: Coverage report
if: always() && github.event_name == 'pull_request'
uses: davelosert/vitest-coverage-report-action@c4bbc33a89b7ace0e63d35f1f7d4bcee31155a73 # v2.13.0
with:
file-coverage-mode: changes
e2e-with-garage:
name: E2E Tests with Garage S3
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium firefox
- name: Start Garage S3 and initialize bucket
run: |
# GitHub Actions services now support entrypoint + command, but we still
# start Garage manually here because service containers are created before
# actions/checkout runs. The upstream Garage image contains only the
# /garage binary (no /bin/sh), so the service cannot wait for the checked-
# out e2e/garage.toml to appear before it starts.
docker run -d --name garage \
-p 3900:3900 \
-p 3902:3902 \
-e GARAGE_CONFIG_FILE=/workspace/dev/garage/garage.toml \
-v "$PWD:/workspace" \
--entrypoint /garage \
oci.stackable.tech/stackable/dxflrs/garage:v2.3.0 \
server --single-node
# Wait for the S3 API to become available
for _ in $(seq 1 30); do
if curl -s http://localhost:3900 >/dev/null 2>&1; then
break
fi
sleep 1
done
S3_SECRET_ACCESS_KEY="e2e-test-secret-key-for-ci" \
GARAGE_ADMIN_TOKEN='stackable-cockpit-e2e-admin-token' \
S3_ENDPOINT='http://localhost:3900' \
S3_CONFIG_PATH="$PWD/s3-config.json" \
./e2e/init-garage-s3.sh
- name: Run E2E tests with Garage
run: npm run test:e2e:garage