|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + pre_commit_check: |
| 13 | + name: Pre-Commit Check |
| 14 | + runs-on: ubuntu-latest |
| 15 | + defaults: |
| 16 | + run: |
| 17 | + shell: bash -l {0} |
| 18 | + env: |
| 19 | + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + - uses: conda-incubator/setup-miniconda@v3 |
| 24 | + with: |
| 25 | + auto-update-conda: true |
| 26 | + auto-activate-base: false |
| 27 | + activate-environment: tiktorch-server-env |
| 28 | + environment-file: environment.yml |
| 29 | + channel-priority: flexible |
| 30 | + miniforge-variant: Miniforge3 |
| 31 | + - name: Run Pre-Commit |
| 32 | + run: | |
| 33 | + echo $BRANCH_NAME |
| 34 | + echo ${{ github.event.pull_request.base.ref }} |
| 35 | + echo ${{ github.event.pull_request.head.sha }} |
| 36 | + git fetch origin |
| 37 | + pre-commit run --from-ref origin/${{ github.event.pull_request.base.ref }} --to-ref ${{ github.event.pull_request.head.sha }} |
| 38 | +
|
| 39 | + test-dev: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + defaults: |
| 42 | + run: |
| 43 | + shell: bash -l {0} |
| 44 | + steps: |
| 45 | + - name: Checkout code |
| 46 | + uses: actions/checkout@v4 |
| 47 | + - uses: conda-incubator/setup-miniconda@v3 |
| 48 | + with: |
| 49 | + auto-update-conda: true |
| 50 | + auto-activate-base: false |
| 51 | + activate-environment: tiktorch-server-env |
| 52 | + environment-file: environment.yml |
| 53 | + channel-priority: flexible |
| 54 | + miniforge-variant: Miniforge3 |
| 55 | + - name: conda diagnostics |
| 56 | + run: | |
| 57 | + conda info |
| 58 | + - name: install submodules |
| 59 | + run: | |
| 60 | + git submodule init |
| 61 | + git submodule update |
| 62 | + make install_submodules |
| 63 | + - name: Run tests |
| 64 | + run: | |
| 65 | + pytest -v -s --cov=tiktorch --cov-report=xml |
| 66 | + - name: Upload coverage to Codecov |
| 67 | + uses: codecov/codecov-action@v4 |
| 68 | + with: |
| 69 | + file: ./coverage.xml |
| 70 | + fail_ci_if_error: true |
| 71 | + env: |
| 72 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 73 | + |
| 74 | + |
| 75 | + conda-noarch-build: |
| 76 | + runs-on: ubuntu-latest |
| 77 | + outputs: |
| 78 | + version: ${{ steps.version.outputs.version }} |
| 79 | + defaults: |
| 80 | + run: |
| 81 | + shell: bash -l {0} |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v4 |
| 84 | + with: |
| 85 | + fetch-depth: 0 |
| 86 | + - uses: conda-incubator/setup-miniconda@v3 |
| 87 | + with: |
| 88 | + auto-update-conda: true |
| 89 | + auto-activate-base: true |
| 90 | + channel-priority: flexible |
| 91 | + miniforge-variant: Miniforge3 |
| 92 | + - name: install common conda dependencies |
| 93 | + run: mamba install -n base -c conda-forge conda-build setuptools_scm -y |
| 94 | + - name: Cache Conda Packages |
| 95 | + uses: actions/cache@v4 |
| 96 | + with: |
| 97 | + path: | |
| 98 | + pkgs/noarch |
| 99 | + pkgs/channeldata.json |
| 100 | + key: ${{ github.sha }}-packages |
| 101 | + - id: version |
| 102 | + run: | |
| 103 | + vers=$( python setup.py --version ) |
| 104 | + echo "version=${vers}" >> $GITHUB_OUTPUT |
| 105 | + - name: Linux Conda Build Test |
| 106 | + run: | |
| 107 | + mkdir -p ./pkgs/noarch |
| 108 | + conda build -c conda-forge conda-recipe --no-test --output-folder ./pkgs |
| 109 | +
|
| 110 | + test-build-conda-packages: |
| 111 | + needs: [conda-noarch-build] |
| 112 | + strategy: |
| 113 | + fail-fast: false |
| 114 | + matrix: |
| 115 | + os: [macos-latest, windows-latest, ubuntu-latest] |
| 116 | + runs-on: ${{ matrix.os }} |
| 117 | + env: |
| 118 | + TIKTORCH_PACKAGE_NAME: tiktorch-${{ needs.conda-noarch-build.outputs.version }}-py_0.tar.bz2 |
| 119 | + steps: |
| 120 | + # Use GNU tar instead of BSD tar on Windows |
| 121 | + - name: "Use GNU tar instead of BSD tar" |
| 122 | + if: matrix.os == 'windows-latest' |
| 123 | + shell: cmd |
| 124 | + run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" |
| 125 | + - name: Checkout code |
| 126 | + uses: actions/checkout@v4 |
| 127 | + with: |
| 128 | + fetch-depth: 0 |
| 129 | + - uses: conda-incubator/setup-miniconda@v3 |
| 130 | + with: |
| 131 | + auto-update-conda: true |
| 132 | + auto-activate-base: true |
| 133 | + channel-priority: flexible |
| 134 | + miniforge-variant: Miniforge3 |
| 135 | + - name: install common conda dependencies |
| 136 | + run: mamba install -n base -c conda-forge conda-build setuptools_scm -y |
| 137 | + - name: Cache Conda Packages |
| 138 | + uses: actions/cache@v4 |
| 139 | + with: |
| 140 | + path: | |
| 141 | + pkgs/noarch |
| 142 | + pkgs/channeldata.json |
| 143 | + key: ${{ github.sha }}-packages |
| 144 | + enableCrossOsArchive: true |
| 145 | + - name: Linux Test |
| 146 | + if: matrix.os == 'ubuntu-latest' |
| 147 | + shell: bash -l {0} |
| 148 | + run: | |
| 149 | + conda build --test --override-channels \ |
| 150 | + -c ./pkgs -c pytorch -c ilastik-forge -c conda-forge \ |
| 151 | + ./pkgs/noarch/${TIKTORCH_PACKAGE_NAME} |
| 152 | + - name: macOS Test |
| 153 | + if: matrix.os == 'macos-latest' |
| 154 | + shell: bash -l {0} |
| 155 | + run: | |
| 156 | + conda build --test --override-channels \ |
| 157 | + -c ./pkgs -c pytorch -c ilastik-forge -c conda-forge \ |
| 158 | + ./pkgs/noarch/${TIKTORCH_PACKAGE_NAME} |
| 159 | + - name: Windows Test |
| 160 | + if: matrix.os == 'windows-latest' |
| 161 | + # HACK: due to a bug in conda-build need to point to |
| 162 | + # libarchive explicitly. |
| 163 | + # https://github.com/conda/conda/issues/12563#issuecomment-1494264704 |
| 164 | + env: |
| 165 | + LIBARCHIVE: C:\Miniconda\Library\bin\archive.dll |
| 166 | + shell: cmd /C CALL {0} |
| 167 | + run: | |
| 168 | + conda build --test --override-channels ^ |
| 169 | + -c %CD%\pkgs -c pytorch -c ilastik-forge -c conda-forge ^ |
| 170 | + .\pkgs\noarch\%TIKTORCH_PACKAGE_NAME% |
0 commit comments