-
Notifications
You must be signed in to change notification settings - Fork 8
Add integration testing with testcontainers and Playwright #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 17 commits
ac612b2
2d2600e
efbef4c
a02c080
e9e466c
fef992f
582f80c
12bb1f1
1d79015
814b6d2
b903635
eb2aa1c
9340a86
012b8bd
867d4e5
4dc2d3c
437a9f4
5b00113
10d96b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: Setup integration test environment | ||
| description: Prepare toolchains, Viceroy, and Docker images for integration test jobs. | ||
|
|
||
| inputs: | ||
| origin-port: | ||
| description: Fixed origin port baked into the WASM binary for integration tests. | ||
| required: true | ||
|
|
||
| outputs: | ||
| node-version: | ||
| description: Node.js version read from .tool-versions. | ||
| value: ${{ steps.node-version.outputs.node-version }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Check shared dependency versions | ||
| shell: bash | ||
| run: ./scripts/check-integration-dependency-versions.sh | ||
|
|
||
| - name: Retrieve Rust version | ||
| id: rust-version | ||
| shell: bash | ||
| run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Retrieve Node.js version | ||
| id: node-version | ||
| shell: bash | ||
| run: echo "node-version=$(grep '^nodejs ' .tool-versions | awk '{print $2}')" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Set up Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||
| target: wasm32-wasip1 | ||
| cache-shared-key: cargo-${{ runner.os }} | ||
|
|
||
| - name: Get Viceroy cache key | ||
| id: viceroy-rev | ||
| shell: bash | ||
| run: echo "sha=$(git ls-remote https://github.com/fastly/Viceroy HEAD | cut -f1)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Cache Viceroy binary | ||
| id: cache-viceroy | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cargo/bin/viceroy | ||
| key: viceroy-${{ runner.os }}-${{ steps.viceroy-rev.outputs.sha }} | ||
|
|
||
| - name: Install Viceroy | ||
| if: steps.cache-viceroy.outputs.cache-hit != 'true' | ||
| shell: bash | ||
| run: cargo install --git https://github.com/fastly/Viceroy viceroy | ||
|
|
||
| - name: Build WASM binary | ||
| shell: bash | ||
| env: | ||
| TRUSTED_SERVER__PUBLISHER__ORIGIN_URL: http://127.0.0.1:${{ inputs.origin-port }} | ||
| TRUSTED_SERVER__PROXY__CERTIFICATE_CHECK: "false" | ||
| run: cargo build --bin trusted-server-fastly --release --target wasm32-wasip1 | ||
|
|
||
| - name: Build WordPress test container | ||
| shell: bash | ||
| run: | | ||
| docker build -t test-wordpress:latest \ | ||
| crates/integration-tests/fixtures/frameworks/wordpress/ | ||
|
|
||
| - name: Build Next.js test container | ||
| shell: bash | ||
| run: | | ||
| docker build \ | ||
| --build-arg NODE_VERSION=${{ steps.node-version.outputs.node-version }} \ | ||
| -t test-nextjs:latest \ | ||
| crates/integration-tests/fixtures/frameworks/nextjs/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| name: "Integration Tests" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔧 Blocking — Workflow still triggers on Commit Remove the |
||
| pull_request: | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| ORIGIN_PORT: 8888 | ||
|
|
||
| jobs: | ||
| integration-tests: | ||
| name: integration tests | ||
| runs-on: ubuntu-latest | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔧 Blocking — No Neither jobs:
integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 15 |
||
| if: >- | ||
| github.event_name == 'push' || | ||
| github.event_name == 'pull_request' || | ||
| github.event_name == 'workflow_dispatch' || | ||
| (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up shared integration test environment | ||
| id: shared-setup | ||
| uses: ./.github/actions/setup-integration-test-env | ||
| with: | ||
| origin-port: ${{ env.ORIGIN_PORT }} | ||
|
|
||
| - name: Run integration tests | ||
| run: >- | ||
| cargo test | ||
| --manifest-path crates/integration-tests/Cargo.toml | ||
| --target x86_64-unknown-linux-gnu | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📌 Non-blocking — Hardcoded target triple
|
||
| -- --include-ignored --skip test_wordpress_fastly --skip test_nextjs_fastly --test-threads=1 | ||
| env: | ||
| INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} | ||
prk-Jr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| RUST_LOG: info | ||
|
|
||
| browser-tests: | ||
| name: browser integration tests | ||
| runs-on: ubuntu-latest | ||
| if: >- | ||
| github.event_name == 'push' || | ||
| github.event_name == 'pull_request' || | ||
| github.event_name == 'workflow_dispatch' || | ||
| (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up shared integration test environment | ||
| id: shared-setup | ||
| uses: ./.github/actions/setup-integration-test-env | ||
| with: | ||
| origin-port: ${{ env.ORIGIN_PORT }} | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ steps.shared-setup.outputs.node-version }} | ||
|
|
||
| - name: Install Playwright | ||
| working-directory: crates/integration-tests/browser | ||
| run: | | ||
| npm ci | ||
| npx playwright install --with-deps chromium | ||
|
|
||
| - name: Run browser tests (Next.js) | ||
| working-directory: crates/integration-tests/browser | ||
| env: | ||
| WASM_BINARY_PATH: ${{ github.workspace }}/target/wasm32-wasip1/release/trusted-server-fastly.wasm | ||
| INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} | ||
| VICEROY_CONFIG_PATH: ${{ github.workspace }}/crates/integration-tests/fixtures/configs/viceroy-template.toml | ||
| TEST_FRAMEWORK: nextjs | ||
| run: npx playwright test | ||
|
|
||
| - name: Run browser tests (WordPress) | ||
| working-directory: crates/integration-tests/browser | ||
| env: | ||
| WASM_BINARY_PATH: ${{ github.workspace }}/target/wasm32-wasip1/release/trusted-server-fastly.wasm | ||
| INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} | ||
| VICEROY_CONFIG_PATH: ${{ github.workspace }}/crates/integration-tests/fixtures/configs/viceroy-template.toml | ||
| TEST_FRAMEWORK: wordpress | ||
| run: npx playwright test | ||
|
|
||
| - name: Upload Playwright HTML report | ||
| uses: actions/upload-artifact@v4 | ||
| if: failure() | ||
| with: | ||
| name: playwright-report | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 Non-blocking — Playwright report overwritten between framework runs The Next.js run (line 68) writes to Consider distinct artifact names per framework, or separate report output directories via |
||
| path: crates/integration-tests/browser/playwright-report/ | ||
| retention-days: 7 | ||
|
|
||
| - name: Upload Playwright traces and screenshots | ||
| uses: actions/upload-artifact@v4 | ||
| if: failure() | ||
| with: | ||
| name: playwright-traces | ||
| path: crates/integration-tests/browser/test-results/ | ||
| retention-days: 7 | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| target/ | ||
| *.rs | ||
| Cargo.toml | ||
| Cargo.lock | ||
| tests/ | ||
| README.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Blocking — Unpinned Viceroy install
Both the cache key (line 41,
git ls-remote HEAD) and this install use whatever is latest on Viceroy's default branch. A breaking upstream change will break CI with zero code changes in this repo.Pin to a specific tag or
--rev:And update the cache key to match the pinned rev instead of
HEAD.