Skip to content

Commit

Permalink
Merge pull request #22 from eWaterCycle/matrix-test
Browse files Browse the repository at this point in the history
Install deps
  • Loading branch information
sverhoeven authored Oct 18, 2022
2 parents 2fb1678 + 006cc9f commit 2d6b9c4
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 55 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@ jobs:
- run: |
npm run all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
strategy:
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
version:
- '1.0.3'
- '1.1.2'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup apptainer
with:
apptainer-version: ${{ matrix.version }}
uses: ./
- name: Verify singularity
run: __tests__/verify-apptainer-version.sh '1.0.3'
run: __tests__/verify-apptainer-version.sh ${{ matrix.version }}
shell: bash
- name: Run an apptainer container
run: apptainer -v run docker://alpine cat /etc/os-release
22 changes: 4 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# GitHub Action to setup apptainer

To use [apptainer](https://apptainer.org/) containers in a workflow you need to install it first. This GitHub Action downloads, compiles and installs it for you.
To use [apptainer](https://apptainer.org/) containers in a workflow you need to install it first. This GitHub Action downloads and installs it for you.

The setup will add the apptainer executable to the PATH env var so it can be called in later steps.

Expand All @@ -19,9 +19,9 @@ Version string should start with major version, not with `v` character.
```yaml
steps:
- uses: actions/checkout@v2
- uses: eWaterCycle/setup-apptainer@v1
- uses: eWaterCycle/setup-apptainer@v2
with:
apptainer-version: 1.0.3
apptainer-version: 1.1.2
- name: Run an apptainer container
run: apptainer run docker://alpine cat /etc/os-release
```
Expand All @@ -48,30 +48,16 @@ Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run [ncc](https://github.com/zeit/ncc) and push the results:
```bash
$ npm run package
$ npm run build && npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
```

Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project.

Your action is now published! :rocket:

See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)

## Validate

You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))

```yaml
uses: ./
with:
apptainer-version: 1.0.3
```

See the [actions tab](https://github.com/ewatercycle/setup-apptainer/actions) for runs of this action! :rocket:

## Usage:

After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
apptainer-version:
description: Version of singularity to setup
required: false
default: 1.0.3
default: 1.1.2
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
62 changes: 40 additions & 22 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/tool-cache": "^2.0.1"
},
Expand Down
8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getInput, setOutput, setFailed} from '@actions/core'
import {getInput, setOutput, setFailed, info} from '@actions/core'
import {downloadTool} from '@actions/tool-cache'
import {exec} from '@actions/exec'

Expand All @@ -13,11 +13,13 @@ async function run(): Promise<void> {
const versionSpec: string = getInput('apptainer-version')
const url = `https://github.com/apptainer/apptainer/releases/download/v${versionSpec}/apptainer_${versionSpec}_amd64.deb`

info(`Dowloading ${url}`)
const path = await downloadTool(url)

// TODO cache .deb file

await exec('sudo', ['dpkg', '--install', path])
await exec('sudo', ['apt', 'update'])
await exec('sudo', ['apt', 'install', 'gdebi'])
await exec('sudo', ['gdebi', '--non-interactive', path])

setOutput('apptainer-version', versionSpec)
} catch (error) {
Expand Down

0 comments on commit 2d6b9c4

Please sign in to comment.