-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add CodSpeed to follow lib performance
- Loading branch information
Showing
17 changed files
with
302 additions
and
91 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 |
---|---|---|
|
@@ -15,6 +15,8 @@ on: | |
- feat/* | ||
- hotfix/* | ||
- main | ||
# Allows CodSpeed to trigger backtest performance analysis in order to generate initial data | ||
workflow_dispatch: | ||
|
||
jobs: | ||
init: | ||
|
@@ -52,7 +54,8 @@ jobs: | |
# Run all test suites | ||
step: | ||
- static | ||
- unit | ||
- unit-simple | ||
- unit-codspeed | ||
# Run on all supported Python versions | ||
python-version: | ||
- "3.11" | ||
|
@@ -103,9 +106,25 @@ jobs: | |
- name: Configure environment variables | ||
run: echo "${{ secrets.DOTENV_UNIT_TESTS }}" > .env | ||
|
||
- name: Run tests | ||
- name: Run test servers (unit) | ||
if: ${{ contains(matrix.step, 'unit') }} | ||
run: make run-test-servers | ||
|
||
- name: Run tests (simple) | ||
if: ${{ !contains(matrix.step, 'codspeed') }} | ||
run: make test-${{ matrix.step }} version_full=${{ needs.init.outputs.VERSION_FULL }} | ||
|
||
- name: Run tests (CodSpeed) | ||
if: ${{ contains(matrix.step, 'codspeed') }} | ||
uses: CodSpeedHQ/[email protected] | ||
with: | ||
token: ${{ secrets.CODSPEED_TOKEN }} | ||
run: make test-${{ matrix.step }} version_full=${{ needs.init.outputs.VERSION_FULL }} | ||
|
||
- name: Kill test servers (unit) | ||
if: ${{ contains(matrix.step, 'unit') }} | ||
run: make kill-test-servers | ||
|
||
- name: Upload artifacts | ||
uses: actions/[email protected] | ||
if: always() | ||
|
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 |
---|---|---|
|
@@ -291,3 +291,9 @@ test-reports/ | |
# Local .env | ||
!.env.example | ||
.env.* | ||
|
||
# CodSpeed | ||
.codspeed/ | ||
|
||
# Test servers PIDs | ||
*.pid |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import asyncio | ||
from contextlib import suppress | ||
from os import environ as env | ||
|
||
from playwright.async_api import async_playwright | ||
|
||
from scrape_it_now.helpers.logging import logger | ||
from scrape_it_now.helpers.resources import browsers_install_path | ||
from scrape_it_now.scrape import install | ||
|
||
CDP_PORT = 9222 | ||
|
||
|
||
async def run(): | ||
# Add installation path to the environment | ||
# See: https://playwright.dev/docs/browsers#hermetic-install | ||
env["PLAYWRIGHT_BROWSERS_PATH"] = await browsers_install_path() | ||
|
||
# Note: This won't install required system packages, make sure to install them manually | ||
await install(True) | ||
|
||
async with async_playwright() as p: | ||
# Launch Chromium in server mode with CDP enabled | ||
await p.chromium.launch( | ||
args=[ | ||
"--disable-gl-drawing-for-tests", | ||
f"--remote-debugging-port={CDP_PORT}", | ||
], | ||
channel="chromium", | ||
devtools=True, | ||
) | ||
logger.info(f"Chromium running with CDP enabled on localhost:{CDP_PORT}") | ||
|
||
# Wait indefinitely (or until the browser is closed) | ||
await asyncio.Future() | ||
|
||
|
||
if __name__ == "__main__": | ||
with suppress(KeyboardInterrupt): | ||
asyncio.run(run()) |
This file was deleted.
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
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
Oops, something went wrong.