|
| 1 | +name: skore-remote-project |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + merge_group: |
| 9 | + types: [checks_requested] |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +permissions: {} |
| 16 | + |
| 17 | +defaults: |
| 18 | + run: |
| 19 | + shell: "bash" |
| 20 | + |
| 21 | +jobs: |
| 22 | + skore-remote-project-changes: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + changes: ${{ steps.filter.outputs.skore-remote-project }} |
| 26 | + permissions: |
| 27 | + pull-requests: read |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 31 | + |
| 32 | + - name: Define if at least one file has changed |
| 33 | + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 34 | + id: filter |
| 35 | + with: |
| 36 | + filters: | |
| 37 | + skore-remote-project: |
| 38 | + - '.github/workflows/skore-remote-project.yml' |
| 39 | + - 'ci/requirements/skore-remote-project/**' |
| 40 | + - 'skore-remote-project/**' |
| 41 | +
|
| 42 | + skore-remote-project-lint: |
| 43 | + runs-on: "ubuntu-latest" |
| 44 | + needs: [skore-remote-project-changes] |
| 45 | + if: ${{ (github.event_name == 'push') || (needs.skore-remote-project-changes.outputs.changes == 'true') }} |
| 46 | + permissions: |
| 47 | + contents: read |
| 48 | + steps: |
| 49 | + - name: Checkout code |
| 50 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 51 | + |
| 52 | + - name: Setup Python |
| 53 | + uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 |
| 54 | + with: |
| 55 | + python-version: "3.12" |
| 56 | + cache: pip |
| 57 | + |
| 58 | + - name: Install dependencies |
| 59 | + run: python -m pip install --upgrade pip pre-commit |
| 60 | + |
| 61 | + - name: Lint |
| 62 | + working-directory: skore-remote-project/ |
| 63 | + run: | |
| 64 | + pre-commit run --all-files ruff |
| 65 | + pre-commit run --all-files mypy |
| 66 | +
|
| 67 | + skore-remote-project-lockfiles: |
| 68 | + runs-on: "ubuntu-latest" |
| 69 | + needs: [skore-remote-project-changes] |
| 70 | + if: ${{ (contains(fromJSON('["pull_request", "merge_group"]'), github.event_name)) && (needs.skore-remote-project-changes.outputs.changes == 'true') }} |
| 71 | + permissions: |
| 72 | + contents: read |
| 73 | + steps: |
| 74 | + - name: Checkout code |
| 75 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 76 | + with: |
| 77 | + fetch-depth: 2 |
| 78 | + |
| 79 | + - name: Check lockfiles are not obsolete |
| 80 | + run: | |
| 81 | + set -eu |
| 82 | +
|
| 83 | + # Check if `pyproject.toml` has changed in this pull-request |
| 84 | + # ├── False |
| 85 | + # │ └── Exit 0 |
| 86 | + # └── True |
| 87 | + # └── Check if lockfiles have changed in this pull-request |
| 88 | + # ├── True |
| 89 | + # │ └── Exit 0 |
| 90 | + # └── False |
| 91 | + # └── Recompile lockfiles and check if they have to change |
| 92 | + # ├── False |
| 93 | + # │ └── Exit 0 |
| 94 | + # └── True |
| 95 | + # └── Exit 1 |
| 96 | +
|
| 97 | + changes=$(git diff --name-only HEAD^1 HEAD) |
| 98 | +
|
| 99 | + if |
| 100 | + (echo "${changes}" | grep -qE "skore-remote-project/pyproject.toml") && |
| 101 | + (echo "${changes}" | (! grep -qE "ci/requirements/skore-remote-project/.*/test-requirements.txt")) |
| 102 | + then |
| 103 | + curl -LsSf https://astral.sh/uv/0.6.16/install.sh | sh |
| 104 | + bash ci/pip-compile.sh skore-remote-project |
| 105 | +
|
| 106 | + if (git diff --name-only | grep -qE "ci/requirements/skore-remote-project/.*/test-requirements.txt"); then |
| 107 | + echo '::error title=skore-remote-project-lockfiles::Lockfiles obsolete, please execute `$ bash ci/pip-compile.sh skore-remote-project`' |
| 108 | + exit 1 |
| 109 | + fi |
| 110 | + fi |
| 111 | +
|
| 112 | + skore-remote-project-test: |
| 113 | + needs: [skore-remote-project-changes] |
| 114 | + if: ${{ (github.event_name == 'push') || (needs.skore-remote-project-changes.outputs.changes == 'true') }} |
| 115 | + strategy: |
| 116 | + fail-fast: false |
| 117 | + matrix: |
| 118 | + os: ["ubuntu-latest", "windows-latest"] |
| 119 | + python: ["3.9", "3.10", "3.11", "3.12"] |
| 120 | + scikit-learn: ["1.6"] |
| 121 | + include: |
| 122 | + - os: "ubuntu-latest" |
| 123 | + python: "3.12" |
| 124 | + scikit-learn: "1.4" |
| 125 | + - os: "ubuntu-latest" |
| 126 | + python: "3.12" |
| 127 | + scikit-learn: "1.5" |
| 128 | + - os: "ubuntu-latest" |
| 129 | + python: "3.12" |
| 130 | + scikit-learn: "1.6" |
| 131 | + coverage: true |
| 132 | + runs-on: ${{ matrix.os }} |
| 133 | + permissions: |
| 134 | + contents: read |
| 135 | + steps: |
| 136 | + - name: Checkout code |
| 137 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 138 | + |
| 139 | + - name: Setup Python |
| 140 | + uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 |
| 141 | + id: setup-python |
| 142 | + with: |
| 143 | + python-version: ${{ matrix.python }} |
| 144 | + check-latest: True |
| 145 | + cache: pip |
| 146 | + |
| 147 | + - name: Restore python-venv |
| 148 | + uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 149 | + id: cache-python-venv |
| 150 | + with: |
| 151 | + path: 'skore-remote-project/venv' |
| 152 | + key: >- |
| 153 | + python-venv |
| 154 | + -${{ matrix.os }} |
| 155 | + -${{ steps.setup-python.outputs.python-version }} |
| 156 | + -${{ hashFiles(format('ci/requirements/skore-remote-project/python-{0}/scikit-learn-{1}/test-requirements.txt', matrix.python, matrix.scikit-learn)) }} |
| 157 | +
|
| 158 | + - name: Setup python-venv |
| 159 | + working-directory: "skore-remote-project/" |
| 160 | + run: | |
| 161 | + set -eu |
| 162 | +
|
| 163 | + # Ensure venv is created |
| 164 | + python -m venv venv |
| 165 | +
|
| 166 | + # Activate venv for each step depending on the OS |
| 167 | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then |
| 168 | + echo "${GITHUB_WORKSPACE}/skore-remote-project/venv/bin" >> ${GITHUB_PATH} |
| 169 | + echo "VIRTUAL_ENV=${GITHUB_WORKSPACE}/skore-remote-project/venv" >> ${GITHUB_ENV} |
| 170 | + else |
| 171 | + echo "${GITHUB_WORKSPACE}\\skore-remote-project\\venv\\Scripts" >> ${GITHUB_PATH} |
| 172 | + echo "VIRTUAL_ENV=${GITHUB_WORKSPACE}\\skore-remote-project\\venv" >> ${GITHUB_ENV} |
| 173 | + fi |
| 174 | +
|
| 175 | + - name: Install dependencies in python-venv |
| 176 | + working-directory: ${{ format('ci/requirements/skore-remote-project/python-{0}/scikit-learn-{1}', matrix.python, matrix.scikit-learn) }} |
| 177 | + if: steps.cache-python-venv.outputs.cache-hit != 'true' |
| 178 | + run: | |
| 179 | + python -m pip install --upgrade pip build |
| 180 | + python -m pip install --requirement test-requirements.txt |
| 181 | +
|
| 182 | + - name: Save python-venv |
| 183 | + uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 184 | + if: steps.cache-python-venv.outputs.cache-hit != 'true' |
| 185 | + with: |
| 186 | + path: 'skore-remote-project/venv' |
| 187 | + key: ${{ steps.cache-python-venv.outputs.cache-primary-key }} |
| 188 | + |
| 189 | + - name: Build |
| 190 | + working-directory: skore-remote-project/ |
| 191 | + run: python -m build |
| 192 | + |
| 193 | + - name: Install |
| 194 | + working-directory: skore-remote-project/dist/ |
| 195 | + run: wheel=(*.whl); python -m pip install --force-reinstall --no-deps "${wheel}" |
| 196 | + |
| 197 | + - name: Test without coverage |
| 198 | + if: ${{ ! matrix.coverage }} |
| 199 | + timeout-minutes: 10 |
| 200 | + working-directory: skore-remote-project/ |
| 201 | + run: python -m pytest -n auto src/ tests/ --no-cov |
| 202 | + |
| 203 | + - name: Test with coverage |
| 204 | + if: ${{ matrix.coverage }} |
| 205 | + timeout-minutes: 10 |
| 206 | + working-directory: skore-remote-project/ |
| 207 | + run: | |
| 208 | + mkdir coverage |
| 209 | + python -m pytest -n auto src/ tests/ --junitxml=coverage/coverage.xml --cov-config=pyproject.toml --cov | tee coverage/coverage.txt |
| 210 | +
|
| 211 | + - name: Upload coverage reports |
| 212 | + if: ${{ matrix.coverage && (github.event_name == 'pull_request') }} |
| 213 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 214 | + with: |
| 215 | + name: skore-remote-project-coverage |
| 216 | + path: skore-remote-project/coverage/ |
| 217 | + |
| 218 | + skore-remote-project: |
| 219 | + needs: |
| 220 | + - skore-remote-project-changes |
| 221 | + - skore-remote-project-lint |
| 222 | + - skore-remote-project-lockfiles |
| 223 | + - skore-remote-project-test |
| 224 | + if: ${{ always() }} |
| 225 | + runs-on: Ubuntu-latest |
| 226 | + steps: |
| 227 | + - shell: bash |
| 228 | + run: | |
| 229 | + [[ ${{ contains(needs.*.result, 'failure') }} = false ]] |
0 commit comments