|
| 1 | +# A GitHub Actions workflow file to run on pull request and on main. |
| 2 | +name: Pull Request Checks |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + # ---------------------------------------------------------------------------------------------- |
| 11 | + # Code Quality Checks and Linting |
| 12 | + # ---------------------------------------------------------------------------------------------- |
| 13 | + check_code_quality: |
| 14 | + name: Code Quality Checks |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v5 |
| 18 | + - name: Set up Python and uv |
| 19 | + uses: astral-sh/setup-uv@v7 |
| 20 | + with: |
| 21 | + python-version: "3.12" |
| 22 | + enable-cache: true |
| 23 | + - name: Install pre-commit |
| 24 | + run: | |
| 25 | + uv sync --group lint |
| 26 | + uv run pre-commit install |
| 27 | + - name: Run code-quality checks |
| 28 | + run: uv run pre-commit run --all-files --show-diff-on-failure |
| 29 | + # ---------------------------------------------------------------------------------------------- |
| 30 | + # Install and Import Check |
| 31 | + # ---------------------------------------------------------------------------------------------- |
| 32 | + install_and_import_shapiq: |
| 33 | + name: Install and import check shapiq |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v5 |
| 37 | + - name: Set up Python and uv |
| 38 | + uses: astral-sh/setup-uv@v7 |
| 39 | + with: |
| 40 | + python-version: "3.12" |
| 41 | + enable-cache: true |
| 42 | + - name: Create uv virtual environment |
| 43 | + run: uv venv |
| 44 | + - name: Install shapiq package |
| 45 | + run: uv run --no-sync uv pip install . |
| 46 | + - name: Test import |
| 47 | + run: uv run --no-sync python -c "import shapiq; print('✅ shapiq imported successfully')" |
| 48 | + # ---------------------------------------------------------------------------------------------- |
| 49 | + # Install and Import Check |
| 50 | + # ---------------------------------------------------------------------------------------------- |
| 51 | + install_and_import_shapiq_games: |
| 52 | + name: Install and import check shapiq-games |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v5 |
| 56 | + - name: Set up Python and uv |
| 57 | + uses: astral-sh/setup-uv@v7 |
| 58 | + with: |
| 59 | + python-version: "3.12" |
| 60 | + enable-cache: true |
| 61 | + - name: Create uv virtual environment |
| 62 | + run: uv venv |
| 63 | + - name: Install shapiq package |
| 64 | + run: uv run --no-sync uv pip install . |
| 65 | + - name: Install dependencies |
| 66 | + run: uv sync --no-dev --group all_ml |
| 67 | + - name: Test import of shapiq_games |
| 68 | + run: uv run --no-sync python -c "import shapiq_games; print('✅ shapiq_games imported successfully')" |
| 69 | + # ---------------------------------------------------------------------------------------------- |
| 70 | + # Unit Tests with Matrix |
| 71 | + # ---------------------------------------------------------------------------------------------- |
| 72 | + test_shapiq: |
| 73 | + name: Run Unit Tests |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + include: |
| 78 | + - os: ubuntu-latest |
| 79 | + python-version: "3.10" |
| 80 | + - os: ubuntu-latest |
| 81 | + python-version: "3.13" |
| 82 | + - os: windows-latest |
| 83 | + python-version: "3.12" |
| 84 | + - os: macos-latest |
| 85 | + python-version: "3.12" |
| 86 | + runs-on: ${{ matrix.os }} |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v5 |
| 89 | + - name: Set up Python and uv |
| 90 | + uses: astral-sh/setup-uv@v7 |
| 91 | + with: |
| 92 | + python-version: ${{ matrix.python-version }} |
| 93 | + enable-cache: true |
| 94 | + - name: Install test dependencies |
| 95 | + run: uv sync |
| 96 | + - name: Run unit tests |
| 97 | + run: uv run pytest "tests/shapiq" |
| 98 | + # ---------------------------------------------------------------------------------------------- |
| 99 | + # Unit Tests for shapiq-games |
| 100 | + # ---------------------------------------------------------------------------------------------- |
| 101 | + test_shapiq_games: |
| 102 | + runs-on: ubuntu-latest |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v5 |
| 105 | + - name: Set up Python and uv |
| 106 | + uses: astral-sh/setup-uv@v7 |
| 107 | + with: |
| 108 | + python-version: "3.12" |
| 109 | + enable-cache: true |
| 110 | + - name: Install dependencies |
| 111 | + run: uv sync |
| 112 | + - name: Run tests |
| 113 | + run: uv run pytest "tests/shapiq_games" -n logical |
| 114 | + # ---------------------------------------------------------------------------------------------- |
| 115 | + # Test Documentation Build |
| 116 | + # ---------------------------------------------------------------------------------------------- |
| 117 | + doc_build: |
| 118 | + name: Test Documentation Build |
| 119 | + runs-on: ubuntu-latest |
| 120 | + needs: |
| 121 | + - install_and_import_shapiq |
| 122 | + - check_code_quality |
| 123 | + steps: |
| 124 | + - uses: actions/checkout@v5 |
| 125 | + - name: Set up Python and uv |
| 126 | + uses: astral-sh/setup-uv@v7 |
| 127 | + with: |
| 128 | + python-version: "3.12" |
| 129 | + enable-cache: true |
| 130 | + - name: Install pandoc |
| 131 | + run: | |
| 132 | + sudo apt-get update |
| 133 | + sudo apt-get install -y pandoc |
| 134 | + - name: Install dependencies |
| 135 | + run: uv sync --no-dev --group docs |
| 136 | + # TODO(mmshlk) Turn this step to fail on warnings in the future. |
| 137 | + - name: Build documentation |
| 138 | + run: uv run --no-sync sphinx-build -b html docs/source docs/build/html |
| 139 | + # ---------------------------------------------------------------------------------------------- |
| 140 | + # Code Coverage |
| 141 | + # ---------------------------------------------------------------------------------------------- |
| 142 | + run_coverage: |
| 143 | + name: Run Test Coverage |
| 144 | + runs-on: ubuntu-latest |
| 145 | + needs: |
| 146 | + - install_and_import_shapiq |
| 147 | + - check_code_quality |
| 148 | + steps: |
| 149 | + - uses: actions/checkout@v5 |
| 150 | + - name: Set up Python and uv |
| 151 | + uses: astral-sh/setup-uv@v7 |
| 152 | + with: |
| 153 | + python-version: "3.12" |
| 154 | + enable-cache: true |
| 155 | + - name: Install test dependencies |
| 156 | + run: uv sync |
| 157 | + - name: Measure coverage |
| 158 | + run: uv run pytest "tests/shapiq" --cov=shapiq --cov-report=xml -n logical |
| 159 | + - name: Upload coverage to codecov |
| 160 | + uses: codecov/codecov-action@v5 |
| 161 | + with: |
| 162 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 163 | + fail_ci_if_error: true |
0 commit comments