From 1c476108889d71b724c9e66e641b300e30bac9e2 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Thu, 6 Feb 2025 12:26:15 +0100 Subject: [PATCH] feat: Ubuntu ARM builds (#1832) * Add Ubuntu ARM runner * Debug docker troubles * Enable in nightly * fix regex warnings * Debug +inf config value * Debug code insertions * Minimum GNAT version * Test nightly, remove SSH step * Add arch to artifacts * Restore workflows --- .github/workflows/ci-linux-arm.yml | 111 ++++++++++++++++++ .github/workflows/ci-linux.yml | 2 +- .github/workflows/nightly.yml | 63 +++++++--- testsuite/tests/index/bad-config-vars/test.py | 11 +- 4 files changed, 167 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/ci-linux-arm.yml diff --git a/.github/workflows/ci-linux-arm.yml b/.github/workflows/ci-linux-arm.yml new file mode 100644 index 00000000..387bc86d --- /dev/null +++ b/.github/workflows/ci-linux-arm.yml @@ -0,0 +1,111 @@ +name: CI linux + +on: + pull_request: + paths-ignore: + - 'doc/**' + - '**.md' + - '**.rst' + - '**.txt' + release: + types: [published] + workflow_dispatch: + +env: + alire_index: "" + # Empty index: test with master of community index + # Otherwise: test with particular commit/branch + # e.g.: index: "git+https://github.com/alire-project/alire-index@deadbeef" + +jobs: + + build: + name: CI on Linux (ARM) + + runs-on: ubuntu-24.04-arm + # Oldest supported so releases can run on older distros + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install FSF toolchain + run: sudo apt-get install -y gnat gprbuild + # GNAT 10 has a bug that fails in the testsuite + + - name: Check toolchain architecture + uses: mosteo-actions/gnat-toolchain-arch-checker@v1 + + - name: Install Python 3.x (required for the testsuite) + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: build only + run: ALIRE_OS=linux gprbuild -j0 -p -P alr_env + + - name: Run test script + run: scripts/ci-github.sh + shell: bash + env: + BRANCH: ${{ github.base_ref }} + INDEX: "" + ALIRE_TESTSUITE_DISABLE_DOCKER: "true" + + # Ascertain whether alr can run without the toolchain that built it + + - name: Remove OS GNAT + run: sudo apt-get remove -y gnat-10 gprbuild + shell: bash + + - name: Check standalone alr + uses: mosteo-actions/alr-standalone-checker@v1 + with: + alr_path: bin + toolchain_path: unused + + - name: Upload binaries + uses: actions/upload-artifact@v4 + with: + name: alr-bin-linux-aarch64.zip + path: | + bin/alr + LICENSE.txt + + - name: Upload logs (if failed) + if: failure() + uses: actions/upload-artifact@v4 + with: + name: e3-log-linux.zip + path: testsuite/out + + # Release steps start here. These only run during a release creation. + + - name: Package binaries + if: (github.event_name == 'release') + run: zip alr-bin-linux.zip bin/alr LICENSE.txt + + - name: Retrieve upload URL for the release + if: (github.event_name == 'release') + id: get_release + uses: bruceadams/get-release@v1.3.2 + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Get release version + if: (github.event_name == 'release') + id: get_version + uses: battila7/get-version-action@v2 + + - name: Upload binary assets + if: (github.event_name == 'release') + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release.outputs.upload_url }} + asset_path: alr-bin-linux.zip + asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-aarch64-linux.zip + asset_content_type: application/zip diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 6193d58e..a7fc4eec 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -62,7 +62,7 @@ jobs: - name: Upload binaries uses: actions/upload-artifact@v4 with: - name: alr-bin-linux.zip + name: alr-bin-linux-x86_64.zip path: | bin/alr LICENSE.txt diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e89bd64d..ce04baee 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,6 +6,7 @@ on: branches: - 'feat/nightly' # Allows to be tested before merging - 'fix/nightly' + - 'feat/ubuntu-arm' schedule: - cron: '0 0 * * *' workflow_dispatch: @@ -21,9 +22,10 @@ jobs: fail-fast: false # Attempt to generate as many of them as possible matrix: os: - - macos-13 # x64 - - macos-14 # arm64 - - ubuntu-20.04 # oldest supported to be able to run on those + - macos-13 # x64 + - macos-14 # arm64 + - ubuntu-20.04 # oldest supported to be able to run on those + - ubuntu-24.04-arm # oldest with ARM arch - windows-latest steps: @@ -32,12 +34,26 @@ jobs: with: submodules: true - - name: Install FSF toolchain + # Determine special case (we need an OS GNAT) + - name: Need OS GNAT? + id: need_os_gnat + if: matrix.os == 'ubuntu-24.04-arm' + run: echo "need_os_gnat=true" >> $GITHUB_OUTPUT + + # Toolchain according to arch + + - name: Install Alire toolchain + if: steps.need_os_gnat.outputs.need_os_gnat != 'true' uses: alire-project/alr-install@v2 with: crates: gnat_native gprbuild prefix: alire_prefix + - name: Install Ubuntu ARM toolchain + if: steps.need_os_gnat.outputs.need_os_gnat == 'true' + run: sudo apt-get install -y gnat gprbuild + # GNAT 10 has a bug that fails in the testsuite + - name: Check toolchain architecture uses: mosteo-actions/gnat-toolchain-arch-checker@v1 @@ -46,11 +62,24 @@ jobs: with: python-version: '3.x' + # Determine whether to disable docker (cannot run on Ubuntu 24 ARM) + + - name: Set ALIRE_TESTSUITE_DISABLE_DOCKER + if: startsWith(matrix.os, 'ubuntu-24.04') + run: echo "ALIRE_TESTSUITE_DISABLE_DOCKER=true" >> $GITHUB_ENV + shell: bash + - name: Run test script run: scripts/ci-github.sh shell: bash # Ascertain whether alr can run without the toolchain that built it + + - name: Uninstall Ubuntu ARM GNAT + if: steps.need_os_gnat.outputs.need_os_gnat == 'true' + run: sudo apt-get remove -y gnat gprbuild + shell: bash + - name: Check standalone alr uses: mosteo-actions/alr-standalone-checker@v1 with: @@ -64,10 +93,20 @@ jobs: name: e3-log-linux.zip path: testsuite/out + - name: Select arch name + id: get_arch + shell: bash + run: | + case ${{ runner.arch }} in + X64) echo "arch=x86_64" >> $GITHUB_OUTPUT ;; + ARM64) echo "arch=aarch64" >> $GITHUB_OUTPUT ;; + *) echo "Unknown architecture, failing..." && exit 1 ;; + esac + - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: alr-bin-${{ matrix.os }}.zip + name: alr-bin-${{ matrix.os }}-${{steps.get_arch.outputs.arch}}.zip path: | bin/alr* LICENSE.txt @@ -87,15 +126,11 @@ jobs: - name: Package binaries (Linux) if: startsWith(matrix.os, 'ubuntu') - run: zip alr-nightly-bin-x86_64-linux.zip bin/alr* LICENSE.txt alr-*.txt + run: zip alr-nightly-bin-${{steps.get_arch.outputs.arch}}-linux.zip bin/alr* LICENSE.txt alr-*.txt - name: Package binaries (macOS/x64) - if: startsWith(matrix.os, 'macos') && runner.arch == 'X64' - run: zip alr-nightly-bin-x86_64-macos.zip bin/alr* LICENSE.txt alr-*.txt - - - name: Package binaries (macOS/arm64) - if: startsWith(matrix.os, 'macos') && runner.arch == 'ARM64' - run: zip alr-nightly-bin-aarch64-macos.zip bin/alr* LICENSE.txt alr-*.txt + if: startsWith(matrix.os, 'macos') + run: zip alr-nightly-bin-${{steps.get_arch.outputs.arch}}-macos.zip bin/alr* LICENSE.txt alr-*.txt # There's no zip on windows - name: Install zip (Windows) @@ -104,7 +139,7 @@ jobs: - name: Package binaries (Windows) if: startsWith(matrix.os, 'windows') - run: zip alr-nightly-bin-x86_64-windows.zip bin/alr* LICENSE.txt alr-*.txt + run: zip alr-nightly-bin-${{steps.get_arch.outputs.arch}}-windows.zip bin/alr* LICENSE.txt alr-*.txt - name: Upload to release uses: pyTooling/Actions/releaser/composite@main @@ -132,7 +167,7 @@ jobs: preRelease: true out-file-path: 'x86_64' extract: true - + - name: download aarch64 uses: robinraju/release-downloader@v1 with: diff --git a/testsuite/tests/index/bad-config-vars/test.py b/testsuite/tests/index/bad-config-vars/test.py index 6ffa7842..7057da0a 100644 --- a/testsuite/tests/index/bad-config-vars/test.py +++ b/testsuite/tests/index/bad-config-vars/test.py @@ -3,6 +3,7 @@ Test invalid crate configuration variable definitions """ import os +import re from drivers.alr import run_alr from drivers.asserts import assert_match @@ -52,9 +53,9 @@ check_error('var1=["plop"]', 'variable definition must be a table') check_error('var1={}', "configuration.variables.var1:") check_error('var1={}', "'type' missing") check_error('var1={type=42}', "'type' must be string") -check_error('var1={type=""}', "Invalid configuration type ''," - " must be \(real, integer, string," - " enum or boolean\)") +check_error('var1={type=""}', r"Invalid configuration type ''," + r" must be \(real, integer, string," + r" enum or boolean\)") check_error('var1={type="test"}', "Invalid configuration type 'test'.*") check_error('var1={type="String", plop="test"}', "forbidden extra entries: plop") @@ -101,7 +102,7 @@ check_ok('var1={type="Integer", first=0, last=10, default=5}') check_error('var1={type="Integer", values=0}', "forbidden extra entries: values") -expected = "invalid default value for Integer range .* \.\. .*" +expected = "invalid default value for Integer range .* " + re.escape("..") + " .*" check_error('var1={type="Integer", first=0, default=-1}', expected) check_error('var1={type="Integer", last=0, default=1}', expected) check_error('var1={type="Integer", first=0, last=10, default=20}', expected) @@ -160,7 +161,7 @@ check_error('var1={type="Enum", values=["A"], last="test"}', "forbidden extra en check_error('var1={type="Enum", values=[]}', "'values' must be a not empty array of strings") check_error('var1={type="Enum"}', "missing 'values' for enumeration type") -expected = "invalid default value for Enum \(A, B\)" +expected = r"invalid default value for Enum \(A, B\)" check_error('var1={type="Enum", values=["A", "B"], default="C"}', expected) check_error('var1={type="Enum", values=["A", "B"], default=42}', expected) check_error('var1={type="Enum", values=["A", "B"], default=42.0}', expected) -- 2.39.5