From 2681b313d08224014fa3f5e4f76e9c75347213d2 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Tue, 4 Mar 2025 11:02:00 +0100 Subject: [PATCH] feat: 2.1 preparations (#1876) * Release preparations * Fix workflow warning * Fix test with hardcoded index version * fix: executable permissions * feat: improved error message for unknown predefined variables in env (#1875) Now full message mentions the fact that this evaluation is expected for prededefined variables and the offending key is printed. Example: ``` error: Unknown predefined variable in environment variable 'PATH' of 'alr': Unknown formatting key: HOME ``` * fix: assorted bitrot since last release * fix: Windows installer --------- Co-authored-by: Manuel --- .github/workflows/ci-release.yml | 62 ++++++++++++------- .gitignore | 2 + BREAKING.md | 5 +- RELEASING-post.md | 9 +++ RELEASING.md | 18 +++--- alire.toml | 2 +- doc/user-changes.md | 4 +- scripts/installer/make-alire-installer | 12 +++- src/alire/alire-index.ads | 12 ++-- src/alire/alire-version.ads | 7 +-- .../alire-settings-builtins-windows.ads | 2 +- testsuite/Dockerfile | 7 ++- testsuite/drivers/driver/docker_wrapper.py | 15 +++++ .../toolchain/install-from-system/test.py | 9 +-- .../tests/publish/private-indexes/test.py | 2 +- 15 files changed, 113 insertions(+), 55 deletions(-) create mode 100644 RELEASING-post.md diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index a343dd5d..8e811cc9 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -236,16 +236,17 @@ jobs: with: name: alr-bin-${{ matrix.platform.id }}.zip - # On Windows runners, 7zip is available instead of zip. Rather than - # installing zip from MSYS2 we simply use 7zip. - - - name: Package binaries (non-Windows) - if: matrix.platform.os != 'windows-latest' - run: zip alr-bin.zip bin/alr* LICENSE.txt - - - name: Package binaries (Windows) + # On Windows, install zip as it is not available by default + - name: Install zip (Windows) if: matrix.platform.os == 'windows-latest' - run: 7z a alr-bin.zip bin/alr.exe LICENSE.txt + run: choco install zip + + - name: Package binaries + shell: bash + # Mark executable as artifacts remove the executable bit + run: | + chmod +x bin/alr* + zip alr-bin.zip bin/alr* LICENSE.txt - name: Upload binary assets uses: actions/upload-release-asset@v1 @@ -278,6 +279,15 @@ jobs: with: name: alr-bin-x86_64-windows.zip + - name: Copy to preinstall location + shell: bash + run: | + INSTALL_DIR=$PWD/alr_install + echo "INSTALL_DIR=$INSTALL_DIR" >> $GITHUB_ENV + mkdir -p $INSTALL_DIR/bin + cp bin/alr.exe $INSTALL_DIR/bin + cp LICENSE.txt $INSTALL_DIR + # We need to install MSYS2 again. This is a bit wasteful since the build # job already did it, but at least this way things are more clearly # separated. If we rely on an existing Alire, we might hit the cache rather @@ -310,7 +320,7 @@ jobs: shell: bash working-directory: scripts/installer/ env: - ALR_INSTALL_DIR: ${{ runner.temp }}/alr_install + ALR_INSTALL_DIR: ${{ env.INSTALL_DIR }} ALR_INSTALL_OS: ${{ runner.os }} - name: Upload installer @@ -422,7 +432,8 @@ jobs: - name: Get ref version id: get_ref - run: echo "::set-output name=short_sha::$(echo ${{ github.sha }} | cut -c1-8)" + run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_OUTPUT + shell: bash - name: Upload as artifact uses: actions/upload-artifact@v4 @@ -447,6 +458,9 @@ jobs: with: name: alr-${{needs.appimage.outputs.short_sha}}-x86_64.AppImage.zip + - name: Mark as executable + run: chmod +x alr.AppImage + - name: Upload AppImage asset if: (github.event_name == 'release') uses: actions/upload-release-asset@v1 @@ -461,12 +475,12 @@ jobs: ################### # release-nightly # ################### - + release-nightly: name: Nightly release on ${{ matrix.platform.id }} - if: > - github.event_name == 'schedule' - || (github.event_name == 'workflow_dispatch' && github.event.inputs.release_nightly != 'false') + if: > + github.event_name == 'schedule' + || (github.event_name == 'workflow_dispatch' && github.event.inputs.release_nightly != 'false') || (github.event_name == 'pull_request' && contains(github.event.pull_request.title, 'nightly')) needs: [build, build-macos-universal] runs-on: ${{ matrix.platform.os }} @@ -508,7 +522,7 @@ jobs: id: date run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT shell: bash - + - name: Get metadata run: | touch alr-date-is-${{steps.date.outputs.date}}.txt @@ -516,8 +530,10 @@ jobs: shell: bash - name: Package binaries - run: zip alr-nightly-bin-${{matrix.platform.id}}.zip bin/alr* LICENSE.txt alr-*.txt - + run: | + chmod +x bin/alr* + zip alr-nightly-bin-${{matrix.platform.id}}.zip bin/alr* LICENSE.txt alr-*.txt + # The uploader needs Python with the github module - name: Set up Python @@ -541,8 +557,8 @@ jobs: release-nightly-appimage: name: Nightly AppImage if: > - github.event_name == 'schedule' - || (github.event_name == 'workflow_dispatch' && github.event.inputs.release_nightly != 'false') + github.event_name == 'schedule' + || (github.event_name == 'workflow_dispatch' && github.event.inputs.release_nightly != 'false') || (github.event_name == 'pull_request' && contains(github.event.pull_request.title, 'nightly')) needs: [appimage] runs-on: ubuntu-22.04 @@ -555,12 +571,14 @@ jobs: name: alr-${{needs.appimage.outputs.short_sha}}-x86_64.AppImage.zip - name: Rename binary - run: mv alr.AppImage alr-nightly-x86_64.AppImage + run: | + chmod +x alr.AppImage + mv alr.AppImage alr-nightly-x86_64.AppImage - name: Upload to release uses: pyTooling/Actions/releaser/composite@r4 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} tag: nightly rm: false files: alr-nightly-x86_64.AppImage diff --git a/.gitignore b/.gitignore index a4d0a0fe..a80d52bf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ .clang-format .clangd/ +.repomix +.vscode *.cgpr *.db diff --git a/BREAKING.md b/BREAKING.md index 6af4fb20..9fb6bf6d 100644 --- a/BREAKING.md +++ b/BREAKING.md @@ -1,10 +1,13 @@ -Log of breaking changes in index or alr. +Log of breaking changes in index or alr. Future versions are as of today and +may change. ### alr 3.0.0 + index 1.4.0 - alr: removed `ALR_CONFIG` environment variable. - alr: removed `alr config` command. +### We are here + ### alr 2.1.0 + index 1.4.0 - index: git remotes in origins are recognized even without `git+` prefix diff --git a/RELEASING-post.md b/RELEASING-post.md new file mode 100644 index 00000000..02cea8b0 --- /dev/null +++ b/RELEASING-post.md @@ -0,0 +1,9 @@ +## Checklist after releasing a new version + +1. [ ] Update versions (to -dev) + - `Alire.Version` + - `alire.toml` +1. [ ] Publish `alr` in community index? + - [ ] Release as many dependencies as possible (all needed) + - [ ] Remove corresponding pins + - [ ] Publish (but with caveat? It will not be the same exact build) \ No newline at end of file diff --git a/RELEASING.md b/RELEASING.md index fe938343..dfef1a1e 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,29 +1,29 @@ ## Checklist for releasing a new version 1. [ ] Update Msys2 installer at https://github.com/msys2/msys2-installer/releases/ -1. [ ] Run local-only tests (`/testsuite/run-dev.sh`) 1. [ ] Update versions - `Alire.Version` - `alire.toml` - `user-changes.md` +1. [ ] In repo `alire-index`: create new index version branches if necessary. + - Edit index/index.toml to match. +1. [ ] Run all tests (regular+local) (`/testsuite/run-dev.sh`) 1. [ ] Create test release in own fork. - To verify builds succeed. - As the Windows build can rarely fail, this provides a backup .exe -1. [ ] In repo `alire-index`: create new index version branches if necessary. - - Edit index/index.toml to match. +1. [ ] Create a proper release in alire-project/alire + - Tag corresponding commit as vX.X.X (github does it if missing). + - Use autogenerated release notes. + - Credit all collaborators (if release notes aren't exhaustive). 1. [ ] Ensure the index version is the default branch in the community repos: - alire-index - alire-index-checks (must match alire-index) - alire-index-staging (when it exists) - test-index -1. [ ] Create a proper release in alire-project/alire - - Tag corresponding commit as vX.X.X (github does it if missing). - - Use autogenerated release notes. - - Credit all collaborators (if release notes aren't exhaustive). -1. Update Alire.Version and alire.toml to -dev in release branch. +1. [ ] Update Alire.Version and alire.toml to -dev in release branch. 1. [ ] Update stable version used in alire-index workflows - We used to use default in setup-alire, but by making it explicit we can test the new release before making it the default for everyone (next step). -1. After a screening period, update default version in setup-alire repo. +1. [ ] After a screening period, update default version in setup-alire repo. - For major Alire versions with breaking changes, bump the setup-alire version too. diff --git a/alire.toml b/alire.toml index 94f1fa27..12c89d58 100644 --- a/alire.toml +++ b/alire.toml @@ -1,7 +1,7 @@ name = "alr" description = "Command-line tool from the Alire project" -version = "2.1-dev" +version = "2.1.0" authors = ["Alejandro R. Mosteo", "Fabien Chouteau", "Pierre-Marie de Rodat"] maintainers = ["alejandro@mosteo.com", "chouteau@adacore.com"] diff --git a/doc/user-changes.md b/doc/user-changes.md index f83b4845..3bd6287c 100644 --- a/doc/user-changes.md +++ b/doc/user-changes.md @@ -4,6 +4,8 @@ This document is a development diary summarizing changes in `alr` that notably affect the user experience. It is intended as a one-stop point for users to stay on top of `alr` new features. +## Release `2.2` + ## Release `2.1` ### New `--format` global switch to produce structured output @@ -18,7 +20,7 @@ select the desired output language: ``` $ alr --format=TOML search --crates hello -[[data]] +[[data]] description = "'Hello, world!' demonstration project" name = "hello" [[data]] diff --git a/scripts/installer/make-alire-installer b/scripts/installer/make-alire-installer index 05a9208d..9f510603 100644 --- a/scripts/installer/make-alire-installer +++ b/scripts/installer/make-alire-installer @@ -114,7 +114,8 @@ create_chroot_system() { pushd "${_newalire}" > /dev/null mkdir -p bin/ - cp -r "$ALR_INSTALL_DIR"/* . + echo "Copying from ${ALR_INSTALL_DIR} to $PWD" | tee -a "${_log}" + cp -rv "$ALR_INSTALL_DIR"/* . mkdir -p share/alire/ cp "${_thisdir}/alr_icon.ico" share/alire/ @@ -126,6 +127,15 @@ then echo "Please set \$ALR_INSTALL_DIR" exit 1 fi + +# Verify it is a folder +if [ ! -d "$ALR_INSTALL_DIR" ] +then + echo "$ALR_INSTALL_DIR is not a folder" + ls -alF "$ALR_INSTALL_DIR" + exit 1 +fi + if [[ -z "$ALR_INSTALL_OS" ]] then echo "Please set \$ALR_INSTALL_OS" diff --git a/src/alire/alire-index.ads b/src/alire/alire-index.ads index 485dc550..adf0c5b8 100644 --- a/src/alire/alire-index.ads +++ b/src/alire/alire-index.ads @@ -16,6 +16,10 @@ with Semantic_Versioning.Extended; package Alire.Index is + Community_Branch : constant String := "stable-1.4.0"; + -- The branch used for the community index. Must be updated when new index + -- features are introduced. + Community_Host : constant String := Settings.Builtins.Index_Host.Get; Community_Organization : constant String := @@ -26,8 +30,8 @@ package Alire.Index is Community_Repo : constant URL := "git+" & Community_Host - & "/" & Community_Organization - & "/" & Community_Repo_Name; + & "/" & Community_Organization + & "/" & Community_Repo_Name; -- Default index installed on first run Community_Name : constant Restricted_Name := "community"; @@ -45,10 +49,6 @@ package Alire.Index is and then Branch_String (Branch_String'Last) /= '-' and then (for some C of Branch_String => C = '-'); - Community_Branch : constant String := "stable-1.3.0"; - -- The branch used for the community index. Must be updated when new index - -- features are introduced. - Min_Compatible_Version : constant Semantic_Versioning.Version; -- Based on the constant defined in private section diff --git a/src/alire/alire-version.ads b/src/alire/alire-version.ads index 345b556c..ae9afb1f 100644 --- a/src/alire/alire-version.ads +++ b/src/alire/alire-version.ads @@ -12,11 +12,8 @@ private -- Remember to update Alire.Index branch if needed too - -- NOTE: in the following version string, the build part (after '+') will - -- be replaced by `alr build` with the current commit, and appended with - -- "_or_later" after build. - - Current_Str : constant String := "2.1.0-dev"; + Current_Str : constant String := "2.1.0"; + -- 2.1.0: new solver and other internal largish refactorings, bugfixes -- 2.0.2: quarterly bugfix maintenance release -- 2.0.1: fix `alr install` and minor fixes -- 2.0.0: alr settings refactor and minor fixes diff --git a/src/alire/os_windows/alire-settings-builtins-windows.ads b/src/alire/os_windows/alire-settings-builtins-windows.ads index a326bc16..7ac38f07 100644 --- a/src/alire/os_windows/alire-settings-builtins-windows.ads +++ b/src/alire/os_windows/alire-settings-builtins-windows.ads @@ -7,7 +7,7 @@ pragma Unreferenced (Alire.Settings.Edit.Early_Load); package Alire.Settings.Builtins.Windows is - Latest_Msys2 : constant String := "2024-07-27"; + Latest_Msys2 : constant String := "2025-02-21"; -- Update here to upgrade to the latest release Date_1 : String renames Latest_Msys2; diff --git a/testsuite/Dockerfile b/testsuite/Dockerfile index b1a134ec..edf9517e 100644 --- a/testsuite/Dockerfile +++ b/testsuite/Dockerfile @@ -1,7 +1,7 @@ # This docker image is used in tests with the `docker_wrapper` driver. -# Latest tested is 24.04 -FROM alire/gnat:ubuntu-lts +# Latest tested is 24.04. We use our image from the github registry. +FROM ghcr.io/alire-project/docker/gnat:ubuntu-lts RUN useradd -m -s /bin/bash user && \ chown user:user /home/user && \ @@ -19,7 +19,8 @@ RUN apt-get update && apt-get install -y \ # Use parent testsuite python packages here too, as they are potential imports # of the drivers and helpers that may be needed in the wrapped test. COPY ./testsuite/requirements.txt /testsuite/requirements.txt -RUN pip3 install -r /testsuite/requirements.txt +RUN pip3 install -r /testsuite/requirements.txt \ + --break-system-packages --no-cache-dir WORKDIR /testsuite USER user diff --git a/testsuite/drivers/driver/docker_wrapper.py b/testsuite/drivers/driver/docker_wrapper.py index 3a7b127a..c84414a3 100644 --- a/testsuite/drivers/driver/docker_wrapper.py +++ b/testsuite/drivers/driver/docker_wrapper.py @@ -3,6 +3,7 @@ import json import os import subprocess from importlib import import_module +import time from typing import Tuple from drivers.driver.base_driver import BaseDriver @@ -108,6 +109,8 @@ class DockerWrapperDriver(BaseDriver): for modifier in [val for _, val in self.MODIFIERS.items() if val in os.environ]: self.test_env[modifier] = os.environ[modifier] + start_time = time.time() + # Run our things try: container = get_client().containers.run( @@ -135,12 +138,24 @@ class DockerWrapperDriver(BaseDriver): self.result.log += f'Docker command failed with exit code {code} and output:\n{output}' raise TestAbortWithFailure( f"Docker command failed with exit code {code}") + + except Exception as e: + self.result.log += f'Docker command failed with exception: {e}' + # Also add traceback: + self.result.log += f'\nTraceback:\n{e.with_traceback()}' finally: + self.result.time = time.time() - start_time + # Don't leave dead containers around if 'container' in locals() and container: container.remove() + # Ensure output was generated by checking output existence + if 'output' not in locals(): + self.result.log += "Docker command did not generate any output" + raise TestAbortWithFailure("Docker command did not generate any output") + # Check that the test succeeded inside the docker container out_lines = output.splitlines() if out_lines and out_lines[-1] == 'SUCCESS': diff --git a/testsuite/tests/dockerized/toolchain/install-from-system/test.py b/testsuite/tests/dockerized/toolchain/install-from-system/test.py index e55de916..e7448ca1 100644 --- a/testsuite/tests/dockerized/toolchain/install-from-system/test.py +++ b/testsuite/tests/dockerized/toolchain/install-from-system/test.py @@ -8,18 +8,19 @@ is not in PATH. import json from shutil import which import subprocess -from drivers.alr import run_alr, set_default_user_settings, unselect_compiler, unselect_gprbuild -from drivers.asserts import assert_eq, assert_match, assert_substring +from drivers.alr import run_alr, unselect_compiler, unselect_gprbuild +from drivers.asserts import assert_eq, assert_substring INSTALL_TELLTALE = "The system package 'gprbuild' is about to be installed" def apt_uninstall(pkg:str, exe:str=""): """ Uninstall a package and verify that an executable, by default named as the - package, is no longer in PATH. + package, is no longer in PATH. Also remove any packages no longer anchored. """ real_exe = exe if exe != "" else pkg subprocess.run(["sudo", "apt-get", "remove", "-y", pkg]).check_returncode() + subprocess.run(["sudo", "apt-get", "autoremove", "-y"]).check_returncode() assert which(real_exe) is None, f"Unexpected executable: {which(real_exe)}" @@ -83,7 +84,7 @@ assert_substring(INSTALL_TELLTALE, p.out) # be found. Note that we cannot force a gnat installation, as there are no # system package definitions for it (because several versions are available # through system packages) and we don't want to force switches between them. -apt_uninstall("gnat-10", "gnat") # gnat-10 for our current Dockerfile +apt_uninstall("gnat") apt_uninstall("gprbuild") p = run_alr("toolchain", "--select", "gprbuild", quiet=False) assert_substring(INSTALL_TELLTALE, p.out) diff --git a/testsuite/tests/publish/private-indexes/test.py b/testsuite/tests/publish/private-indexes/test.py index 012261bd..fa7f6525 100644 --- a/testsuite/tests/publish/private-indexes/test.py +++ b/testsuite/tests/publish/private-indexes/test.py @@ -209,7 +209,7 @@ for force_arg in ([], ["--force"]): ( r".*This file can then be uploaded to " r"https://github\.com/github-username/alire-index/upload/" - r"stable-1\.3\.0/index/xx/xxx to create a pull request against" + r".*/index/xx/xxx to create a pull request against" r" the community index.*" ), ], -- 2.39.5