|
| 1 | +name: ci-bootstrap |
| 2 | + |
| 3 | +# Which released mcpp builds this tree, measured the way a developer builds it. |
| 4 | +# |
| 5 | +# `.xlings.json` names the mcpp a clone of this repository builds with: inside |
| 6 | +# the checkout the `mcpp` shim refuses to run any other version |
| 7 | +# ("mcpp@<pin> is the version this project asks for ... set this project up: |
| 8 | +# xlings install"). The pin does not move with every release; it moves when the |
| 9 | +# tree starts to need something the pinned mcpp does not have. Two jobs answer |
| 10 | +# whether that moment has come: |
| 11 | +# |
| 12 | +# developer the pinned mcpp, installed by `xlings install` in the checkout |
| 13 | +# (project scope, no -g) and run through the shim, builds the tree |
| 14 | +# with --strict, on Linux, macOS and Windows. build.yml builds with |
| 15 | +# the same version but installs it globally and runs it by path; a |
| 16 | +# shim or project-scope defect, or a cold runner, is only seen here. |
| 17 | +# latest the newest release builds the tree with --strict. It runs only |
| 18 | +# while the pin lags the newest release; when they are equal the |
| 19 | +# developer job has already answered. |
| 20 | +# |
| 21 | +# --strict is the assertion. A mcpp older than the manifest warns about a key it |
| 22 | +# does not know, drops it and exits 0 (2026.9.24.1 against |
| 23 | +# `[test] windows_code_page`); under --strict that is an error. |
| 24 | +# |
| 25 | +# No cache, on purpose: the subject is a fresh clone. |
| 26 | + |
| 27 | +on: |
| 28 | + workflow_call: |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read |
| 32 | + |
| 33 | +jobs: |
| 34 | + developer: |
| 35 | + name: the pinned mcpp builds the tree (${{ matrix.os }}, xlings install + mcpp build --strict) |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + timeout-minutes: 45 |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: |
| 41 | + os: [ubuntu-24.04, macos-15, windows-2025] |
| 42 | + env: |
| 43 | + XLINGS_NON_INTERACTIVE: '1' |
| 44 | + XLINGS_VERSION: '2026.10.10.2' |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Install xlings |
| 49 | + if: runner.os != 'Windows' |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + set -euo pipefail |
| 53 | + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.10.10.2 |
| 54 | + echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" |
| 55 | + echo "$HOME/.xlings/bin" >> "$GITHUB_PATH" |
| 56 | +
|
| 57 | + - name: Install xlings |
| 58 | + if: runner.os == 'Windows' |
| 59 | + shell: pwsh |
| 60 | + run: | |
| 61 | + irm https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.ps1 | iex |
| 62 | + "$env:USERPROFILE\.xlings\subos\current\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 |
| 63 | +
|
| 64 | + - name: Install the mcpp .xlings.json names, in this project |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + set -euo pipefail |
| 68 | + xlings install -y |
| 69 | + pin=$(grep -oE '"mcpp"[[:space:]]*:[[:space:]]*"[^"]+"' .xlings.json \ |
| 70 | + | grep -oE '[0-9]+(\.[0-9]+)+' | head -1) |
| 71 | + got=$(mcpp --version | head -1 | awk '{print $2}' | tr -d '\r') |
| 72 | + [ -n "$pin" ] && [ "$got" = "$pin" ] || { |
| 73 | + echo "::error::.xlings.json names mcpp ${pin:-?}; the shim in this checkout runs ${got:-nothing}"; exit 1; } |
| 74 | + echo "the shim runs mcpp $got, the version .xlings.json names" |
| 75 | +
|
| 76 | + - name: Build the tree with it (mcpp build --strict) |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + mcpp self config --mirror GLOBAL |
| 81 | + mcpp build --strict |
| 82 | + case "$RUNNER_OS" in Windows) exe=mcpp.exe ;; *) exe=mcpp ;; esac |
| 83 | + built=$(find target -type f -name "$exe" -path '*/bin/*' | grep -v '/dist/' || true) |
| 84 | + [ "$(printf '%s\n' "$built" | grep -c .)" = 1 ] || { |
| 85 | + echo "::error::expected one $exe under target/, found: ${built:-none}"; exit 1; } |
| 86 | + want=$(awk -F '"' '/^version[[:space:]]*=/{print $2; exit}' mcpp.toml) |
| 87 | + got=$("$built" --version | head -1 | tr -d '\r') |
| 88 | + [ "$got" = "mcpp $want" ] || { |
| 89 | + echo "::error::the built binary says '$got', mcpp.toml says $want"; exit 1; } |
| 90 | + echo "built $got" |
| 91 | +
|
| 92 | + latest: |
| 93 | + name: the newest release builds the tree (linux, when the pin lags it) |
| 94 | + runs-on: ubuntu-24.04 |
| 95 | + timeout-minutes: 45 |
| 96 | + env: |
| 97 | + XLINGS_NON_INTERACTIVE: '1' |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + |
| 101 | + - name: Compare the pin with the newest release |
| 102 | + id: cmp |
| 103 | + shell: bash |
| 104 | + env: |
| 105 | + GH_TOKEN: ${{ github.token }} |
| 106 | + run: | |
| 107 | + set -euo pipefail |
| 108 | + pin=$(grep -oE '"mcpp"[[:space:]]*:[[:space:]]*"[^"]+"' .xlings.json \ |
| 109 | + | grep -oE '[0-9]+(\.[0-9]+)+' | head -1) |
| 110 | + latest=$(gh api "repos/${{ github.repository }}/releases/latest" --jq .tag_name | sed 's/^v//') |
| 111 | + [ -n "$pin" ] && [ -n "$latest" ] || { |
| 112 | + echo "::error::could not read the pin (${pin:-?}) or the newest release (${latest:-?})"; exit 1; } |
| 113 | + echo "pin=$pin latest=$latest" |
| 114 | + echo "latest=$latest" >> "$GITHUB_OUTPUT" |
| 115 | + if [ "$pin" = "$latest" ]; then |
| 116 | + echo "run=false" >> "$GITHUB_OUTPUT" |
| 117 | + echo "::notice::.xlings.json names the newest release ($latest); the developer job covers it" |
| 118 | + else |
| 119 | + echo "run=true" >> "$GITHUB_OUTPUT" |
| 120 | + fi |
| 121 | +
|
| 122 | + - name: Install xlings |
| 123 | + if: steps.cmp.outputs.run == 'true' |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + set -euo pipefail |
| 127 | + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.10.10.2 |
| 128 | + echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" |
| 129 | +
|
| 130 | + - name: Install the newest release and build the tree with it (mcpp build --strict) |
| 131 | + if: steps.cmp.outputs.run == 'true' |
| 132 | + shell: bash |
| 133 | + run: | |
| 134 | + set -euo pipefail |
| 135 | + # Makes the released version the one the shim runs here, over the |
| 136 | + # checkout's own pin, and asserts it. |
| 137 | + bash .github/tools/install_released_mcpp.sh "${{ steps.cmp.outputs.latest }}" "$(pwd)" |
| 138 | + mcpp self config --mirror GLOBAL |
| 139 | + mcpp build --strict |
| 140 | + built=$(find target -type f -name mcpp -path '*/bin/*' | grep -v '/dist/' || true) |
| 141 | + [ "$(printf '%s\n' "$built" | grep -c .)" = 1 ] || { |
| 142 | + echo "::error::expected one mcpp under target/, found: ${built:-none}"; exit 1; } |
| 143 | + "$built" --version |
0 commit comments