diff options
Diffstat (limited to '.github/workflows/ci.yml')
| -rw-r--r-- | .github/workflows/ci.yml | 232 |
1 files changed, 209 insertions, 23 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52592fb4..70ce9fe4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,76 +2,262 @@ name: CI on: push: - branches: [develop] + branches: [develop, "release/**"] pull_request: - branches: [develop] + branches: [develop, "release/**"] + # `labeled` is added to the defaults (opened/synchronize/reopened) so + # that applying `full-ci`, `sanitizers`, or `thread-sanitizer` to an + # already-open PR triggers + # a fresh run that includes the requested opt-in jobs (see the gates below). + types: [opened, synchronize, reopened, labeled] workflow_dispatch: + inputs: + recache: + description: "Force recompilation and persist refreshed ccache objects on develop" + required: false + type: boolean + default: false + save_ccache: + description: "Persist Linux ccache objects without forcing recompilation on develop" + required: false + type: boolean + default: false + armhf_image_tag: + description: "Immutable paired ARMHF image tag; empty resolves the promoted generation" + required: false + type: string + default: "" + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + packages: read jobs: # Single source of truth for the project version string: read it from - # CMakeLists.txt so CI and release.yml cannot disagree. Strip the + # release-state.txt so CI and release builds cannot disagree. Strip the # optional fourth tweak segment (3.0.0.0 → 3.0.0) to match the 3-part # shape release.yml derives from build/v<X.Y.Z> tags. prepare: runs-on: ubuntu-latest + timeout-minutes: 10 outputs: version: ${{ steps.v.outputs.version }} + release_channel: ${{ steps.v.outputs.release_channel }} + rc_number: ${{ steps.v.outputs.rc_number }} + linux_image_tag: ${{ steps.linux-image.outputs.image_tag }} + armhf_image_tag: ${{ steps.armhf-image.outputs.image_tag }} + save_linux_ccache: ${{ steps.ccache-policy.outputs.save_ccache }} + build_linux_packages: ${{ steps.packaging-policy.outputs.build_packages }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 + - name: Validate workflow job timeouts + run: .github/scripts/validate-workflow-timeouts.py + - name: Run CI policy self-tests + run: | + .github/scripts/validate-ci-inputs.sh --self-test + .github/scripts/is-linux-ci-image-input.sh --self-test + .github/scripts/select-ccache-key-suffix.sh --self-test + .github/scripts/select-linux-ccache-save.sh --self-test + .github/scripts/select-linux-packaging.sh --self-test + .github/scripts/test-linux-ccache-compiler-signature.sh + .github/scripts/test-verify-linux-ci-image.sh + python3 -m unittest discover -s .github/scripts/tests -p 'test_*.py' - id: v run: | - VERSION=$(grep -E '^\s*VERSION\s+[0-9]' CMakeLists.txt | head -1 | awk '{print $2}' | cut -d. -f1-3) - if [ -z "$VERSION" ]; then - echo "::error::Could not derive VERSION from CMakeLists.txt" - exit 1 + STATE=$(python3 .github/scripts/release-policy.py read-state) + VERSION=$(jq -r .version <<<"$STATE") + CHANNEL=$(jq -r .channel <<<"$STATE") + RC_NUMBER=$(jq -r .rc <<<"$STATE") + echo "Derived version from release-state.txt: $VERSION" + { + echo "version=$VERSION" + echo "release_channel=$CHANNEL" + echo "rc_number=$RC_NUMBER" + } >> "$GITHUB_OUTPUT" + # PRs can consume develop caches, so only trusted develop executions may + # publish the Linux cache shared with later pull-request builds. + - id: ccache-policy + name: Select Linux ccache save policy + env: + EVENT_NAME: ${{ github.event_name }} + REQUEST_SAVE_CCACHE: ${{ inputs.save_ccache || false }} + RECACHE: ${{ inputs.recache || false }} + run: .github/scripts/select-linux-ccache-save.sh + - id: packaging-policy + name: Select Linux packaging policy + env: + EVENT_NAME: ${{ github.event_name }} + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + CURRENT_SHA: ${{ github.sha }} + FULL_CI: ${{ contains(github.event.pull_request.labels.*.name, 'full-ci') }} + run: .github/scripts/select-linux-packaging.sh + - id: linux-image + name: Resolve Linux CI image generation + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: .github/scripts/resolve-linux-ci-image-tag.py + - id: armhf-image + name: Resolve ARMHF CI image generation + if: >- + github.event_name == 'workflow_dispatch' || + contains(github.event.pull_request.labels.*.name, 'full-ci') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REQUESTED_TAG: ${{ inputs.armhf_image_tag || '' }} + run: | + if [[ -n "$REQUESTED_TAG" ]]; then + echo "Using requested ARMHF CI image generation: $REQUESTED_TAG" + echo "image_tag=$REQUESTED_TAG" >> "$GITHUB_OUTPUT" + else + RESOLVE_ARMHF=true .github/scripts/resolve-linux-ci-image-tag.py fi - echo "Derived version from CMakeLists.txt: $VERSION" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" + # Two-tier CI to conserve Actions minutes. The default path runs one Linux + # x86_64 smoke leg; sanitizer and broader platform coverage are opt-in. + # + # * Default (every push / PR to develop): Linux x86_64 only -- `linux`. + # * ASan + UBSan: runs on PRs carrying `sanitizers` or `full-ci`. + # * TSan: runs only on PRs carrying `thread-sanitizer`. + # * Opt-in matrix (`linux-arm`, `linux-armhf`, macos, macos-intel, windows): runs when a + # PR carries the `full-ci` label, or when the workflow is started manually + # ("Run workflow" / workflow_dispatch). Release builds are unaffected -- + # they run the full matrix via release.yml on build/v* tags. + # + # Every non-prepare leg also `needs: linux`, so a break that fails + # everywhere fails fast on the cheapest runner before any costly leg + # starts, instead of burning them in parallel. `prepare` stays in `needs` + # for its version output. macos: - needs: prepare + needs: [prepare, linux] + # Opt-in only -- see the two-tier note above. + if: >- + github.event_name == 'workflow_dispatch' || + contains(github.event.pull_request.labels.*.name, 'full-ci') uses: ./.github/workflows/build-macos.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" + hamlib_branch: "4.7.2" arch: "arm64" runner: "macos-15" deployment_target: "11.0" - secrets: inherit + recache: ${{ inputs.recache || false }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} macos-intel: - needs: prepare + needs: [prepare, linux] + # Opt-in only -- see the two-tier note above. + if: >- + github.event_name == 'workflow_dispatch' || + contains(github.event.pull_request.labels.*.name, 'full-ci') uses: ./.github/workflows/build-macos.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" + hamlib_branch: "4.7.2" arch: "x86_64" runner: "macos-15-intel" deployment_target: "10.13" - secrets: inherit + recache: ${{ inputs.recache || false }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} linux: - needs: prepare + needs: [prepare] uses: ./.github/workflows/build-linux.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" + hamlib_branch: "4.7.2" arch: "x86_64" + image_tag: ${{ needs.prepare.outputs.linux_image_tag }} + allow_stale_image: true + recache: ${{ inputs.recache || false }} + save_ccache: ${{ needs.prepare.outputs.save_linux_ccache == 'true' }} + validate_fortran_fallback: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'full-ci') }} + build_packages: ${{ needs.prepare.outputs.build_linux_packages == 'true' }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} secrets: inherit + linux-sanitizers: + name: Linux x86_64 ASan + UBSan + needs: [prepare, linux] + if: >- + contains(github.event.pull_request.labels.*.name, 'full-ci') || + contains(github.event.pull_request.labels.*.name, 'sanitizers') + uses: ./.github/workflows/build-linux-sanitizers.yml + with: + hamlib_branch: "4.7.2" + sanitizer: asan-ubsan + image_tag: ${{ needs.prepare.outputs.linux_image_tag }} + allow_stale_image: true + recache: ${{ inputs.recache || false }} + advisory: true + + linux-tsan: + name: Linux x86_64 TSan + needs: [prepare, linux] + if: contains(github.event.pull_request.labels.*.name, 'thread-sanitizer') + uses: ./.github/workflows/build-linux-sanitizers.yml + with: + hamlib_branch: "4.7.2" + sanitizer: tsan + recache: ${{ inputs.recache || false }} + advisory: true + linux-arm: - needs: prepare + needs: [prepare, linux] + # Opt-in only -- see the two-tier note above. + if: >- + github.event_name == 'workflow_dispatch' || + contains(github.event.pull_request.labels.*.name, 'full-ci') uses: ./.github/workflows/build-linux.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" + hamlib_branch: "4.7.2" arch: "aarch64" + image_tag: ${{ needs.prepare.outputs.linux_image_tag }} + allow_stale_image: true + recache: ${{ inputs.recache || false }} + save_ccache: ${{ needs.prepare.outputs.save_linux_ccache == 'true' }} + build_packages: ${{ needs.prepare.outputs.build_linux_packages == 'true' }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + secrets: inherit + + linux-armhf: + needs: [prepare, linux] + # Opt-in only -- target tests and runtime validation execute under QEMU. + if: >- + github.event_name == 'workflow_dispatch' || + contains(github.event.pull_request.labels.*.name, 'full-ci') + uses: ./.github/workflows/build-linux.yml + with: + version: ${{ needs.prepare.outputs.version }} + hamlib_branch: "4.7.2" + arch: "armhf" + image_tag: ${{ needs.prepare.outputs.armhf_image_tag }} + allow_stale_image: true + recache: ${{ inputs.recache || false }} + save_ccache: ${{ needs.prepare.outputs.save_linux_ccache == 'true' }} + build_packages: ${{ needs.prepare.outputs.build_linux_packages == 'true' }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} secrets: inherit windows: - needs: prepare + needs: [prepare, linux] + # Opt-in only -- see the two-tier note above. + if: >- + github.event_name == 'workflow_dispatch' || + contains(github.event.pull_request.labels.*.name, 'full-ci') uses: ./.github/workflows/build-windows.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" - secrets: inherit + hamlib_branch: "4.7.2" + recache: ${{ inputs.recache || false }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} |
