|
| 1 | +name: Build-test-upload package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +env: |
| 10 | + PACKAGE_NAME: mandelbrot-demo |
| 11 | + MODULE_NAME: mandelbrot_demo |
| 12 | + |
| 13 | +jobs: |
| 14 | + build_linux: |
| 15 | + runs-on: ubuntu-20.04 |
| 16 | + |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + python: ['3.8', '3.9', '3.10'] |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - name: Set pkgs_dirs |
| 26 | + run: | |
| 27 | + echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc |
| 28 | + - name: Cache conda packages |
| 29 | + uses: actions/cache@v3 |
| 30 | + env: |
| 31 | + CACHE_NUMBER: 0 # Increase to reset cache |
| 32 | + with: |
| 33 | + path: ~/.conda/pkgs |
| 34 | + key: |
| 35 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- |
| 38 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- |
| 39 | + - name: Add conda to system path |
| 40 | + run: echo $CONDA/bin >> $GITHUB_PATH |
| 41 | + - name: Install conda-build |
| 42 | + run: conda install conda-build |
| 43 | + - name: Build conda package |
| 44 | + run: | |
| 45 | + CHANNELS="-c dppy/label/dev -c intel -c conda-forge --override-channels" |
| 46 | + VERSIONS="--python ${{ matrix.python }}" |
| 47 | + TEST="" |
| 48 | + cd ./demos/mandelbrot |
| 49 | + conda build $TEST $VERSIONS $CHANNELS conda-recipe |
| 50 | + - name: Upload artifact |
| 51 | + uses: actions/upload-artifact@v3 |
| 52 | + with: |
| 53 | + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} |
| 54 | + path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2 |
| 55 | + |
| 56 | + test_linux: |
| 57 | + needs: build_linux |
| 58 | + runs-on: ${{ matrix.runner }} |
| 59 | + |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + python: ['3.8', '3.9', '3.10'] |
| 63 | + experimental: [true] |
| 64 | + runner: [ubuntu-20.04] |
| 65 | + continue-on-error: ${{ matrix.experimental }} |
| 66 | + env: |
| 67 | + CHANNELS: -c dppy/label/dev -c intel -c conda-forge --override-channels |
| 68 | + |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v3 |
| 71 | + with: |
| 72 | + fetch-depth: 0 |
| 73 | + - name: Download artifact |
| 74 | + uses: actions/download-artifact@v3 |
| 75 | + with: |
| 76 | + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} |
| 77 | + - name: Add conda to system path |
| 78 | + run: echo $CONDA/bin >> $GITHUB_PATH |
| 79 | + - name: Install conda-build |
| 80 | + # Needed to be able to run conda index |
| 81 | + run: conda install conda-build |
| 82 | + - name: Create conda channel |
| 83 | + run: | |
| 84 | + mkdir -p $GITHUB_WORKSPACE/channel/linux-64 |
| 85 | + # conda index $GITHUB_WORKSPACE/channel || exit 1 |
| 86 | + mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64 || exit 1 |
| 87 | + conda index $GITHUB_WORKSPACE/channel || exit 1 |
| 88 | + # Test channel |
| 89 | + conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json |
| 90 | + cat ver.json |
| 91 | + - name: Collect dependencies |
| 92 | + run: | |
| 93 | + CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" |
| 94 | + conda create -n test-env $PACKAGE_NAME python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile |
| 95 | + cat lockfile |
| 96 | + - name: Set pkgs_dirs |
| 97 | + run: | |
| 98 | + echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc |
| 99 | + - name: Cache conda packages |
| 100 | + uses: actions/cache@v3 |
| 101 | + env: |
| 102 | + CACHE_NUMBER: 0 # Increase to reset cache |
| 103 | + with: |
| 104 | + path: ~/.conda/pkgs |
| 105 | + key: |
| 106 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} |
| 107 | + restore-keys: | |
| 108 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- |
| 109 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- |
| 110 | + - name: Install package |
| 111 | + run: | |
| 112 | + export CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" |
| 113 | + conda create -n test-env $PACKAGE_NAME pytest python=${{ matrix.python }} ${CHANNELS} |
| 114 | + . $CONDA/etc/profile.d/conda.sh |
| 115 | + conda activate test-env |
| 116 | + # Test installed packages |
| 117 | + conda list -n test-env |
| 118 | + - name: Run tests |
| 119 | + run: | |
| 120 | + . $CONDA/etc/profile.d/conda.sh |
| 121 | + conda activate test-env |
| 122 | + pushd ./demos/mandelbrot/${{ env.MODULE_NAME }} |
| 123 | + pytest |
| 124 | + popd |
| 125 | +
|
| 126 | + upload_linux: |
| 127 | + needs: test_linux |
| 128 | + if: ${{github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')}} |
| 129 | + runs-on: ubuntu-20.04 |
| 130 | + strategy: |
| 131 | + matrix: |
| 132 | + python: ['3.8', '3.9', '3.10'] |
| 133 | + steps: |
| 134 | + - name: Download artifact |
| 135 | + uses: actions/download-artifact@v3 |
| 136 | + with: |
| 137 | + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} |
| 138 | + |
| 139 | + - name: Install anaconda-client |
| 140 | + run: conda install anaconda-client |
| 141 | + - name: Add conda to system path |
| 142 | + run: echo $CONDA/bin >> $GITHUB_PATH |
| 143 | + |
| 144 | + - name: Upload |
| 145 | + env: |
| 146 | + ANACONDA_TOKEN: ${{ secrets.PYCODDIYTOKEN }} |
| 147 | + run: | |
| 148 | + anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user pycoddiy --label dpep ${PACKAGE_NAME}-*.tar.bz2 |
| 149 | +
|
| 150 | + build_windows: |
| 151 | + runs-on: windows-latest |
| 152 | + |
| 153 | + strategy: |
| 154 | + matrix: |
| 155 | + python: ['3.8', '3.9', '3.10'] |
| 156 | + env: |
| 157 | + conda-bld: C:\Miniconda\conda-bld\win-64\ |
| 158 | + steps: |
| 159 | + - uses: actions/checkout@v3 |
| 160 | + with: |
| 161 | + fetch-depth: 0 |
| 162 | + - uses: conda-incubator/setup-miniconda@v2 |
| 163 | + with: |
| 164 | + use-only-tar-bz2: true |
| 165 | + auto-activate-base: true |
| 166 | + conda-build-version: "*" |
| 167 | + activate-environment: true |
| 168 | + python-version: ${{ matrix.python }} |
| 169 | + |
| 170 | + - name: Cache conda packages |
| 171 | + uses: actions/cache@v3 |
| 172 | + env: |
| 173 | + CACHE_NUMBER: 0 # Increase to reset cache |
| 174 | + with: |
| 175 | + path: /home/runner/conda_pkgs_dir |
| 176 | + key: |
| 177 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} |
| 178 | + restore-keys: | |
| 179 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- |
| 180 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- |
| 181 | + - name: Build conda package |
| 182 | + run: | |
| 183 | + cd ./demos/mandelbrot |
| 184 | + conda build --keep-old-work --dirty --no-test --python ${{ matrix.python }} -c dppy/label/dev -c intel -c conda-forge --override-channels conda-recipe |
| 185 | + - name: Upload artifact |
| 186 | + uses: actions/upload-artifact@v3 |
| 187 | + with: |
| 188 | + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} |
| 189 | + path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2 |
| 190 | + |
| 191 | + test_windows: |
| 192 | + needs: build_windows |
| 193 | + runs-on: ${{ matrix.runner }} |
| 194 | + defaults: |
| 195 | + run: |
| 196 | + shell: cmd /C CALL {0} |
| 197 | + strategy: |
| 198 | + matrix: |
| 199 | + python: ['3.8', '3.9', '3.10'] |
| 200 | + experimental: [false] |
| 201 | + runner: [windows-latest] |
| 202 | + continue-on-error: ${{ matrix.experimental }} |
| 203 | + env: |
| 204 | + workdir: '${{ github.workspace }}' |
| 205 | + CHANNELS: -c dppy/label/dev -c intel -c conda-forge --override-channels |
| 206 | + steps: |
| 207 | + - name: Checkout sources |
| 208 | + uses: actions/checkout@v3 |
| 209 | + with: |
| 210 | + fetch-depth: 0 |
| 211 | + - name: Download artifact |
| 212 | + uses: actions/download-artifact@v3 |
| 213 | + with: |
| 214 | + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} |
| 215 | + - uses: conda-incubator/setup-miniconda@v2 |
| 216 | + with: |
| 217 | + use-only-tar-bz2: false |
| 218 | + auto-update-conda: true |
| 219 | + conda-build-version: '*' |
| 220 | + miniconda-version: 'latest' |
| 221 | + activate-environment: test-env |
| 222 | + python-version: ${{ matrix.python }} |
| 223 | + - name: conda info |
| 224 | + shell: cmd /C CALL {0} |
| 225 | + run: | |
| 226 | + conda info |
| 227 | + - name: conda config --show |
| 228 | + shell: cmd /C CALL {0} |
| 229 | + run: | |
| 230 | + conda config --show |
| 231 | + - name: Create conda channel with the artifact bit |
| 232 | + shell: cmd /C CALL {0} |
| 233 | + run: | |
| 234 | + echo ${{ env.workdir }} |
| 235 | + mkdir ${{ env.workdir }}\channel\win-64 |
| 236 | + move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.workdir }}\channel\win-64 |
| 237 | + dir ${{ env.workdir }}\channel\win-64 |
| 238 | + - name: Index the channel |
| 239 | + shell: cmd /C CALL {0} |
| 240 | + run: conda index ${{ env.workdir }}\channel |
| 241 | + - name: Collect dependencies |
| 242 | + shell: cmd /C CALL {0} |
| 243 | + run: | |
| 244 | + conda install -n test-env ${{ env.PACKAGE_NAME }} python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile && conda activate test-env |
| 245 | + - name: Display lockfile content |
| 246 | + shell: pwsh |
| 247 | + run: Get-Content -Path .\lockfile |
| 248 | + - name: Cache conda packages |
| 249 | + uses: actions/cache@v3 |
| 250 | + env: |
| 251 | + CACHE_NUMBER: 0 # Increase to reset cache |
| 252 | + with: |
| 253 | + path: /home/runner/conda_pkgs_dir |
| 254 | + key: |
| 255 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} |
| 256 | + restore-keys: | |
| 257 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- |
| 258 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- |
| 259 | + - name: Install dependencies |
| 260 | + shell: cmd /C CALL {0} |
| 261 | + run: | |
| 262 | + conda install -n test-env ${{ env.PACKAGE_NAME }} pytest python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} |
| 263 | + - name: Install opencl_rt |
| 264 | + shell: cmd /C CALL {0} |
| 265 | + run: conda install -n test-env opencl_rt -c intel --override-channels |
| 266 | + - name: Configure Intel OpenCL CPU RT |
| 267 | + shell: pwsh |
| 268 | + run: | |
| 269 | + $script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1" |
| 270 | + &$script_path |
| 271 | + # Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default |
| 272 | + $cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg" |
| 273 | + Get-Content -Tail 5 -Path $cl_cfg |
| 274 | + - name: Run tests |
| 275 | + shell: pwsh |
| 276 | + run: | |
| 277 | + ls |
| 278 | + conda activate test-env |
| 279 | + pushd ./demos/mandelbrot/${{ env.MODULE_NAME }} |
| 280 | + pytest |
| 281 | + popd |
| 282 | +
|
| 283 | + upload_windows: |
| 284 | + needs: test_windows |
| 285 | + if: ${{github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')}} |
| 286 | + runs-on: windows-latest |
| 287 | + strategy: |
| 288 | + matrix: |
| 289 | + python: ['3.8', '3.9', '3.10'] |
| 290 | + steps: |
| 291 | + - name: Download artifact |
| 292 | + uses: actions/download-artifact@v3 |
| 293 | + with: |
| 294 | + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} |
| 295 | + - uses: conda-incubator/setup-miniconda@v2 |
| 296 | + with: |
| 297 | + auto-activate-base: true |
| 298 | + activate-environment: "" |
| 299 | + - name: Install anaconda-client |
| 300 | + run: conda install anaconda-client |
| 301 | + |
| 302 | + - name: Upload |
| 303 | + env: |
| 304 | + ANACONDA_TOKEN: ${{ secrets.PYCODDIYTOKEN }} |
| 305 | + run: | |
| 306 | + anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user pycoddiy --label dpep ${{ env.PACKAGE_NAME }}-*.tar.bz2 |
0 commit comments