This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Merged
Add smoke tests #276
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
Empty file.
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 |
---|---|---|
|
@@ -9,16 +9,18 @@ on: | |
|
||
# GitHub Actions workflow to deploy to Azure using azd | ||
# To configure required secrets for connecting to Azure, simply run `azd pipeline config` | ||
|
||
# Set up permissions for deploying with secretless Azure federated credentials | ||
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
uri: ${{ steps.output.outputs.uri }} | ||
env: | ||
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | ||
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} | ||
|
@@ -27,10 +29,10 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install azd | ||
uses: Azure/[email protected] | ||
|
||
- name: Log in with Azure (Federated Credentials) | ||
if: ${{ env.AZURE_CLIENT_ID != '' }} | ||
run: | | ||
|
@@ -39,31 +41,67 @@ jobs: | |
--federated-credential-provider "github" ` | ||
--tenant-id "$Env:AZURE_TENANT_ID" | ||
shell: pwsh | ||
|
||
- name: Log in with Azure (Client Credentials) | ||
if: ${{ env.AZURE_CREDENTIALS != '' }} | ||
run: | | ||
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable; | ||
Write-Host "::add-mask::$($info.clientSecret)" | ||
|
||
azd auth login ` | ||
--client-id "$($info.clientId)" ` | ||
--client-secret "$($info.clientSecret)" ` | ||
--tenant-id "$($info.tenantId)" | ||
shell: pwsh | ||
env: | ||
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Provision Infrastructure | ||
run: azd provision --no-prompt | ||
env: | ||
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }} | ||
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} | ||
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: Deploy Application | ||
run: azd deploy --no-prompt | ||
env: | ||
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }} | ||
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} | ||
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: Output Deployment URI | ||
id: output | ||
run: | | ||
azd env get-values > .env | ||
source .env | ||
echo "uri=$BACKEND_URI" >> "$GITHUB_OUTPUT" | ||
|
||
smoketests: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
|
||
- name: Basic smoke test (curl) | ||
env: | ||
URI: ${{needs.build.outputs.uri}} | ||
run: | | ||
echo "Sleeping 1 minute due to https://github.com/Azure/azure-dev/issues/2669" | ||
sleep 60 | ||
curl -sSf $URI | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: End-to-end smoke tests (playwright) | ||
env: | ||
URI: ${{needs.build.outputs.uri}} | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements-dev.in | ||
python3 -m playwright install --with-deps | ||
python3 -m pytest --exitfirst src/tests/smoke/smoketests.py --live-server-url $URI |
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
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
Empty file.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
{{cookiecutter.__src_folder_name}}/src/tests/smoke/README.md
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,11 @@ | ||
# Smoke tests | ||
|
||
This directory contains smoke tests for the project. | ||
These tests are meant to be run against a running instance of the project, | ||
not against a local development server. | ||
|
||
See azure-dev.yaml for an example of how to run these tests in GitHub actions. | ||
|
||
``` | ||
python3 -m pytest --exitfirst src/tests/smoke/smoketests.py --live-server-url $URI | ||
``` |
Empty file.
15 changes: 15 additions & 0 deletions
15
{{cookiecutter.__src_folder_name}}/src/tests/smoke/conftest.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,15 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--live-server-url", | ||
action="store", | ||
default="http://localhost:8000", | ||
help="URL for the live server to test against", | ||
) | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def live_server_url(request): | ||
return request.config.getoption("--live-server-url") |
10 changes: 10 additions & 0 deletions
10
{{cookiecutter.__src_folder_name}}/src/tests/smoke/smoketests.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,10 @@ | ||
# ruff: noqa: F401 | ||
|
||
# Import only the tests that we want to run for smoke testing | ||
from ..local.test_playwright import ( | ||
test_about, | ||
test_destination_options_have_cruises, | ||
test_destinations, | ||
test_home, | ||
test_request_information, | ||
) |
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.
I do wonder if we want to do this a fancier way. We could even write a Python script using tenacity to check for 200 status with backoff and 10 attempts, that sort of thing. Or we could do that in bash (barf).
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.
I think we can make it cooler later... this works for now (unless it doesn't)
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.
It does seem to work so far! We'll see what happens when we cruft update on all 17 repos.