From 2e187a6e2c026b27c3420f0cc38b186b3bb4d6ef Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Fri, 22 May 2026 17:47:42 +0200 Subject: [PATCH] Refactor commonalities and general tidy-up --- .github/actions/checkout-repos/action.yml | 20 ++++++++++ .github/actions/setup-alr/action.yml | 45 +++++++++++++++++++++ .github/workflows/build-distros.yml | 48 +++++++---------------- .github/workflows/build-native-master.yml | 32 ++++++--------- .github/workflows/build-native.yml | 46 +++++++--------------- .github/workflows/build-ports.yml | 38 ++++++------------ .github/workflows/check-authorship.yml | 7 ++++ .github/workflows/check-crate-name.yml | 7 ++++ .github/workflows/check-index.yml | 39 +++++++++--------- .github/workflows/check-with-script.yml | 32 ++++----------- .github/workflows/cleaner.yml | 2 +- .github/workflows/diff-release.yml | 45 ++++++--------------- 12 files changed, 174 insertions(+), 187 deletions(-) create mode 100644 .github/actions/checkout-repos/action.yml create mode 100644 .github/actions/setup-alr/action.yml diff --git a/.github/actions/checkout-repos/action.yml b/.github/actions/checkout-repos/action.yml new file mode 100644 index 00000000..95d40c54 --- /dev/null +++ b/.github/actions/checkout-repos/action.yml @@ -0,0 +1,20 @@ +name: Check out index repos +description: > + Check out alire-index with full history (needed by diff detectors + and check-author; grafted partial branches cause confusion), and + alire-index-checks checked out at the PR base branch. + +runs: + using: composite + steps: + - name: Check out alire-index + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check out alire-index-checks + uses: actions/checkout@v4 + with: + repository: alire-project/alire-index-checks + ref: ${{ github.base_ref }} + path: alire-index-checks diff --git a/.github/actions/setup-alr/action.yml b/.github/actions/setup-alr/action.yml new file mode 100644 index 00000000..8685a42b --- /dev/null +++ b/.github/actions/setup-alr/action.yml @@ -0,0 +1,45 @@ +name: Set up alr +description: > + Install alr, stable or devel, based on the PR target branch. + The stable version is provided here as the single authoritative source. + +inputs: + version: + description: Stable alr version to install; update here to bump. + required: false + default: '2.1.0' + toolchain: + description: > + Passed verbatim to setup-alire's toolchain input + (e.g. --disable-assistant). Omit to use the action default. + required: false + default: '' + +runs: + using: composite + steps: + - name: Set up stable `alr` + if: contains(github.base_ref, 'stable-') && inputs.toolchain == '' + uses: alire-project/setup-alire@v5 + with: + version: ${{ inputs.version }} + + - name: Set up stable `alr` (custom toolchain) + if: contains(github.base_ref, 'stable-') && inputs.toolchain != '' + uses: alire-project/setup-alire@v5 + with: + version: ${{ inputs.version }} + toolchain: ${{ inputs.toolchain }} + + - name: Set up devel `alr` + if: contains(github.base_ref, 'devel-') && inputs.toolchain == '' + uses: alire-project/setup-alire@v5 + with: + branch: master + + - name: Set up devel `alr` (custom toolchain) + if: contains(github.base_ref, 'devel-') && inputs.toolchain != '' + uses: alire-project/setup-alire@v5 + with: + branch: master + toolchain: ${{ inputs.toolchain }} diff --git a/.github/workflows/build-distros.yml b/.github/workflows/build-distros.yml index 5c258538..09e7d9ce 100644 --- a/.github/workflows/build-distros.yml +++ b/.github/workflows/build-distros.yml @@ -4,16 +4,19 @@ name: Build Crate (Distro toolchain) # Build the crate on the platforms with a supported package manager # and using the distro-supplied GNAT compiler (with Alire's FSF fallback). -env: - CHECKS_ORG: alire-project - CHECKS_REPO: alire-index-checks - ALR_VERSION: 2.1.0 - on: pull_request: paths: - 'index/**.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + jobs: build: @@ -38,41 +41,20 @@ jobs: - ubuntu-lts # Ubuntu LTS is a common Debian derivative steps: - - name: Check out alire-index - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Needed to be able to diff and obtain changed files. Furthermore, we - # need the full history or else grafted partial branches confuse the - # changed files detectors (in both scripts/gh-build-crate.sh and - # check-author action). + - name: Check out repos + uses: ./.github/actions/checkout-repos - - name: Check out alire-index-checks - uses: actions/checkout@v4 + - name: Set up `alr` + uses: ./.github/actions/setup-alr with: - repository: ${{env.CHECKS_ORG}}/${{env.CHECKS_REPO}} - ref: ${{github.base_ref}} - path: ${{env.CHECKS_REPO}} - - - name: Set up stable `alr` - if: contains(github.base_ref, 'stable-') - uses: alire-project/setup-alire@v5 - with: - toolchain: --disable-assistant # We want to use the external ones in this workflow - version: ${{env.ALR_VERSION}} - - - name: Set up devel `alr` - if: contains(github.base_ref, 'devel-') - uses: alire-project/setup-alire@v5 - with: - toolchain: --disable-assistant # We want to use the external ones in this workflow - branch: master + # External distro toolchain is used; skip Alire's own + toolchain: --disable-assistant - name: Test crate (${{matrix.tag}}) uses: mosteo-actions/docker-run@v1 with: image: ghcr.io/alire-project/docker/gnat:${{matrix.tag}} - command: ${{env.CHECKS_REPO}}/scripts/gh-build-crate.sh + command: alire-index-checks/scripts/gh-build-crate.sh params: > -v ${{ github.workspace }}/alire_install/bin/alr:/usr/bin/alr -v ${{ github.event_path}}:/etc/event.json diff --git a/.github/workflows/build-native-master.yml b/.github/workflows/build-native-master.yml index e16ebb73..6e50933f 100644 --- a/.github/workflows/build-native-master.yml +++ b/.github/workflows/build-native-master.yml @@ -2,14 +2,11 @@ # When the same index version is used by various stable and devel `alr` # versions, we want to make sure all of them understand the index properly. -# Besides, there are name: Build Crate (alr dev) # Build the crate with a native toolchain from Alire env: - CHECKS_ORG: alire-project - CHECKS_REPO: alire-index-checks PACMAN: C:\Users\runneradmin\AppData\Local\alire\cache\msys64\usr\bin\pacman on: @@ -17,6 +14,14 @@ on: paths: - 'index/**.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + jobs: build: @@ -37,33 +42,20 @@ jobs: - windows-latest steps: - - name: Check out alire-index - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Needed to be able to diff and obtain changed files. Furthermore, we - # need the full history or else grafted partial branches confuse the - # changed files detectors (in both scripts/gh-build-crate.sh and - # check-author action). - - - name: Check out alire-index-checks - uses: actions/checkout@v4 - with: - repository: ${{env.CHECKS_ORG}}/${{env.CHECKS_REPO}} - ref: ${{github.base_ref}} - path: ${{env.CHECKS_REPO}} + - name: Check out repos + uses: ./.github/actions/checkout-repos - name: Set up devel `alr` uses: alire-project/setup-alire@v5 with: branch: 'master' - - name: Install tar from msys2 (Windows) # Git tar in Actions VM does not seem to work) + - name: Install tar from msys2 (Windows) # Git tar in Actions VM does not seem to work if: matrix.os == 'windows-latest' run: ${{env.PACMAN}} --noconfirm -S tar - name: Test crate - run: ${{env.CHECKS_REPO}}/scripts/gh-build-crate.sh + run: alire-index-checks/scripts/gh-build-crate.sh shell: bash env: GITHUB_EVENT_PATH: ${{ github.event_path }} diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index a29f6f6f..cccf74d8 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -4,9 +4,6 @@ name: Build Crate (Alire toolchain) # Build the crate with a native toolchain from Alire env: - CHECKS_ORG: alire-project - CHECKS_REPO: alire-index-checks - ALR_VERSION: 2.1.0 PACMAN: C:\Users\runneradmin\AppData\Local\alire\cache\msys64\usr\bin\pacman on: @@ -14,6 +11,14 @@ on: paths: - 'index/**.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + jobs: build: @@ -34,42 +39,19 @@ jobs: - windows-latest steps: - - name: Check out alire-index - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Needed to be able to diff and obtain changed files. Furthermore, we - # need the full history or else grafted partial branches confuse the - # changed files detectors (in both scripts/gh-build-crate.sh and - # check-author action). - - - name: Check out alire-index-checks - uses: actions/checkout@v4 - with: - repository: ${{env.CHECKS_ORG}}/${{env.CHECKS_REPO}} - ref: ${{github.base_ref}} - path: ${{env.CHECKS_REPO}} + - name: Check out repos + uses: ./.github/actions/checkout-repos # By default, this also sets up the newest indexed native toolchain - - name: Set up stable `alr` - if: contains(github.base_ref, 'stable-') - uses: alire-project/setup-alire@v5 - with: - version: ${{env.ALR_VERSION}} + - name: Set up `alr` + uses: ./.github/actions/setup-alr - # By default, this also sets up the newest indexed native toolchain - - name: Set up devel `alr` - if: contains(github.base_ref, 'devel-') - uses: alire-project/setup-alire@v5 - with: - branch: 'master' - - - name: Install tar from msys2 (Windows) # Git tar in Actions VM does not seem to work) + - name: Install tar from msys2 (Windows) # Git tar in Actions VM does not seem to work if: matrix.os == 'windows-latest' run: ${{env.PACMAN}} --noconfirm -S tar - name: Test crate - run: ${{env.CHECKS_REPO}}/scripts/gh-build-crate.sh + run: alire-index-checks/scripts/gh-build-crate.sh shell: bash env: GITHUB_EVENT_PATH: ${{ github.event_path }} diff --git a/.github/workflows/build-ports.yml b/.github/workflows/build-ports.yml index 502a7842..58fc6e65 100644 --- a/.github/workflows/build-ports.yml +++ b/.github/workflows/build-ports.yml @@ -6,16 +6,19 @@ name: Build Crate (MacPorts) # Build the crate with a native toolchain from Alire -env: - CHECKS_ORG: alire-project - CHECKS_REPO: alire-index-checks - ALR_VERSION: 2.1.0 - on: pull_request: paths: - 'index/**.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + jobs: build: @@ -33,26 +36,11 @@ jobs: - macos-latest # arm64 steps: - - name: Check out alire-index - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Needed to be able to diff and obtain changed files. Furthermore, we - # need the full history or else grafted partial branches confuse the - # changed files detectors (in both scripts/gh-build-crate.sh and - # check-author action). + - name: Check out repos + uses: ./.github/actions/checkout-repos - - name: Check out alire-index-checks - uses: actions/checkout@v4 - with: - repository: ${{env.CHECKS_ORG}}/${{env.CHECKS_REPO}} - ref: ${{github.base_ref}} - path: ${{env.CHECKS_REPO}} - - - name: Set up stable `alr` - uses: alire-project/setup-alire@v5 - with: - version: ${{env.ALR_VERSION}} + - name: Set up `alr` + uses: ./.github/actions/setup-alr - name: Disable Homebrew run: rm -f $(which brew) @@ -66,7 +54,7 @@ jobs: run: echo '-x11 +no_x11 +quartz' >> /opt/local/etc/macports/variants.conf - name: Test crate - run: ${{env.CHECKS_REPO}}/scripts/gh-build-crate.sh + run: alire-index-checks/scripts/gh-build-crate.sh shell: bash env: GITHUB_EVENT_PATH: ${{ github.event_path }} diff --git a/.github/workflows/check-authorship.yml b/.github/workflows/check-authorship.yml index 6dc55163..7d1a62ef 100644 --- a/.github/workflows/check-authorship.yml +++ b/.github/workflows/check-authorship.yml @@ -5,6 +5,13 @@ on: paths: - 'index/**.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + jobs: check: uses: ./.github/workflows/check-with-script.yml diff --git a/.github/workflows/check-crate-name.yml b/.github/workflows/check-crate-name.yml index 484fbbf6..4e51ed2e 100644 --- a/.github/workflows/check-crate-name.yml +++ b/.github/workflows/check-crate-name.yml @@ -5,6 +5,13 @@ on: paths: - 'index/**.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + jobs: check: uses: ./.github/workflows/check-with-script.yml diff --git a/.github/workflows/check-index.yml b/.github/workflows/check-index.yml index 291924c7..36eac485 100644 --- a/.github/workflows/check-index.yml +++ b/.github/workflows/check-index.yml @@ -1,35 +1,34 @@ name: Check Index -env: - ALR_VERSION: 2.1.0 - on: pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - build: + check: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v4 - - name: Set up stable `alr` - if: contains(github.base_ref, 'stable-') - uses: alire-project/setup-alire@v5 - with: - version: ${{env.ALR_VERSION}} + - name: Set up `alr` + uses: ./.github/actions/setup-alr - - name: Set up devel `alr` - if: contains(github.base_ref, 'devel-') - uses: alire-project/setup-alire@v5 - with: - branch: master + - name: List current index + run: alr index --list - - run: alr index --list - - - run: alr index --add=. --name=local_index + - name: Add local index + run: alr index --add=. --name=local_index # Check index contents for unknown config variables - - run: alr index --check + - name: Check index + run: alr index --check - - run: alr index --update-all + - name: Update index + run: alr index --update-all - - run: alr search --crates + - name: List crates + run: alr search --crates diff --git a/.github/workflows/check-with-script.yml b/.github/workflows/check-with-script.yml index 390c9573..86d5473a 100644 --- a/.github/workflows/check-with-script.yml +++ b/.github/workflows/check-with-script.yml @@ -17,37 +17,21 @@ on: type: boolean default: false -env: - CHECKS_ORG: alire-project - CHECKS_REPO: alire-index-checks - ALR_VERSION: 2.1.0 - jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Needed to be able to diff and obtain changed files. Furthermore, - # we need the full history or else grafted partial branches confuse - # the changed files detectors. + - name: Check out repos + uses: ./.github/actions/checkout-repos - - name: Check out alire-index-checks - uses: actions/checkout@v4 - with: - repository: ${{env.CHECKS_ORG}}/${{env.CHECKS_REPO}} - ref: ${{github.base_ref}} - path: ${{env.CHECKS_REPO}} - - - name: Set up stable `alr` + - name: Set up `alr` if: inputs.setup_alr - uses: alire-project/setup-alire@v5 - with: - version: ${{env.ALR_VERSION}} + uses: ./.github/actions/setup-alr - name: Run check run: > - ${{env.CHECKS_REPO}}/scripts/${{inputs.script}} - "${{inputs.script_arg}}" + alire-index-checks/scripts/${{inputs.script}} + "$SCRIPT_ARG" shell: bash + env: + SCRIPT_ARG: ${{inputs.script_arg}} diff --git a/.github/workflows/cleaner.yml b/.github/workflows/cleaner.yml index a4ceee69..cc5eab00 100644 --- a/.github/workflows/cleaner.yml +++ b/.github/workflows/cleaner.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/stale@v7 with: - debug-only : false # Set to true to work in dry-run mode + debug-only: false # Set to true to work in dry-run mode stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.' close-pr-message: 'This PR was closed because it has been stalled for 90 days with no activity.' days-before-stale: 60 diff --git a/.github/workflows/diff-release.yml b/.github/workflows/diff-release.yml index ae067e63..8b24a3ed 100644 --- a/.github/workflows/diff-release.yml +++ b/.github/workflows/diff-release.yml @@ -5,16 +5,18 @@ name: Diff release -env: - CHECKS_ORG: alire-project - CHECKS_REPO: alire-index-checks - ALR_VERSION: 2.1.0 - on: pull_request: paths: - 'index/**.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + jobs: DIFF: @@ -22,35 +24,14 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check out alire-index - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Needed to be able to diff and obtain changed files. Furthermore, we - # need the full history or else grafted partial branches confuse the - # changed files detector + - name: Check out repos + uses: ./.github/actions/checkout-repos - - name: Check out alire-index-checks - uses: actions/checkout@v4 + - name: Set up `alr` + uses: ./.github/actions/setup-alr with: - repository: ${{env.CHECKS_ORG}}/${{env.CHECKS_REPO}} - ref: ${{github.base_ref}} - path: ${{env.CHECKS_REPO}} - - - name: Set up stable `alr` - if: contains(github.base_ref, 'stable-') - uses: alire-project/setup-alire@v5 - with: - toolchain: --disable-assistant # We don't need the compiler - version: ${{env.ALR_VERSION}} - - - name: Set up devel `alr` - if: contains(github.base_ref, 'devel-') - uses: alire-project/setup-alire@v5 - with: - toolchain: --disable-assistant # We don't need the compiler - branch: master + toolchain: --disable-assistant # No compiler needed - name: <> - run: ${{env.CHECKS_REPO}}/scripts/diff-release.sh || true # No deal breaker if failed + run: alire-index-checks/scripts/diff-release.sh || true # No deal breaker if failed shell: bash