Skip to content

Updated config

Updated config #118

# Workflow to verify that the exampleSite runs ok
name: Test example site
on:
# Runs on pull requests targeting the default branch
pull_request:
branches: ["main"]
# Runs on push to the development branch
push:
branches: ["134-bug-playwright-runs-in-github-actions-dont-save-screenshots"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
CI: true
jobs:
# Build job
build-and-test:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.136.2
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: |
node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Cache Playwright Binaries
id: cache-playwright
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright
key: playwright-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Build and serve demo site
run: |
cd exampleSite
hugo server --themesDir ../.. --buildDrafts --buildFuture --bind 0.0.0.0 &
sleep 10
- name: Debug env variable
run: echo $CI
- name: Run Playwright tests
run: npm run test:e2e
- name: Debug directory structure
run: |
pwd
echo "Current directory contents:"
ls -la
echo "Test results directory:"
ls -la test-results || echo "test-results not found"
- name: Get the failure count
id: tests
run: |
export count=$(cat ./playwright-report/result.txt | grep Failed | cut -d ':' -f 2 | tr -d ' ')
echo "fail_count=$count" >> "$GITHUB_OUTPUT"
echo $count
- uses: mshick/add-pr-comment@v2
if: always()
with:
message-path: |
./playwright-report/result.txt
message-failure: |
Workflow failed
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Fail the job if there any failed case
if: steps.tests.outputs.fail_count != '0'
run : |
exit 1
outputs:
fail_count: ${{ steps.tests.outputs.fail_count }}