Skip to content

Commit

Permalink
Add generate_github_integration_tests_without_db_matrix_json session …
Browse files Browse the repository at this point in the history
…to noxfile
  • Loading branch information
tkilias committed Aug 25, 2023
1 parent 0efb8ac commit d29019d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/integration_tests_without_db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ jobs:

- id: generate_integration_tests_without_db
name: "Generate list of integration tests without DB"
run: poetry run -- nox -s generate_integration_tests_without_db_matrix > "$GITHUB_OUTPUT"
run: poetry run -- nox -s generate_github_integration_tests_without_db_matrix > "$GITHUB_OUTPUT"
outputs:
test_path: ${{ toJSON(steps.generate_integration_tests_without_db.outputs.matrix) }}
test-path: ${{ toJSON(steps.generate_integration_tests_without_db.outputs.matrix) }}

debug:
needs: prepare_matrix
strategy:
fail-fast: false
matrix:
python-version: [ 3.8 ]
test_path: ${{ fromJSON(needs.prepare_matrix.outputs.test_path) }}
test-path: ${{ fromJSON(needs.prepare_matrix.outputs.test-path) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- run: echo "${{ matrix.test_path.name }}"
- run: echo "${{ matrix.test-path.name }}"

run_test:
needs: prepare_matrix
Expand Down
18 changes: 13 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,23 @@ def _generate_test_matrix_entry(test_file: Path):
}


@nox.session(python=False)
def generate_integration_tests_without_db_matrix(session: Session):
"""
{"name": "<test_name>", "path": "<test_path>"}
"""
def _generate_github_integration_tests_without_db_matrix() -> str:
without_db_test_directory = INTEGRATION_TEST_DIRECTORY / "without_db"
test_files = without_db_test_directory.rglob("test_*.py")
output = [_generate_test_matrix_entry(test_file) for test_file in test_files]
json_str = json.dumps(output)
return json_str


@nox.session(python=False)
def generate_github_integration_tests_without_db_matrix_json(session: Session):
json_str = _generate_github_integration_tests_without_db_matrix()
print(json_str)


@nox.session(python=False)
def generate_github_integration_tests_without_db_matrix(session: Session):
json_str = _generate_github_integration_tests_without_db_matrix()
github_output_definition = f"matrix={json_str}"
print(github_output_definition)

Expand Down

0 comments on commit d29019d

Please sign in to comment.