Skip to content
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

Add Makefile #91

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# from https://stackoverflow.com/a/10858332/1091766
# function to check a named environment variable
# see usage below for examples
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))

# include sort imports via `--select I`
lint-fix:
uv run ruff check --select I --fix tests/

# include sort imports via `--select I`
lint-check:
uv run ruff check --select I tests/

format:
uv run ruff format tests/

check_env_vars:
$(call check_defined, PATH_ROOTS, env var for which paths to scrub in vcr cassettes)
$(call check_defined, PROOF_API_TOKEN_DEV, env var for test PROOF user)

test_api_cached: check_env_vars
op run -- uv run pytest --color=yes --record-mode=once --verbose -s tests/cromwellapi/

test_api_rewrite: check_env_vars
op run -- uv run pytest --color=yes --record-mode=rewrite --verbose -s tests/cromwellapi/
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,22 @@ Adding tests shouldn't require any changes to the files in `tests/cromwelljava`

### API

These tests are run on GitHub Actions on each push to main/dev and each pull request via the `.github/workflows/api-tests.yml` workflow.
These tests are run on GitHub Actions on each push to main/dev and each pull request via the `.github/workflows/api-tests.yml` workflow. This GH Action is run on our custom runner that runs on FH infrastructure so it has appropriate privileges.

To run them locally:
To run tests locally:

- get on the Cisco VPN if working remotely or be on an FH campus network
- set a PROOF token for the test user used for these tests as `PROOF_API_TOKEN_DEV`. the value is in 1password ([Secrets and env vars in 1password](https://developer.1password.com/docs/cli/secrets-environment-variables/)). Talk to Sean or Scott if you don't have access.
1. Open 1password and find the API key.
2. Right-click the key and select "Copy Secret Reference."
3. Run: `export PROOF_API_TOKEN_DEV="op://secret/reference/copied/from/1PW"`
- run tests, for example: `op run -- uv run pytest tests/cromwellapi --verbose`
3. Add the following line to your dot file (e.g., `.zshrc`): `export PROOF_API_TOKEN_DEV="op://secret/reference/copied/from/1PW"`
- set an env var for paths to scrub in test fixtures as `PATH_ROOTS`. the value is in 1password ([Secrets and env vars in 1password](https://developer.1password.com/docs/cli/secrets-environment-variables/)).
1. Open 1password and find the entry.
2. Right-click the key and select "Copy Secret Reference."
3. Add the following line to your dot file (e.g., `.zshrc`): `export PATH_ROOTS="op://secret/reference/copied/from/1PW"`
- reload your dot file in your terminal session so the new env vars are available
- run tests using cached test fixtures: `make test_api_cached`
- run tests while re-writing test fixtures: `make test_api_rewrite`

To add tests:

Expand Down
21 changes: 12 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
[project]
name = "wdlunittests"
version = "0.1.0"
description = "Add your description here"
description = "WDL Unit Tests"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"dateparser>=1.2.0",
"colorama>=0.4.6",
"httpx>=0.28.1",
"pytest>=8.3.4",
"pytest-recording>=0.13.2",
"sh>=2.1.0",
"tenacity>=9.0.0",
"vcrpy>=7.0.0",
"dateparser>=1.2.0",
"colorama>=0.4.6",
"httpx>=0.28.1",
"pytest>=8.3.4",
"pytest-recording>=0.13.2",
"sh>=2.1.0",
"tenacity>=9.0.0",
"vcrpy>=7.0.0",
]

[dependency-groups]
dev = ["ruff>=0.9.4"]
Loading