ci: wip #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit Tests (Vitest) | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
permissions: | |
actions: write | |
checks: write | |
contents: write | |
deployments: write | |
discussions: write | |
issues: write | |
packages: write | |
pages: write | |
pull-requests: write | |
repository-projects: write | |
security-events: read | |
statuses: write | |
jobs: | |
test: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.docker-cache | |
key: ${{ runner.os }}-docker-${{ hashFiles('docker/Dockerfile') }} | |
restore-keys: | | |
${{ runner.os }}-docker- | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
id: build-docker-image | |
run: | | |
docker build --cache-from=type=local,src=/tmp/.docker-cache \ | |
--cache-to=type=local,dest=/tmp/.docker-cache-new \ | |
-t sveltex/test-environment:latest \ | |
-f ./docker/Dockerfile . | |
- name: Save Docker cache | |
if: steps.build-docker-image.outputs.cache-hit != 'true' | |
run: | | |
rm -rf /tmp/.docker-cache | |
mv /tmp/.docker-cache-new /tmp/.docker-cache | |
- name: Install Node.js dependencies | |
run: pnpm install | |
- name: Run Unit Tests in Docker container | |
run: | | |
docker run --rm -v ${{ github.workspace }}:/app -w /app sveltex/test-environment:latest pnpm test | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: vitest-report | |
path: vitest-report/ | |
retention-days: 30 |