From 5981e432c93321698ddd8a5c7790184ee46135f7 Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Fri, 20 Mar 2026 11:49:47 +0100 Subject: [PATCH 1/6] First version using only bash --- .github/workflows/CI.yml | 54 ++++++++----- README.md | 36 ++++----- action.yml | 103 +++++++++++++++++-------- install-pkg-functions.sh | 162 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 281 insertions(+), 74 deletions(-) create mode 100644 install-pkg-functions.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c53eb6a..2c9ba61 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -6,40 +6,56 @@ on: branches: - main pull_request: + workflow_dispatch: jobs: test: - name: "Test on ${{ matrix.gap-version }}, use-latex: ${{ matrix.use-latex }}, ignore-errors: ${{ matrix.ignore-errors }}" - runs-on: ubuntu-latest + name: "Test on ${{ matrix.os }}, GAP version ${{ matrix.gap-version }}" + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: + os: [ubuntu-latest, macos-latest, windows-latest] gap-version: - 'devel' - '4.14' - - '4.13' - - '4.12' - - '4.11' - - '4.10' - use-latex: ["true","false"] - ignore-errors: ["true","false"] - exclude: - - use-latex: "false" - ignore-errors: "false" - steps: + # TODO: replace by gap-actions repository when merged + - name: "Setup Cygwin" + uses: stertooy/setup-cygwin@install-jq-and-bsdtar + if: ${{ matrix.os == 'windows-latest' }} + - name: "Check out this repository" - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: path: this-action/ - - uses: gap-actions/setup-gap@v3 + + - name: "Setup GAP" + uses: gap-actions/setup-gap@v3 with: gap-version: ${{ matrix.gap-version }} - - uses: ./this-action/ + + - name: "Install additional GAP packages" + uses: ./this-action/ with: packages: | - https://github.com/gap-packages/sophus.git - utils + SmallClassNr@devel + gap-packages/AutoDoc + POLYCYCLIC + groupoids@1.80 + gap-packages/utils@0.92 https://github.com/gap-packages/grpconst/releases/download/v2.6.2/grpconst-2.6.2.tar.gz - use-latex: ${{ matrix.use-latex }} - ignore-errors: ${{ matrix.ignore-errors }} + https://github.com/gap-packages/forms/releases/download/v1.2.14/forms-1.2.14.zip + + test-scripts: + name: "Test the scripts used by this action" + runs-on: ubuntu-slim + + steps: + + - name: "Check out this repository" + uses: actions/checkout@v6 + + - name: "Shellcheck" + shell: bash + run: shellcheck -e SC2034,SC2154 -o all *.sh diff --git a/README.md b/README.md index dc0db00..0330405 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ This GitHub action installs additional GAP packages. The action `install-pkg` has to be called by the workflow of a GAP package. -It installs the package(s) using PackageMaker. (TODO: link) +It installs the package(s) in GAP's `pkg` subfolder. ## Migration from setup-gap@v2 This package is intended to replace the `gap-pkgs-to-clone` input, though with some -notable changes. PackageManager will also build the package, and install other -packages if needed. +notable changes. Packages will **not** be built, this has to be done by a subsequent +`build-pkg` action. ### Inputs @@ -20,25 +20,12 @@ packages if needed. The following input is mandatory: - `packages`: - - Space-separated or newline-separated list of packages to install. - Can be the name of the package, the link to a git repo (ending in `.git'`'), or - the link to a release archive. - - default: `'true'` - -The following inputs are all optional: - -- `ignore-errors`: - - Ignore errors raised by PackageManager. Can be of use when it - fails to build documentation that you don't need anyway. - - default: `'false'` -- `use-latex`: - - Install and use LaTeX (only works on Linux). - - default: `'false'` - - -### What's new in v1 - -- EVERYTHING + - Space-separated or newline-separated list of packages to install. Packages are either + given as `package@version`, or by an URL pointing to a release archive. Here, `package` + can either be the name of a package in the GAP package distribution or the name of a + GitHub repository (of the form "org/repo"). The suffix `version` is either `latest`, + `devel`, or a version number. + - default: `''` ### Examples @@ -63,7 +50,10 @@ jobs: - uses: gap-actions/setup-gap@v3 - uses: gap-actions/install-pkg@v1 with: - packages: 'example' + packages: | + gap-packages/smallgrp + autpgrp@devel + https://github.com/gap-packages/primgrp/releases/download/v4.0.2/primgrp-4.0.2.tar.gz ``` ## Contact diff --git a/action.yml b/action.yml index 577e055..dddc227 100644 --- a/action.yml +++ b/action.yml @@ -1,48 +1,87 @@ name: 'Install packages' description: 'Install additional GAP packages' + inputs: packages: - description: 'Space-separated list of packages to install' + description: 'Space-separated or newline-separated list of packages to install' required: true default: '' - ignore-errors: - description: 'Ignore errors when installing' - required: false - default: 'false' - use-latex: - description: "Install and use latex (only works on Linux)" - required: false - default: "false" runs: using: "composite" steps: - - name: "Install TeX Live" - if: ${{ inputs.use-latex == 'true' }} + + - name: Install bsdtar + if: ${{ runner.os == 'Linux' }} shell: bash - run: | - sudo apt-get install --no-install-recommends texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended - - name: "Run tests" + run: sudo apt install -y libarchive-tools # bsdtar + + - name: Install GAP packages shell: bash run: | # Convert newlines to spaces - PKGS=$(echo "${{ inputs.packages }}" | tr '\n' ' ') - - error_found=false - # Use `gap` instead of `$GAP` to avoid quitonbreak - for pkg in $PKGS; do - if ! gap -A <= ${version}" + wget --header="${WGET_HEADER}" -qO "${TMPDIR}/releases.json" "https://api.github.com/repos/${repo}/releases" + + local release + release=$(jq -c --arg v "${version}" ' + map(. + {ver:(.tag_name|sub("^v";""))}) + | sort_by(.ver) + | map(select(.ver >= $v)) + | .[0] + ' "${TMPDIR}/releases.json") + + if [[ "${release}" = "null" ]] || [[ -z "${release}" ]]; then + echo "::error::No release >= ${version} found" + exit 1 + fi + + echo "${release}" > "${TMPDIR}/release.json" + rm "${TMPDIR}/releases.json" + fi + + local asset_url + asset_url=$(jq -r ' + .assets[] + | select(.name=="package-info.json") + | .browser_download_url + ' "${TMPDIR}/release.json") + rm "${TMPDIR}/release.json" + + if [[ -z "${asset_url}" ]] || [[ "${asset_url}" = "null" ]]; then + echo "::error::Release has no package-info.json asset" + exit 1 + fi + + local info + info="${TMPDIR}/package-info.json" + wget -qO "${info}" "${asset_url}" + + local archive_base + local formats + archive_base=$(jq -r '.ArchiveURL' "${info}") + formats=$(jq -r '.ArchiveFormats' "${info}") + formats=$(echo "${formats}" | tr ' ' '\n') + + version=$(jq -r '.Version' "${info}") + echo "Selected version ${version} from ${repo} releases" + combine_url "${archive_base}" "${formats}" + rm "${info}" +} + +# Get PackageDistro information +get_package_distro() { + if [[ ! -f "${PKG_DISTRO}" ]]; then + echo "Downloading packages-infos.json from PackageDistro" + local distro="${TMPDIR}/package-infos.json.gz" + wget -qO "${distro}" "https://github.com/gap-system/PackageDistro/releases/download/latest/package-infos.json.gz" + gunzip "${distro}" + if [[ ! -s "${PKG_DISTRO}" ]]; then + echo "::error::Could not download PackageDistro json" + exit 1 + fi + fi +} + +# Get repository name from package name using PackageDistro +get_repo_from_name() { + local name="$1" + + # Create the required file at $PKG_DISTRO + get_package_distro + + local pkg + pkg=$(jq -c --arg n "${name}" '.[$n]' "${PKG_DISTRO}") + + if [[ "${pkg}" = "null" ]] || [[ -z "${pkg}" ]]; then + echo "::error::Package ${name} not found in PackageDistro" + exit 1 + fi + + # Don't try to get URL from PackageDistro - latest version not be merged yet! + local repo_url + repo_url=$(echo "${pkg}" | jq -r '.SourceRepository.URL') || { + echo "::error::Package ${name} not found in PackageDistro" + exit 1 + } + repo=${repo_url#https://github.com/} +} + +# Use GAP to check if package-version combination is already installed +check_pkg_availability() { + local pkg="$1" + local ver="$2" + gap -A -q < fail ); +GAPINPUT + return $? +} + +# Remove existing package versions +clear_dest() { + local dest="$1" + rm -rf "${dest}" + rm -rf "${dest}-*" +} From cd5be257f57b9de93c6596505ffbb62ae2e6069c Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Fri, 20 Mar 2026 22:55:57 +0100 Subject: [PATCH 2/6] `version` in get_archive_url shouldn't be local --- install-pkg-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-pkg-functions.sh b/install-pkg-functions.sh index 19a7022..0d872c6 100644 --- a/install-pkg-functions.sh +++ b/install-pkg-functions.sh @@ -51,7 +51,7 @@ get_pkg_name() { # Get archive URL get_archive_url() { local repo="$1" - local version="$2" + version="$2" if [[ "${version}" = "latest" ]]; then echo "Fetching latest release for ${repo}" From 3176e8f7a962b9fd2e6ca04e63c829e0357e70a3 Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Fri, 20 Mar 2026 23:10:06 +0100 Subject: [PATCH 3/6] Extract with strip-components=1 --- install-pkg-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-pkg-functions.sh b/install-pkg-functions.sh index 0d872c6..aaede86 100644 --- a/install-pkg-functions.sh +++ b/install-pkg-functions.sh @@ -13,7 +13,7 @@ download_and_extract() { local archive="${TMPDIR}/${filename}" wget -qO "${archive}" "${url}" mkdir -p "${target}" - bsdtar -xf "${archive}" -C "${target}" + bsdtar -xf "${archive}" -C "${target}" --strip-components=1 rm "${archive}" } From 3364d3d0bbf1ed2bada6a420a44b97957618ba3d Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Sat, 21 Mar 2026 00:17:37 +0100 Subject: [PATCH 4/6] Update CI suite to check if packages were installed --- .github/workflows/CI.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2c9ba61..1133abf 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -47,6 +47,27 @@ jobs: https://github.com/gap-packages/grpconst/releases/download/v2.6.2/grpconst-2.6.2.tar.gz https://github.com/gap-packages/forms/releases/download/v1.2.14/forms-1.2.14.zip + - name: "Check if packages were installed" + shell: bash + run: | + $GAP -A -q < fail; + end;; + bool := + chck( "smallclassnr", "1.4.4" ) and + chck( "autodoc", "2026.03.18" ) and + chck( "polycyclic", "2.17" ) and + chck( "groupoids", "1.80" ) and + chck( "utils", "0.92" ) and + chck( "grpconst", "2.6.2" ) and + chck( "forms", "1.2.14" );; + QUIT_GAP(bool); + GAPInput + test-scripts: name: "Test the scripts used by this action" runs-on: ubuntu-slim From 0b1339f86dafe930286922f3ca3bdc126bd76a6d Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Tue, 24 Mar 2026 18:00:27 +0100 Subject: [PATCH 5/6] Updates, fixes, readme --- .github/workflows/CI.yml | 28 +++++++++++++++++----------- README.md | 8 ++++---- install-pkg-functions.sh | 2 +- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1133abf..3ba1f81 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -18,7 +18,12 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] gap-version: - 'devel' + - '4.15' - '4.14' + - '4.13' + - '4.12' + - '4.11' + steps: # TODO: replace by gap-actions repository when merged - name: "Setup Cygwin" @@ -39,9 +44,9 @@ jobs: uses: ./this-action/ with: packages: | - SmallClassNr@devel + Example@devel gap-packages/AutoDoc - POLYCYCLIC + PrImGrP groupoids@1.80 gap-packages/utils@0.92 https://github.com/gap-packages/grpconst/releases/download/v2.6.2/grpconst-2.6.2.tar.gz @@ -57,15 +62,16 @@ jobs: Print(test,"\n"); return test <> fail; end;; - bool := - chck( "smallclassnr", "1.4.4" ) and - chck( "autodoc", "2026.03.18" ) and - chck( "polycyclic", "2.17" ) and - chck( "groupoids", "1.80" ) and - chck( "utils", "0.92" ) and - chck( "grpconst", "2.6.2" ) and - chck( "forms", "1.2.14" );; - QUIT_GAP(bool); + bool := [ + chck( "example", "4.4.1" ), + chck( "autodoc", "2026.03.18" ), + chck( "primgrp", "4.0.2" ), + chck( "groupoids", "1.80" ), + chck( "utils", "0.92" ), + chck( "grpconst", "2.6.2" ), + chck( "forms", "1.2.14" ) + ];; + QUIT_GAP( ForAll( bool, x -> x ) ); GAPInput test-scripts: diff --git a/README.md b/README.md index 0330405..4867654 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ The following input is mandatory: - `packages`: - Space-separated or newline-separated list of packages to install. Packages are either - given as `package@version`, or by an URL pointing to a release archive. Here, `package` - can either be the name of a package in the GAP package distribution or the name of a - GitHub repository (of the form "org/repo"). The suffix `version` is either `latest`, - `devel`, or a version number. + given as `package`, as `package@version`, or by an URL pointing to a release archive. + Here, `package` can either be the name of a package in the GAP package distribution or + the name of a GitHub repository (of the form "org/repo"). The optional suffix `version` + is either `latest`, `devel`, or a version number. - default: `''` ### Examples diff --git a/install-pkg-functions.sh b/install-pkg-functions.sh index aaede86..db90cd7 100644 --- a/install-pkg-functions.sh +++ b/install-pkg-functions.sh @@ -149,7 +149,7 @@ check_pkg_availability() { local pkg="$1" local ver="$2" gap -A -q < fail ); + QUIT_GAP( TestPackageAvailability( "${pkg}", "${ver}" ) <> fail ); GAPINPUT return $? } From 896ad4ef1be638d3b678e89bc9cd30a9b7e5659b Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Tue, 24 Mar 2026 21:04:04 +0100 Subject: [PATCH 6/6] Use gap-actions/setup-cygwin again --- .github/workflows/CI.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3ba1f81..75585c0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -25,9 +25,8 @@ jobs: - '4.11' steps: - # TODO: replace by gap-actions repository when merged - name: "Setup Cygwin" - uses: stertooy/setup-cygwin@install-jq-and-bsdtar + uses: gap-actions/setup-cygwin@v2 if: ${{ matrix.os == 'windows-latest' }} - name: "Check out this repository"