|
| 1 | +# Pull-request build: only the distributions a PR touches are built |
| 2 | +# (a change outside distros/ affects all of them), on all five platforms. |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + distros: |
| 8 | + description: Space-separated distributions to build (default all) |
| 9 | + required: false |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +permissions: |
| 16 | + actions: read |
| 17 | + contents: read |
| 18 | + |
| 19 | +env: |
| 20 | + PYTHONIOENCODING: utf-8 |
| 21 | + SAVE_CACHE_AS_ARTIFACT: 'true' |
| 22 | + |
| 23 | +jobs: |
| 24 | + plan: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + distros: ${{ steps.plan.outputs.distros }} |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v6 |
| 30 | + with: |
| 31 | + persist-credentials: false |
| 32 | + fetch-depth: 0 |
| 33 | + - name: Which distributions changed |
| 34 | + id: plan |
| 35 | + env: |
| 36 | + BASE: ${{ github.event.pull_request.base.sha }} |
| 37 | + SELECTED: ${{ inputs.distros }} |
| 38 | + run: | |
| 39 | + # plain python + PyYAML of the runner image; no pixi needed for this |
| 40 | + if [ -n "$SELECTED" ]; then |
| 41 | + distros=$(python3 -c 'import json,os; print(json.dumps(os.environ["SELECTED"].split()))') |
| 42 | + elif [ -n "$BASE" ]; then |
| 43 | + distros=$(python3 tools/robostack.py changed-distros --base "$BASE") |
| 44 | + else |
| 45 | + distros=$(python3 tools/robostack.py changed-distros --base HEAD --all) |
| 46 | + fi |
| 47 | + echo "distros=$distros" | tee -a "$GITHUB_OUTPUT" |
| 48 | +
|
| 49 | + sort-check: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v6 |
| 53 | + with: |
| 54 | + persist-credentials: false |
| 55 | + - uses: prefix-dev/setup-pixi@v0.10.2 |
| 56 | + with: |
| 57 | + frozen: true |
| 58 | + pixi-version: v0.75.0 |
| 59 | + - name: Check sorting |
| 60 | + run: pixi run sort --check |
| 61 | + - name: Check conda_build_config.yaml is up to date |
| 62 | + run: | |
| 63 | + pixi run render-pinning |
| 64 | + git diff --exit-code -- 'distros/*/conda_build_config.yaml' |
| 65 | +
|
| 66 | + build: |
| 67 | + needs: plan |
| 68 | + if: needs.plan.outputs.distros != '[]' |
| 69 | + strategy: |
| 70 | + fail-fast: false |
| 71 | + matrix: |
| 72 | + distro: ${{ fromJSON(needs.plan.outputs.distros) }} |
| 73 | + target: |
| 74 | + - { os: ubuntu-latest, platform: linux-64 } |
| 75 | + - { os: ubuntu-24.04-arm, platform: linux-aarch64 } |
| 76 | + - { os: macos-15-intel, platform: osx-64 } |
| 77 | + - { os: macos-15, platform: osx-arm64 } |
| 78 | + - { os: windows-2022, platform: win-64 } |
| 79 | + name: ${{ matrix.distro }} ${{ matrix.target.platform }} |
| 80 | + runs-on: ${{ matrix.target.os }} |
| 81 | + env: |
| 82 | + DISTRO: ${{ matrix.distro }} |
| 83 | + PLATFORM: ${{ matrix.target.platform }} |
| 84 | + # rattler-build writes to ./output of the distribution, or to CONDA_BLD_PATH (win-64) |
| 85 | + CACHE_DIR: ${{ matrix.target.platform == 'win-64' && 'C:/bld/win-64' || format('distros/{0}/output/{1}', matrix.distro, matrix.target.platform) }} |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v6 |
| 88 | + with: |
| 89 | + persist-credentials: false |
| 90 | + fetch-depth: 0 |
| 91 | + |
| 92 | + - uses: prefix-dev/setup-pixi@v0.10.2 |
| 93 | + with: |
| 94 | + frozen: true |
| 95 | + pixi-version: v0.75.0 |
| 96 | + |
| 97 | + - name: Windows workarounds (short build path, long paths, PATH and SDK clean-up) |
| 98 | + if: runner.os == 'Windows' |
| 99 | + shell: pwsh |
| 100 | + run: | |
| 101 | + "CONDA_BLD_PATH=C:\bld\" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 102 | + New-Item -ItemType Directory -Force -Path C:\bld | Out-Null |
| 103 | + New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force |
| 104 | + Remove-Item -Recurse -Force C:\Strawberry -ErrorAction SilentlyContinue |
| 105 | + Remove-Item -Recurse -Force "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0" -ErrorAction SilentlyContinue |
| 106 | +
|
| 107 | + - name: Clean up PATH |
| 108 | + if: runner.os == 'Windows' |
| 109 | + uses: egor-tensin/cleanup-path@v5 |
| 110 | + with: |
| 111 | + dirs: 'C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin' |
| 112 | + |
| 113 | + - name: Disable git auto-maintenance in source caches |
| 114 | + shell: bash -l {0} |
| 115 | + run: git config --global maintenance.auto false |
| 116 | + |
| 117 | + - name: Generate recipes |
| 118 | + shell: bash -l {0} |
| 119 | + env: |
| 120 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + run: | |
| 122 | + set -e |
| 123 | + for attempt in 1 2 3; do |
| 124 | + if pixi run -v rs "$DISTRO" generate-recipes --platform "$PLATFORM" -n; then break; fi |
| 125 | + if [[ "${attempt}" == "3" ]]; then echo "Recipe generation failed after 3 attempts" >&2; exit 1; fi |
| 126 | + echo "Recipe generation attempt ${attempt} failed; retrying..." >&2 |
| 127 | + sleep 15 |
| 128 | + done |
| 129 | +
|
| 130 | + - name: Check patches |
| 131 | + shell: bash -l {0} |
| 132 | + run: | |
| 133 | + pixi run rs "$DISTRO" check-orphaned-patches |
| 134 | + pixi run rs "$DISTRO" check-patches |
| 135 | +
|
| 136 | + - name: Restore build cache |
| 137 | + uses: actions/cache/restore@v5 |
| 138 | + with: |
| 139 | + path: ${{ env.CACHE_DIR }} |
| 140 | + key: ${{ runner.os }}-${{ matrix.distro }}-${{ matrix.target.platform }}-pr-${{ github.event.pull_request.number }} |
| 141 | + restore-keys: | |
| 142 | + ${{ runner.os }}-${{ matrix.distro }}-${{ matrix.target.platform }}-pr-${{ github.event.pull_request.number }}- |
| 143 | +
|
| 144 | + # Temporary rebuild controls live in distros/<distro>/ci.yaml. |
| 145 | + - name: Apply ci.yaml cache controls |
| 146 | + shell: bash -l {0} |
| 147 | + run: | |
| 148 | + pixi run python tools/ci_config.py --cache-dir "$CACHE_DIR" --config "distros/$DISTRO/ci.yaml" --vinca "distros/$DISTRO/vinca.yaml" |
| 149 | + mkdir -p "$CACHE_DIR" |
| 150 | + pixi run rattler-index fs "$CACHE_DIR/.." --force |
| 151 | +
|
| 152 | + - name: Build recipes |
| 153 | + id: build-recipes |
| 154 | + shell: bash -l {0} |
| 155 | + run: | |
| 156 | + set +e |
| 157 | + extra=() |
| 158 | + # shorter work dirs for MAX_PATH on Windows |
| 159 | + [ "$PLATFORM" == "win-64" ] && extra+=(--no-build-id) |
| 160 | + pixi run rs "$DISTRO" build --target-platform "$PLATFORM" "${extra[@]}" 2>&1 | tee rattler-build.log |
| 161 | + status=${PIPESTATUS[0]} |
| 162 | + echo "exit-code=${status}" >> "$GITHUB_OUTPUT" |
| 163 | + exit "$status" |
| 164 | +
|
| 165 | + - name: Summarize build result |
| 166 | + if: always() |
| 167 | + shell: bash -l {0} |
| 168 | + run: | |
| 169 | + pixi run python tools/summarize_rattler_build.py --log rattler-build.log \ |
| 170 | + --platform "$DISTRO $PLATFORM" --outcome "${{ steps.build-recipes.outcome }}" >> "$GITHUB_STEP_SUMMARY" |
| 171 | +
|
| 172 | + - name: Upload build log |
| 173 | + if: always() |
| 174 | + uses: actions/upload-artifact@v6 |
| 175 | + with: |
| 176 | + name: build-log-${{ matrix.distro }}-${{ matrix.target.platform }}-${{ github.run_id }}-${{ github.run_attempt }} |
| 177 | + path: rattler-build.log |
| 178 | + if-no-files-found: warn |
| 179 | + retention-days: 7 |
| 180 | + |
| 181 | + - name: Save build cache |
| 182 | + if: ${{ always() && contains(fromJSON('["success","failure","cancelled"]'), steps.build-recipes.outcome) }} |
| 183 | + uses: actions/cache/save@v5 |
| 184 | + with: |
| 185 | + path: ${{ env.CACHE_DIR }} |
| 186 | + key: ${{ runner.os }}-${{ matrix.distro }}-${{ matrix.target.platform }}-pr-${{ github.event.pull_request.number }}-${{ github.run_id }}-${{ github.run_attempt }} |
| 187 | + |
| 188 | + - name: Generate the staged build workflows (catches post-merge problems) |
| 189 | + shell: bash -l {0} |
| 190 | + run: pixi run rs "$DISTRO" gha --platform "$PLATFORM" --batch-size 25 |
0 commit comments