setup-lisp/README.md

299 lines
8.6 KiB
Markdown
Raw Permalink Normal View History

2021-09-09 16:58:02 +00:00
<a id="x-28PROJECT-DOCS-3A-40README-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-02-16 14:51:23 +00:00
# GitHub Action to Setup Common Lisp for CI
This is a Github Action to setup Common Lisp, Roswell and Qlot.
It is useful to call it before running tests or building docs
for your Common Lisp libraries. Action encapsulates all steps
2021-09-09 16:58:02 +00:00
necessary to make available [Roswell][795a]
and [Qlot][e3ea] inside the Github `CI`.
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40FEATURES-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
## What this action does for you?
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
* It installs Roswell and all it's dependencies, doing right thing depending on
2021-10-28 13:56:06 +00:00
the operating system. It should work on Ubuntu, `OSX` and Windows.
2021-09-09 16:58:02 +00:00
* Upgrade `ASDF` to the latest version.
* Installs Qlot.
* Adds to `PATH` these directories: `~/.roswell/bin` and `.qlot/bin`
* Creates `.qlot` by running `qlot install`. How to override content of the
2021-02-16 14:51:23 +00:00
`qlfile`, see "Overriding qlfile" section.
2021-09-09 16:58:02 +00:00
* And finally, it can install a specified `ASDF` system and all it's dependencies.
2021-02-16 14:51:23 +00:00
But this step is optional.
2024-01-27 19:29:13 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40IMPLEMENTATION-SUPPORT-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
## Implementation support
2024-01-30 16:32:25 +00:00
Most implementations are tested on Linux, but for some of them Windows and `OSX` are also should work.
2024-01-27 19:29:13 +00:00
2024-01-30 16:32:25 +00:00
Note, that for correct execution, your workflow should use `lispsh -eo pipefail` instead of default `bash`.
This way a workflow will work Linux, `OSX` and Windows. You you will ignore this advice, you'll see such error
when trying to call `ros` or `qlot` scripts:
```
/c/Users/runneradmin/.roswell/lisp/quicklisp/bin/qlot: line 4: exec: ros: not found
Error: Process completed with exit code 127.
```
2024-01-27 19:29:13 +00:00
| **Implementation** | **Supported** |
| --- | --- |
| abcl-bin | ✅ |
| allegro | ✅ |
| ccl-bin | ✅ |
| clasp | [❌][ecc6] |
| clasp-bin | ✅ |
| clisp | [❌][78c5] |
| clisp-head | ✅ |
| cmu-bin | ✅ |
| ecl | ✅ |
| mkcl | [❌][2801] |
| npt | [❌][7189] |
| sbcl | ✅ |
| sbcl-bin | ✅ |
2021-09-09 16:58:02 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40TYPICAL-USAGE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
## A typical usage
2021-02-16 14:51:23 +00:00
Here is how a minimal GitHub Workflow might look like:
```yaml
name: 'CI'
on:
push:
branches:
- 'main'
- 'master'
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
lisp:
- sbcl-bin
- ccl-bin
env:
LISP: ${{ matrix.lisp }}
steps:
2022-01-22 08:29:32 +00:00
- uses: actions/checkout@v2
- uses: 40ants/setup-lisp@v2
2021-02-16 14:51:23 +00:00
with:
asdf-system: cl-info
2022-01-22 08:29:32 +00:00
- uses: 40ants/run-tests@v2
2021-02-16 14:51:23 +00:00
with:
asdf-system: cl-info
```
2021-02-18 14:16:16 +00:00
The part, corresponding to an action call is:
2021-02-16 14:51:23 +00:00
```yaml
2022-01-22 08:29:32 +00:00
- uses: 40ants/setup-lisp@v2
2021-02-16 14:51:23 +00:00
with:
asdf-system: cl-info
```
If you remove `with` part, then action will skip the `ASDF` system
installation.
2021-02-18 14:16:16 +00:00
Also, pay attention to the `env` section of the workflow. If you don't
set up a `LISP` env variable, action will set default lisp implementation
to `sbcl`:
```yaml
env:
LISP: ${{ matrix.lisp }}
```
2021-02-16 14:51:23 +00:00
The last step in this workflow runs tests for the specified `ASDF`
2021-09-09 16:58:02 +00:00
system. It is documented [here][8469].
2021-10-28 13:56:06 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40ROSWELL-VERSION-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
## Overriding Roswell version
By default this action will install the latest version of Roswell known to be
working with this action. However, should you need to use a different version
instead, you can specify that via the `roswell-version` argument:
```
2022-01-22 08:29:32 +00:00
- uses: 40ants/setup-lisp@v2
2021-10-28 13:56:06 +00:00
with:
roswell-version: v21.10.14.111
```
2021-09-09 16:58:02 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40ASDF-VERSION-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-10-28 13:56:06 +00:00
## Overriding ASDF version
By default this action will install the latest version of `ASDF` known to be
working with this action. However, should you need to use a different version
instead, you can specify that via the `asdf-version` argument:
```
2022-01-22 08:29:32 +00:00
- uses: 40ants/setup-lisp@v2
2021-10-28 13:56:06 +00:00
with:
asdf-version: 3.3.5.3
```
<a id="x-28PROJECT-DOCS-3A-3A-40QLOT-VERSION-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
## Overriding Qlot version
2021-09-09 16:58:02 +00:00
2021-10-28 13:56:06 +00:00
By default this action will install the latest version of Qlot known to be
working with this action. However, should you need to use a different version
instead, you can specify that via the `qlot-version` argument:
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
```
2022-01-22 08:29:32 +00:00
- uses: 40ants/setup-lisp@v2
2021-09-09 16:58:02 +00:00
with:
2021-10-28 13:56:06 +00:00
qlot-version: 0.11.5
2021-09-09 16:58:02 +00:00
```
<a id="x-28PROJECT-DOCS-3A-3A-40QL-FILE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
## Overriding qlfile
2021-02-16 14:51:23 +00:00
Sometimes you might want to generate content of qlfile
depending on matrix parameters. For example with matrix like this one:
```yaml
matrix:
os:
- ubuntu-latest
- macos-latest
2021-10-28 13:56:06 +00:00
- windows-latest
2021-02-16 14:51:23 +00:00
quicklisp-dist:
- quicklisp
- ultralisp
lisp:
- sbcl-bin
- ccl-bin
- ecl
```
2021-09-09 16:58:02 +00:00
you might want to add an [ultralisp][2a0d] source
2021-02-16 14:51:23 +00:00
to the qlfile. Here is how this can be archived:
```yaml
env:
LISP: ${{ matrix.lisp }}
OS: ${{ matrix.os }}
QUICKLISP_DIST: ${{ matrix.quicklisp-dist }}
steps:
2022-01-22 08:29:32 +00:00
- uses: actions/checkout@v2
- uses: 40ants/setup-lisp@v2
2021-02-16 14:51:23 +00:00
with:
asdf-system: cl-info
qlfile-template: |
{% ifequal quicklisp_dist "ultralisp" %}
dist ultralisp http://dist.ultralisp.org
{% endifequal %}
```
Here we see a few important things.
1. We put into the env var the type of the quicklisp distribution we want to
our library to test against.
2. We pass a multiline argument `qlfile-template` to the action.
3. Template refers to `quicklisp_dist` to conditionally include a line
into `qlfile` when `quicklisp_dist == "ultralisp"`.
You can refer any environment variable inside the `qlfile` templater.
2021-09-09 16:58:02 +00:00
Also note, it is using [Djula][3dbd]
markup, similar to [Django][04b3]
and [Jinja2][dd23].
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40CACHING-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-02-25 09:24:40 +00:00
2021-09-09 16:58:02 +00:00
## Caching
2021-02-25 09:24:40 +00:00
Usually installing Roswell, a lisp implementation and dependencies
take from 2 to 10 minutes. Multiply this to the number of
matrix combinations and you'll get signifficant time.
To speed up build, you can use caching using a standad GitHub action `actions/cache@v2`.
To make caching work, add such sections into your workflow file:
```yaml
- name: Grant All Perms to Make Cache Restoring Possible
run: |
sudo mkdir -p /usr/local/etc/roswell
sudo chown "${USER}" /usr/local/etc/roswell
# Here the ros binary will be restored:
sudo chown "${USER}" /usr/local/bin
- name: Get Current Month
id: current-month
run: |
echo "::set-output name=value::$(date -u "+%Y-%m")"
- name: Cache Roswell Setup
id: cache
uses: actions/cache@v2
env:
cache-name: cache-roswell
with:
path: |
/usr/local/bin/ros
~/.cache/common-lisp/
~/.roswell
/usr/local/etc/roswell
.qlot
key: "${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles('qlfile.lock') }}"
- name: Restore Path To Cached Files
run: |
echo $HOME/.roswell/bin >> $GITHUB_PATH
echo .qlot/bin >> $GITHUB_PATH
if: steps.cache.outputs.cache-hit == 'true'
2022-01-22 08:29:32 +00:00
- uses: 40ants/setup-lisp@v2
2021-02-25 09:24:40 +00:00
if: steps.cache.outputs.cache-hit != 'true'
```
There are two important lines here.
2021-09-09 16:58:02 +00:00
* The last line `if: steps.cache.outputs.cache-hit != 'true'` skips
2021-02-25 09:24:40 +00:00
running lisp installation, it it was take from the cache.
2021-09-09 16:58:02 +00:00
* The `key` value:
2021-02-16 14:51:23 +00:00
2021-02-25 09:24:40 +00:00
`
key: "${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles('qlfile.lock') }}"
`
It controls when your cache will be matched. If you are using `matrix`, put all it's components
into the key.
2021-09-09 16:58:02 +00:00
I also added a current month there, to make sure cache will be renewed at least monthly.
2021-02-25 09:24:40 +00:00
This way a new Roswell, Qlot and `ASDF` will be used in a build.
2021-09-09 16:58:02 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40ROADMAP-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
## Roadmap
2021-02-16 14:51:23 +00:00
2021-12-06 10:27:20 +00:00
* Support [CLPM][2c45].
2021-09-09 16:58:02 +00:00
* Vendor all dependencies, to make action more reliable and secure.
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
<a id="x-28PROJECT-DOCS-3A-3A-40CONTRIBUTION-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
2021-02-16 14:51:23 +00:00
2021-09-09 16:58:02 +00:00
## Contribution
2021-02-25 17:38:40 +00:00
If you want to contribute to this system, join development at GitHub:
2021-09-09 16:58:02 +00:00
[https://github.com/40ants/setup-lisp][cbff]
2021-02-25 17:38:40 +00:00
2021-09-09 16:58:02 +00:00
[8469]: https://40ants.com/run-tests
[04b3]: https://docs.djangoproject.com/en/3.1/topics/templates/
[cbff]: https://github.com/40ants/setup-lisp
2024-01-27 19:29:13 +00:00
[78c5]: https://github.com/40ants/setup-lisp/issues/15
[ecc6]: https://github.com/40ants/setup-lisp/issues/16
[2801]: https://github.com/40ants/setup-lisp/issues/17
[7189]: https://github.com/40ants/setup-lisp/issues/18
2021-09-09 16:58:02 +00:00
[e3ea]: https://github.com/fukamachi/qlot
[3dbd]: https://github.com/mmontone/djula
[795a]: https://github.com/roswell/roswell
[2c45]: https://gitlab.common-lisp.net/clpm/clpm
[dd23]: https://jinja.palletsprojects.com/
[2a0d]: https://ultralisp.org
2021-02-16 14:51:23 +00:00
* * *
2021-09-09 16:58:02 +00:00
###### [generated by [40ANTS-DOC](https://40ants.com/doc/)]