From 0e532680ce9e4d23fdee80c478a27d341e62eee6 Mon Sep 17 00:00:00 2001 From: Martin Kim <46072231+martinkim0@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:20:39 -0800 Subject: [PATCH] Backport PR #2413: Add workflow for private tests --- .github/workflows/test_linux_private.yml | 75 ++++++++++++++++++++++++ tests/conftest.py | 14 +++++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/test_linux_private.yml diff --git a/.github/workflows/test_linux_private.yml b/.github/workflows/test_linux_private.yml new file mode 100644 index 0000000000..5b65297e63 --- /dev/null +++ b/.github/workflows/test_linux_private.yml @@ -0,0 +1,75 @@ +name: Test (Linux, private) + +on: + push: + branches: + [main, 0.15.x, 0.16.x, 0.17.x, 0.18.x, 0.19.x, 0.20.x, 1.0.x, 1.1.x] + pull_request: + branches: + [main, 0.15.x, 0.16.x, 0.17.x, 0.18.x, 0.19.x, 0.20.x, 1.0.x, 1.1.x] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -e {0} # -e to fail on error + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.11"] + + environment: + name: private_test + + permissions: + id-token: write + + name: ${{ matrix.name }} Python ${{ matrix.python }} private + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python }} + + steps: + - uses: actions/checkout@v4 + - uses: aws-actions/configure-aws-credentials@v4 + with: + audience: sts.amazonaws.com + role-to-assume: arn:aws:iam::${{ secrets.AWS_IAM }}:role/scvi-tools_private_test + aws-region: us-west-2 + role-duration-seconds: 3600 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + cache: "pip" + cache-dependency-path: "**/pyproject.toml" + + - name: Install test dependencies + run: | + python -m pip install --upgrade pip wheel + + - name: Install dependencies + run: | + pip install ".[tests]" + + - name: Test + env: + MPLBACKEND: agg + PLATFORM: ${{ matrix.os }} + DISPLAY: :42 + run: | + coverage run -m pytest -v --color=yes --private + - name: Report coverage + run: | + coverage report + - name: Upload coverage + uses: codecov/codecov-action@v3 diff --git a/tests/conftest.py b/tests/conftest.py index 7a83b17212..957fcefa5c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -39,6 +39,12 @@ def pytest_addoption(parser): default=0, help="Option to specify which scvi-tools seed to use for tests.", ) + parser.addoption( + "--private", + action="store_true", + default=False, + help="Run tests that are private.", + ) def pytest_configure(config): @@ -64,6 +70,14 @@ def pytest_collection_modifyitems(config, items): if not run_optional and ("optional" in item.keywords): item.add_marker(skip_optional) + run_private = config.getoption("--private") + skip_private = pytest.mark.skip(reason="need --private option to run") + for item in items: + # All tests marked with `pytest.mark.private` get skipped unless + # `--private` passed + if not run_private and ("private" in item.keywords): + item.add_marker(skip_private) + @pytest.fixture(scope="session") def save_path(tmp_path_factory):