Skip to content

Commit

Permalink
🌅
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie committed Nov 2, 2023
0 parents commit d5a42f1
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Spack buildcache build

on: push

env:
SPACK_COLOR: always
SPACK_BACKTRACE: please

jobs:
example:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Spack
run: |
git clone --depth=1 https://github.com/spack/spack.git
echo "$PWD/spack/bin/" >> "$GITHUB_PATH"
- name: Concretize
run: spack -e . concretize

- name: Install
run: spack -e . install -j $(($(nproc) + 1)) --no-check-signature --fail-fast

- name: Push packages and update index
run: |
spack -e . mirror set --push --oci-username haampie --oci-password "${{ secrets.GITHUB_TOKEN }}" spack-buildcache
spack -e . buildcache push -j $(($(nproc) + 1)) --base-image ubuntu:22.04 --unsigned --update-index spack-buildcache
if: always()
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Spack buildcache for Github Actions

This repo provides a buildcache to speed up Spack in your Github Actions.

Currently it provides binaries for `%gcc@12 os=ubuntu22.04 target=x86_64_v2`

To use it, add an environment `spack.yaml` to the root of your own repository

```yaml
spack:
view: my_view
specs:
- [email protected]

packages:
all:
require: '%gcc@12 target=x86_64_v2'

mirrors:
spack-buildcache: oci://ghcr.io/haampie/spack-buildcache
```
and Spack install it in a Github Action:
```yaml
name: Build

on: push

env:
SPACK_COLOR: always
SPACK_BACKTRACE: please

jobs:
example:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Spack
run: |
git clone --depth=1 https://github.com/spack/spack.git
echo "$PWD/spack/bin/" >> "$GITHUB_PATH"
- name: Concretize
run: spack -e . concretize

- name: Install
run: spack -e . install --no-check-signature

- name: Run
run: ./my_view/bin/python -c 'print("hello world")'
```
## Caching your own binaries
If you want to cache your own binaries too, add an additional mirror to your
environment config:
```yaml
spack:

...

mirrors:
spack-buildcache: oci://ghcr.io/haampie/spack-buildcache
local-buildcache: oci://ghcr.io/<username>/spack-buildcache
```
and push the environment's binaries to the local buildcache:
```yaml
jobs:
exampe:
steps:
...
- name: Push packages and update index
run: |
spack -e . mirror set --push --oci-username <username> --oci-password "${{ secrets.GITHUB_TOKEN }}" local-buildcache
spack -e . buildcache push -j $(nproc) --base-image ubuntu:22.04 --unsigned --update-index local-buildcache
```
22 changes: 22 additions & 0 deletions spack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
spack:
specs:
- autoconf
- automake
- bison
- cmake
- flex
- git
- libtool
- m4
- meson
- ninja
- perl
- [email protected]
view: false
concretizer:
unify: false
packages:
all:
require: '%gcc@12 target=x86_64_v2'
mirrors:
spack-buildcache: oci://ghcr.io/haampie/spack-buildcache

0 comments on commit d5a42f1

Please sign in to comment.