feat: Dual Mode #204
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: Playwright Tests | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "**/*.go" | |
- "**/*.js" | |
- "**/*.templ" | |
pull_request: | |
branches: [main] | |
paths: | |
- "**/*.go" | |
- "**/*.js" | |
- "**/*.templ" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: playwright | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# Make sure the actual branch is checked out when running on pull requests | |
ref: ${{ github.head_ref }} | |
# This is important to fetch the changes to the previous commit | |
fetch-depth: 0 | |
- name: Prettify code | |
uses: creyD/prettier_action@v4.3 | |
with: | |
# This part is also where you can pass other options, for example: | |
prettier_options: --write **/*.{js,md} | |
only_changed: True | |
- name: Set up bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Install a-h/templ | |
run: go install github.com/a-h/templ/cmd/templ@latest | |
- name: Install Taskfile CLI | |
run: go install github.com/go-task/task/v3/cmd/task@latest | |
- name: Compile templates | |
run: templ generate | |
- name: Install go modules | |
run: go mod tidy | |
- name: Install dependencies | |
run: bun install | |
- name: Transpile Frontend | |
run: bun run build | |
- name: Build the application | |
run: go build -v -race -o ./out/wga | |
- run: ls -la | |
working-directory: ./out | |
- name: Set executable permissions | |
run: chmod +x ./wga | |
working-directory: ./out | |
- name: Run migrations | |
run: ./wga migrate | |
working-directory: ./out | |
env: | |
WGA_PROTOCOL: ${{ vars.WGA_PROTOCOL }} | |
WGA_HOSTNAME: ${{ vars.WGA_HOSTNAME }} | |
WGA_ADMIN_EMAIL: ${{ secrets.WGA_ADMIN_EMAIL }} | |
WGA_ADMIN_PASSWORD: ${{ secrets.WGA_ADMIN_PASSWORD }} | |
WGA_S3_ENDPOINT: ${{ vars.WGA_S3_ENDPOINT }} | |
WGA_S3_BUCKET: ${{ vars.WGA_S3_BUCKET }} | |
WGA_S3_REGION: "" | |
WGA_S3_ACCESS_KEY: ${{ secrets.WGA_S3_ACCESS_KEY }} | |
WGA_S3_ACCESS_SECRET: ${{ secrets.WGA_S3_ACCESS_SECRET }} | |
WGA_SMTP_HOST: ${{ vars.WGA_SMTP_HOST }} | |
WGA_SMTP_PORT: ${{ vars.WGA_SMTP_PORT }} | |
WGA_SMTP_USERNAME: "" | |
WGA_SMTP_PASSWORD: "" | |
WGA_SENDER_ADDRESS: ${{ vars.WGA_SENDER_ADDRESS }} | |
WGA_SENDER_NAME: ${{ vars.WGA_SENDER_NAME }} | |
MAILPIT_URL: ${{ vars.MAILPIT_URL }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wga | |
path: out | |
retention-days: 1 | |
playwright-tests: | |
needs: build | |
timeout-minutes: 5 | |
strategy: | |
fail-fast: false | |
matrix: | |
shardIndex: [1, 2, 3, 4] | |
shardTotal: [4] | |
runs-on: ubuntu-latest | |
environment: playwright | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Fetch the build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: wga | |
path: ./wga_tmp | |
- name: Download Mailpit | |
run: wget https://github.com/axllent/mailpit/releases/download/v1.14.4/mailpit-linux-amd64.tar.gz | |
- name: Extract Mailpit | |
run: tar -xvf mailpit-linux-amd64.tar.gz | |
- name: Run Mailpit | |
run: ./mailpit -v > mailpit.log & | |
- name: Install Bun dependencies | |
run: bun install | |
- name: Get installed Playwright version | |
id: playwright-version | |
run: echo "PLAYWRIGHT_VERSION=$(grep '@playwright/test@' yarn.lock | awk -F'[@"]' '{print $4}' | awk -F'^' '{print $2}')" >> $GITHUB_ENV | |
# - name: Cache playwright binaries | |
# uses: actions/cache@v4 | |
# id: playwright-cache | |
# with: | |
# path: | | |
# ~/.cache/ms-playwright | |
# key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | |
- run: bunx playwright install --with-deps | |
name: Install Playwright | |
# if: steps.playwright-cache.outputs.cache-hit != 'true' | |
- run: bunx playwright install-deps | |
name: Install Playwright dependencies | |
# if: steps.playwright-cache.outputs.cache-hit != 'true' | |
- name: Add executable permissions | |
run: chmod +x ./wga | |
working-directory: ./wga_tmp | |
- name: Run the application | |
run: ./wga serve --dev > wga.log & | |
working-directory: ./wga_tmp | |
env: | |
WGA_PROTOCOL: ${{ vars.WGA_PROTOCOL }} | |
WGA_HOSTNAME: ${{ vars.WGA_HOSTNAME }} | |
WGA_ADMIN_EMAIL: ${{ secrets.WGA_ADMIN_EMAIL }} | |
WGA_ADMIN_PASSWORD: ${{ secrets.WGA_ADMIN_PASSWORD }} | |
WGA_S3_ENDPOINT: ${{ vars.WGA_S3_ENDPOINT }} | |
WGA_S3_BUCKET: ${{ vars.WGA_S3_BUCKET }} | |
WGA_S3_REGION: "" | |
WGA_S3_ACCESS_KEY: ${{ secrets.WGA_S3_ACCESS_KEY }} | |
WGA_S3_ACCESS_SECRET: ${{ secrets.WGA_S3_ACCESS_SECRET }} | |
WGA_SMTP_HOST: ${{ vars.WGA_SMTP_HOST }} | |
WGA_SMTP_PORT: ${{ vars.WGA_SMTP_PORT }} | |
WGA_SMTP_USERNAME: "" | |
WGA_SMTP_PASSWORD: "" | |
WGA_SENDER_ADDRESS: ${{ vars.WGA_SENDER_ADDRESS }} | |
WGA_SENDER_NAME: ${{ vars.WGA_SENDER_NAME }} | |
MAILPIT_URL: ${{ vars.MAILPIT_URL }} | |
- name: Wait for the application to start | |
run: sleep 5 | |
- name: Run Playwright tests | |
run: bunx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
env: | |
MAILPIT_URL: ${{ vars.MAILPIT_URL }} | |
WGA_PROTOCOL: ${{ vars.WGA_PROTOCOL }} | |
WGA_HOSTNAME: ${{ vars.WGA_HOSTNAME }} | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: blob-report-${{ matrix.shardIndex }} | |
path: blob-report | |
retention-days: 1 | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: mailpit-${{ matrix.shardIndex }} | |
path: mailpit.log | |
retention-days: 1 | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: wga-log-${{ matrix.shardIndex }} | |
path: wga.log | |
retention-days: 1 | |
merge-reports: | |
# Merge reports after playwright-tests, even if some shards have failed | |
if: success() || failure() | |
needs: [playwright-tests] | |
environment: playwright | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install | |
- name: Download blob reports from GitHub Actions Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: all-blob-reports | |
pattern: blob-report-* | |
merge-multiple: true | |
- name: Merge into HTML Report | |
run: bunx playwright merge-reports --reporter html ./all-blob-reports | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report--attempt-${{ github.run_attempt }} | |
path: playwright-report | |
retention-days: 14 | |
- name: Upload HTML report to Azure | |
shell: bash | |
run: | | |
REPORT_DIR='run-${{ github.run_id }}-${{ github.run_attempt }}' | |
azcopy cp --recursive "./playwright-report/*" "https://wga.blob.core.windows.net/\$web/$REPORT_DIR" | |
echo "::notice title=HTML report url::https://wga.z6.web.core.windows.net/$REPORT_DIR/index.html" | |
env: | |
AZCOPY_AUTO_LOGIN_TYPE: SPN | |
AZCOPY_SPA_APPLICATION_ID: "${{ secrets.AZCOPY_SPA_APPLICATION_ID }}" | |
AZCOPY_SPA_CLIENT_SECRET: "${{ secrets.AZCOPY_SPA_CLIENT_SECRET }}" | |
AZCOPY_TENANT_ID: "${{ secrets.AZCOPY_TENANT_ID }}" |