Skip to content

Commit

Permalink
👷 Add automated test suite
Browse files Browse the repository at this point in the history
See #16
  • Loading branch information
foosel committed May 24, 2024
1 parent ef51c79 commit bc50353
Show file tree
Hide file tree
Showing 194 changed files with 1,072 additions and 325 deletions.
62 changes: 57 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,79 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
id: pages
uses: actions/configure-pages@v2
uses: actions/configure-pages@v5
- name: Inject version information
run: |
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
jq -n --arg commit "$GITHUB_SHA" --arg build "$GITHUB_RUN_NUMBER" --arg date "$DATE" '{commit: $commit, build: $build, date: $date}' > ./src/version.json
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: ./src

# Test job
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: 🏗 Prepare Playwright env
working-directory: ./tests
run: |
npm ci
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["@playwright/test"].version')
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: 🧰 Cache Playwright browser binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: "~/.cache/ms-playwright"
key: "${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}"
restore-keys: |
${{ runner.os }}-playwright-
- name: 🏗 Install Playwright browser binaries & OS dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./tests
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
npx playwright install --with-deps
- name: 🏗 Install Playwright OS dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
working-directory: ./tests
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
npx playwright install-deps
- name: 🎭 Run Playwright
working-directory: ./tests
run: |
npx playwright test
- name: ⬆ Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: tests/playwright-report


# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
needs:
- build
- test
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
3 changes: 1 addition & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: '3'

tasks:
serve:
dir: ./src
cmds:
- echo "Starting server on http://localhost:8000"
- python -m http.server 8000
- npx http-server ./src -p 8000
5 changes: 5 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
Binary file added tests/files/test-pdf.pdf
Binary file not shown.
Loading

0 comments on commit bc50353

Please sign in to comment.