-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
102 additions
and
5 deletions.
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,82 @@ | ||
name: Smoke test (PR) | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- master | ||
|
||
env: | ||
python-version: "3.12" | ||
|
||
concurrency: | ||
group: "smoke-test" # Make sure, to not run multiple smoke tests at the same time | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
smoke_test_pr: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Get User Permission | ||
id: checkAccess | ||
uses: actions-cool/check-user-permission@v2 | ||
with: | ||
require: read | ||
username: ${{ github.triggering_actor }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Check User Permission | ||
if: steps.checkAccess.outputs.require-result == 'false' | ||
run: | | ||
echo "${{ github.triggering_actor }} does not have permissions on this repo." | ||
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
echo "Job originally triggered by ${{ github.actor }}" | ||
exit 1 | ||
- name: Checkout current code | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ env.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.python-version }} | ||
- name: Check secret access | ||
run: | | ||
if [[ "x${{ secrets.PASSWORD }}" != "x" ]]; then | ||
echo "Access to secrets" | ||
else | ||
echo "No access to secrets" | ||
exit 1 | ||
fi | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -r requirements_test.txt | ||
playwright install chromium | ||
- name: Prepare cookies with pytest | ||
run: pytest smoke_test/setup_cookies.py -v -x | ||
env: | ||
EMAIL: ${{ vars.EMAIL }} | ||
PASSWORD: ${{ secrets.PASSWORD }} | ||
# !!!!!!!!!!!!!!!!!!!! | ||
# From here on, we run new code which does not have access to the password, only the cookies | ||
# !!!!!!!!!!!!!!!!!!!! | ||
- name: Checkout new code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: "${{ github.event.pull_request.merge_commit_sha }}" | ||
clean: false | ||
- name: Test with pytest | ||
run: pytest smoke_test -v -x | ||
env: | ||
EMAIL: ${{ vars.EMAIL }} | ||
PASSWORD: <redacted> | ||
- name: Upload out dir with screenshots and traces | ||
uses: actions/upload-artifact@v4 | ||
if: success() || failure() | ||
with: | ||
name: out_dir_with_screenshots_and_traces | ||
path: out | ||
retention-days: 14 | ||
|
||
|
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,17 @@ | ||
"""Setup cookies for smoke test for cookidoo-api.""" | ||
|
||
from dotenv import load_dotenv | ||
|
||
from cookidoo_api.cookidoo import Cookidoo | ||
from smoke_test.conftest import save_cookies | ||
|
||
load_dotenv() | ||
|
||
|
||
class TestLoginAndValidation: | ||
"""Test login and validation.""" | ||
|
||
async def test_cookidoo_login(self, cookidoo: Cookidoo) -> None: | ||
"""Test cookidoo validation of the token or login otherwise.""" | ||
await cookidoo.login() | ||
save_cookies(cookidoo.cookies) |