Skip to content

Commit

Permalink
Backport PR #2413: Add workflow for private tests (#2414)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Kim <46072231+martinkim0@users.noreply.github.com>
  • Loading branch information
meeseeksmachine and martinkim0 authored Jan 18, 2024
1 parent 3e5b364 commit f7deb82
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/test_linux_private.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit f7deb82

Please sign in to comment.