diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index bf570b0..c1384d7 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -17,10 +17,17 @@ env: jobs: build_linux: runs-on: ubuntu-latest + strategy: matrix: python: ["3.10", "3.11", "3.12", "3.13"] + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -28,6 +35,7 @@ jobs: - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -42,8 +50,15 @@ jobs: - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + + - name: Store conda paths as envs + shell: bash -el {0} + run: | + echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> $GITHUB_ENV + - name: Build conda package run: | CHANNELS="-c https://software.repos.intel.com/python/conda -c conda-forge --override-channels" @@ -55,11 +70,12 @@ jobs: $VERSIONS \ $CHANNELS \ conda-recipe + - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} - path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda + path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda build_windows: runs-on: windows-latest @@ -67,17 +83,24 @@ jobs: strategy: matrix: python: ["3.10", "3.11", "3.12", "3.13"] - env: - conda-bld: C:\Miniconda\conda-bld\win-64\ + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: conda-incubator/setup-miniconda@v3 + + - uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 with: - conda-remove-defaults: true - auto-activate-base: true - activate-environment: "" + miniforge-version: latest + use-mamba: 'true' + conda-remove-defaults: 'true' + activate-environment: 'build' + python-version: '3.13' # no python 3.14 support by conda-build - name: Cache conda packages uses: actions/cache@v4 @@ -90,21 +113,29 @@ jobs: restore-keys: | ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + - name: Install conda-build run: conda install conda-build - - name: Setup MSVC - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + - name: Store conda paths as envs + shell: bash -el {0} + run: | + echo "CONDA_BLD=$CONDA_PREFIX\\conda-bld\\win-64\\" >> $GITHUB_ENV + - name: Build conda package run: conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe + - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} - path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.conda + path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda test_linux: needs: build_linux + runs-on: ubuntu-latest + strategy: matrix: include: @@ -116,6 +147,7 @@ jobs: numpy: "2.3" - python: "3.13" numpy: "2.3" + env: CHANNELS: -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels @@ -124,10 +156,13 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + - name: Create conda channel run: | mkdir -p $GITHUB_WORKSPACE/channel/linux-64 @@ -137,6 +172,7 @@ jobs: # Test channel conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json cat ver.json + - name: Collect dependencies run: | . $CONDA/etc/profile.d/conda.sh @@ -144,9 +180,11 @@ jobs: export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile cat lockfile + - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -165,8 +203,11 @@ jobs: CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS + conda activate ${{ env.TEST_ENV_NAME }} + # Test installed packages conda list + - name: Run tests run: | . $CONDA/etc/profile.d/conda.sh @@ -175,6 +216,7 @@ jobs: test_windows: needs: build_windows + runs-on: windows-latest strategy: @@ -188,6 +230,7 @@ jobs: numpy: "2.3" - python: "3.13" numpy: "2.3" + env: CHANNELS: -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels @@ -196,22 +239,28 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} - - uses: conda-incubator/setup-miniconda@v3 + + - uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 with: - conda-remove-defaults: true - auto-activate-base: true - activate-environment: "" - - name: Install conda-build - # Needed to be able to run conda index - run: conda install conda-build + miniforge-version: latest + use-mamba: 'true' + conda-remove-defaults: 'true' + activate-environment: 'test' + python-version: '3.13' # no python 3.14 support by conda-index + + - name: Install conda-index + run: conda install conda-index + - name: Create conda channel run: | mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64 move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64 - conda index ${{ env.GITHUB_WORKSPACE }}/channel + python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel + # Test channel conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json more ${{ env.GITHUB_WORKSPACE }}\ver.json + - name: Collect dependencies shell: cmd run: | @@ -223,6 +272,7 @@ jobs: ) conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile more lockfile + - name: Cache conda packages uses: actions/cache@v4 env: @@ -248,8 +298,11 @@ jobs: ) SET "WORKAROUND_DEPENDENCIES=intel-openmp" conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %WORKAROUND_DEPENDENCIES% pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} + conda activate -n ${{ env.TEST_ENV_NAME }} + # Test installed packages conda list + - name: Run tests run: | conda activate -n ${{ env.TEST_ENV_NAME }}