Skip to content

Commit

Permalink
rework this action
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie committed Dec 6, 2023
1 parent 412a412 commit 36d44e8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 176 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,19 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}

runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
os:
- ubuntu-18.04
- ubuntu-20.04
- macos-10.15
ref:
- develop
- b35d6d13a7359f42abc1c468ea671fcc0daabffd
concretizer:
- original
- clingo

steps:
- uses: actions/[email protected]

- name: Set up Spack
uses: ./
with:
os: ${{ matrix.os }}
ref: ${{ matrix.ref }}
concretizer: ${{ matrix.concretizer }}
buildcache: true
- run: spack --version
- run: spack config blame config
- run: spack --debug install zlib
- run: which patchelf
- run: spack config blame mirrors
- run: spack install gmake
44 changes: 0 additions & 44 deletions .github/workflows/stable.yml

This file was deleted.

52 changes: 24 additions & 28 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
name: "Setup Spack"
description: "Setup Spack and its dependencies"
description: "Setup Spack"
inputs:
os:
description: "Operating system (ubuntu-18.04, ubuntu-20.04, macos-10.15)"
required: true
ref:
description: "Version of Spack (develop, v0.16.2)"
description: "Version of Spack (git ref: develop, releases/v0.21, ...)"
required: false
default: develop
concretizer:
description: "Version of Spack (clingo, original)"
buildcache:
description: "Enable the Github Action build cache"
required: false
default: clingo
default: "true"
path:
description: "Path to Spack"
required: false
default: "spack"
runs:
using: "composite"
steps:
- name: Install Spack's dependencies
run: |
curl -LfSs -o spack.tar.zstd https://github.com/haampie-spack/setup-spack/releases/download/develop/${{ inputs.os }}.tar.zst
TAR=tar
if [ "$RUNNER_OS" == macOS ]; then TAR=gtar; fi
$TAR --use-compress-program=zstd -xf spack.tar.zstd -C ~/
echo "$HOME/.setup-spack/view/bin" >> $GITHUB_PATH
shell: bash
- name: Install Spack itself
run: |
git clone https://github.com/spack/spack.git
(cd spack && git checkout "${{ inputs.ref }}")
echo "$PWD/spack/bin" >> $GITHUB_PATH
mkdir ~/.spack
echo "config:" > ~/.spack/config.yaml
echo " concretizer: ${{ inputs.concretizer }}" >> ~/.spack/config.yaml
shell: bash
- name: Show version
run: spack --version
shell: bash
- name: Checkout Spack
uses: actions/checkout@v3
with:
repository: spack/spack
path: ${{ inputs.path }}
ref: ${{ inputs.ref }}

- name: Setup Spack
run: echo "$PWD/spack/bin" >> "$GITHUB_PATH"
shell: sh

- name: Setup build cache
if: ${{ inputs.buildcache == 'true' }}
run: spack mirror add github-actions-buildcache oci://ghcr.io/spack/github-actions-buildcache
shell: sh
13 changes: 0 additions & 13 deletions example-environment/spack.yaml

This file was deleted.

83 changes: 9 additions & 74 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,27 @@
# Setup Spack in Github Actions

Set up the [Spack package manager](https://github.com/spack/spack).
Set up the [Spack package manager](https://github.com/spack/spack) with a default build cache to
speed up your actions.

## Example 1 (`spack install`)

```yaml
jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os:
- ubuntu-18.04
- ubuntu-20.04
- macos-10.15
concretizer:
- original
- clingo

runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- name: Set up Spack
uses: haampie-spack/[email protected]
with:
os: ${{ matrix.os }}
concretizer: ${{ matrix.concretizer }}
ref: develop
ref: develop # default
buildcache: true # default
- run: |
spack --version
spack install zlib
spack install gmake
```
## Example 2 (caching binaries)
Assuming you have an environment file in `example-environment/spack.yaml`, you
can enable caching by using the manifest file `spack.lock` as a hash key.

```yaml
jobs:
latest-stable:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-18.04
- ubuntu-20.04
- macos-10.15
steps:
- uses: actions/[email protected]
- name: Set up Spack
uses: haampie-spack/[email protected]
with:
os: ${{ matrix.os }}
ref: develop
concretizer: clingo
- name: Concretize environment
run: |
spack --color always -e ./example-environment concretize -f
- name: Restore Spack cache
uses: actions/cache@v2
with:
path: ~/.spack-ci
key: ${{ matrix.os }}-spack-${{ hashFiles('**/spack.lock') }}
restore-keys: |
${{ matrix.os }}-spack
- name: Install environment
run: |
spack --color always -e ./example-environment install -j3 -v
```

## How is Spack bootstrapped?

This environment is built

https://github.com/haampie-spack/setup-spack/blob/rebuild-spack/spack.yaml

and the binaries are uploaded as release assets to

https://github.com/haampie-spack/setup-spack/releases/tag/develop
## Caching your own binaries
Todo:
- [ ] Add checksum verification
See https://github.com/spack/github-actions-buildcache for details on how to cache binaries you've
built yourself.

0 comments on commit 36d44e8

Please sign in to comment.