-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(integration): Add initial "integration tests" #3121
Draft
theosanderson
wants to merge
7
commits into
main
Choose a base branch
from
integration-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d7cbe2f
initial commit
theosanderson 786bf7f
initial 2
theosanderson 8771ddf
Update integration-tests.yml
theosanderson 8cddffe
Update integration-tests.yml
theosanderson 9b3c79d
update
theosanderson 0b1df84
disable webkit for now
theosanderson 4350309
add principles
theosanderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: Integration tests | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- "backend/**" | ||
- "keycloak/**" | ||
- "kubernetes/**" | ||
- "website/**" | ||
- "deploy.py" | ||
- "integration-tests/**" | ||
- ".github/scripts/**" | ||
- ".github/workflows/**" | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
integration-tests: | ||
permissions: | ||
packages: read | ||
contents: read | ||
checks: read | ||
actions: read # Required by workflow-telemetry-action | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 45 | ||
env: | ||
sha: ${{ github.event.pull_request.head.sha || github.sha }} | ||
steps: | ||
- name: Shorten sha | ||
run: echo "sha=${sha::7}" >> $GITHUB_ENV | ||
- name: Collect Workflow Telemetry | ||
uses: catchpoint/workflow-telemetry-action@v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Install k3d | ||
run: | | ||
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash | ||
k3d version | ||
- uses: azure/setup-helm@v4 | ||
- name: Create k3d cluster | ||
run: | | ||
./deploy.py --verbose cluster | ||
- name: Deploy with helm | ||
run: | | ||
./deploy.py --verbose helm --branch ${{ github.ref_name }} --sha ${{ env.sha }} --for-e2e | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ./website/.nvmrc | ||
- name: Cache .npm | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('integration-tests/**/package-lock.json') }} | ||
- name: Install dependencies | ||
run: cd integration-tests && npm i | ||
- name: Get Installed Playwright Version | ||
id: playwright-version | ||
run: cd integration-tests && echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages['node_modules/@playwright/test'].version)")" >> $GITHUB_ENV | ||
- name: Cache Playwright Browsers | ||
uses: actions/cache@v4 | ||
id: playwright-cache | ||
with: | ||
path: ~/.cache/ms-playwright | ||
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | ||
- name: Install Playwright Browsers and System Dependencies | ||
run: cd integration-tests && npx playwright install --with-deps | ||
if: steps.playwright-cache.outputs.cache-hit != 'true' | ||
- name: Install only System Dependencies | ||
run: cd website && npx playwright install-deps | ||
if: steps.playwright-cache.outputs.cache-hit == 'true' | ||
- name: Wait for the pods to be ready | ||
run: ./.github/scripts/wait_for_pods_to_be_ready.py --timeout 120 | ||
- name: Sleep for 10 secs | ||
run: sleep 10 | ||
- name: Run Integration test | ||
run: | | ||
set -o pipefail | ||
cd integration-tests && npx playwright test 2>&1 | tee output.txt | ||
EXIT_CODE=$? | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
sed -n '/Running [0-9]\+ tests/,$p' output.txt >> $GITHUB_STEP_SUMMARY | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
exit $EXIT_CODE | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ failure() }} | ||
with: | ||
name: playwright-report | ||
path: integration-tests/playwright-report/ | ||
retention-days: 30 | ||
- name: Upload Test Results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-results | ||
path: integration-tests/test-results/ | ||
retention-days: 30 | ||
- name: List running pods | ||
if: ${{ !cancelled() }} | ||
run: kubectl get pods --all-namespaces | ||
- name: Describe pods | ||
if: ${{ !cancelled() }} | ||
run: kubectl describe pods -l app=loculus | ||
- name: Show events | ||
if: ${{ !cancelled() }} | ||
run: kubectl get events | ||
- name: Save logs from all containers to file | ||
if: ${{ !cancelled() }} | ||
run: ./.github/scripts/collect_kubernetes_logs.sh | ||
- name: Upload Kubernetes logs | ||
if: ${{ !cancelled() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: kubernetes-logs | ||
path: kubernetes_logs/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Integration tests | ||
|
||
These are tests of the full Loculus system, following sequences through submission to preprocessing to release. | ||
|
||
## Principles | ||
|
||
Here are some current guiding principles for these tests: | ||
- Only use facilities users could use (primarily browser interaction), rather than setting things up with backend calls. This makes it easy for others to understand the tests because they can follow them in the browser. | ||
- All tests should be able to run in parallel. Mostly this can be carried out by creating a separate user/group for each test. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "integration_tests", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"description": "", | ||
"devDependencies": { | ||
"@playwright/test": "^1.48.2", | ||
"@types/node": "^22.8.3", | ||
"@types/uuid": "^10.0.0", | ||
"uuid": "^11.0.2" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] }, | ||
}, | ||
/* | ||
{ | ||
name: 'webkit', | ||
use: { ...devices['Desktop Safari'] }, | ||
}, | ||
*/ | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
../deploy.py cluster --delete | ||
../deploy.py cluster | ||
../deploy.py helm --for-e2e | ||
python ../.github/scripts/wait_for_pods_to_be_ready.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { PlaywrightTestConfig } from '@playwright/test'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
testDir: '../specs', | ||
use: { | ||
baseURL: 'http://localhost:3000', | ||
trace: 'on-first-retry', | ||
screenshot: 'only-on-failure', | ||
}, | ||
reporter: [['html'], ['list']], | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why don't we put that in the e2e values.yaml? Or even in the real values.yaml?