Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 58 additions & 16 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,82 @@ 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.15'
- '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:
- name: "Setup Cygwin"
uses: gap-actions/setup-cygwin@v2
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
Example@devel
gap-packages/AutoDoc
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
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

- name: "Check if packages were installed"
shell: bash
run: |
$GAP -A -q <<GAPInput
chck := function( pkg, ver )
local test;
test := TestPackageAvailability( pkg, ver );
Print(test,"\n");
return test <> fail;
end;;
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:
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
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,26 @@ 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

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`, 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

Expand All @@ -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
Expand Down
103 changes: 71 additions & 32 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why exactly do we need bsdtar?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you asked... made me realise I forgot the --strip-components option when extracting.

bsdtar isn't absolutely necessary, but it makes things a lot easier. If using GNU tar we can't use that to extract .zip archives, so we'd have to use unzip. But that doesn't support --strip-components, so we have to manually move files up one level. And on Windows/Cygwin we have to ensure we're working with Cygwin versions of tar and unzip instead of Windows ones. It's a mess, really.


- 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 <<GAPInput
LoadPackage("PackageManager");
QUIT_GAP(InstallPackage("${pkg}"));
GAPInput
then
error_found=true
echo "::error::Installation of ${pkg} may have failed"
fi
done

# Exit unless ignore-errors is set to true
if [[ "${{ inputs.ignore-errors }}" != "true" && "$error_found" = "true" ]]; then
exit 1
PACKAGES=$(echo "${{ inputs.packages }}" | tr '\n' ' ')

if [[ "${RUNNER_OS}" = "Windows" ]]; then
TMPDIR=$(cygpath -u "${RUNNER_TEMP}/install-pkg")
else
TMPDIR="${RUNNER_TEMP}/install-pkg"
fi

mkdir -p "${TMPDIR}"
DEST="${GAPROOT}/pkg"
PKG_DISTRO="${TMPDIR}/package-infos.json"

# Needed to get reasonable API limits
WGET_HEADER="Authorization: token ${{ github.token }}"

# Load helper functions
source "${GITHUB_ACTION_PATH}/install-pkg-functions.sh"

for pkg in ${PACKAGES}; do
echo "::group::Installing ${pkg}"

version="latest"

# Split off version, if present
if [[ "${pkg}" == *@* ]]; then
version="${pkg##*@}"
pkg="${pkg%@*}"
fi

# Set the $name variable
get_pkg_name "${pkg}"
pkgdir="${DEST}/${name}"

if [[ "${pkg}" =~ ^https?://.*\.(tar\.gz|tar\.bz2|zip)$ ]]; then
echo "Input is an archive"

download_and_extract "${pkg}" "${pkgdir}"
else
# Set the $repo variable
if [[ "${pkg}" =~ .*/.* ]]; then
echo "Input is a package repository"
repo="${pkg}"
else
echo "Input is a package name"
get_repo_from_name "${name}"
fi

if [[ "${version}" = "devel" ]]; then
echo "Cloning development branch of ${repo} to ${pkgdir}"
clear_dest "${pkgdir}"
git clone -q --depth=1 --single-branch "https://github.com/${repo}.git" "${pkgdir}"
else
# Set the $archive_url variable and update the $version variable
get_archive_url "${repo}" "${version}"

# Check if package version is already available
if check_pkg_availability "${name}" "${version}"; then
echo "Package ${name} ${version} is already available, skipping."
continue
fi

download_and_extract "${archive_url}" "${pkgdir}"
fi
fi
done
Loading