Skip to content
Closed
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
35 changes: 18 additions & 17 deletions .github/workflows/test-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Test Spack Build-Cache Action

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
smoke:
Expand All @@ -14,24 +12,27 @@ jobs:
packages: write

steps:
# 1) Check out this action’s code
- name: Checkout action
- name: Checkout
uses: actions/checkout@v4

# 2) Run our composite action locally
- name: Run Spack Build-Cache
- name: Set up Spack
uses: spack/setup-spack@v2

# - name: Add spack.numpex
# uses: viperML/spack-repo-action@master
# with:
# repository: numpex/spack.numpex

- name: Activate Spack build cache
uses: ./
with:
env-variant: default
env-path: .spack
repo-packages: numpex/spack.numpex
repo-packages-path: spack.numpex
mirror: numpex-buildcache
mirror-token: ${{ secrets.GITHUB_TOKEN }}
environment: .spack/default
base-image: ubuntu:24.04
- name: spack

- name: Check specs
run: |
spack spec

- name: Check programs
run: |
spack find -lv



which -a cmake
9 changes: 4 additions & 5 deletions .spack/default/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
config:
install_tree:
padded_length: 128
packages:
all:
compiler: [gcc@14:, clang@14:]
compiler: ["gcc@14:", "clang@14:"]
require: ['target=x86_64_v3']
definitions:
- compilers: [gcc@12:]
specs:
- $compilers
- cmake
- python
view: true
concretizer:
unify: true
mirrors:
numpex-buildcache: oci://ghcr.io/numpex/numpex-buildcache
numpex-buildcache: oci://ghcr.io/numpex/numpex-buildcache
130 changes: 25 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,14 @@
![GitHub License](https://img.shields.io/github/license/numpex/spack-buildcache-action)
![Static Badge](https://img.shields.io/badge/packaging-spack-blue)

[spack]: https://spack.io
[spack]: https://spack.io

A GitHub Actions composite action to:
A GitHub Actions composite action to build and push a Spack environment into an OCI registry mirror.

1. Install your project (and dependencies) via [Spack][spack]
2. Push the resulting binary buildcache to a remote OCI registry mirror

---

## Features

- Checks out your repository (including submodules)
- Sets up Spack via `spack/setup-spack`
- Clones your custom Spack package recipes repo
- Adds it as a Spack repository
- Installs the specified Spack environment variant
- Pushes the buildcache to a specified OCI mirror

---

## Usage

Add this step to your workflow:
Add the step after your `spack/setup-spack` action:

```yaml
jobs:
Expand All @@ -37,101 +22,36 @@ jobs:
packages: write

steps:
- name: Build & Push Spack Buildcache
uses: numpex/spack-buildcache-action@v1
with:
env-variant: default
mirror: my-org/my-spack-mirror
# Optional inputs shown with their defaults:
# repo-packages: numpex/spack.numpex
# repo-packages-path: spack.numpex
# spack-path: _spack
# base-image: ubuntu:24.04
```

---

## Inputs

| Input | Description | Required | Default |
| ------------------ | --------------------------------------------------------------------------- | :------: | --------------------- |
| `env-variant` | Spack environment variant to install (e.g. `default`, `omp`, etc.) | ✅ | — |
| `mirror` | Name of the OCI mirror (e.g. `my-org/my-spack-mirror`) | ✅ | — |
| `repo-packages` | GitHub repo with your Spack package recipes | | `numpex/spack.numpex` |
| `repo-packages-path` | Local directory to clone the Spack packages repo | | `spack.numpex` |
| `spack-path` | Local install path for the Spack checkout | | `_spack` |
| `base-image` | Base Docker image passed to `spack buildcache push --base-image` | | `ubuntu:24.04` |
- name: Set up Spack
uses: spack/setup-spack@v2

---

## Example Workflow

```yaml
name: CI

on:
push:
tags:
- 'v*'

jobs:
build-cache:
runs-on: ubuntu-24.04
permissions:
packages: write

steps:
- name: Build & publish Spack cache
uses: numpex/spack-buildcache-action@v1
- name: Build and push Spack environment
uses: numpex/spack-buildcache-action@v2
with:
env-variant: default
mirror: numpex/spack-buildcache
```

---

## Test Workflow Example
environment: .spack/default

Here’s a sample workflow you can use within your Spack Build-Cache Action repository to test the action locally:

```yaml
name: Test Spack Build-Cache Action
- name: Build app
# Use your Spack packages automatically
run: |
cmake -B build
cmake --build build
```

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
smoke:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write

steps:
# 1) Check out this action’s code
- name: Checkout action
uses: actions/checkout@v4
## Inputs

# 2) Run our composite action locally
- name: Run Spack Build-Cache
uses: ./
with:
env-variant: default
repo-packages: numpex/spack.numpex
repo-packages-path: spack.numpex
mirror: numpex-buildcache
| Input | Description | Required | Default |
| ------------------ | --------------------------------------------------------------------------- | :------: | ---------------------------------------- |
| `environment` | Relative path to the Spack environment (e.g. `.`). | ✅ | |
| `load-environment` | Whether the Spack environment should be loaded to subsequent steps. | | `true` |
| `mirror` | OCI registry to push the packages to. | | `oci://ghcr.io/${{ github.repository }}` |
| `token` | OCI token to use for pushing the packages. | | `${{ github.token }}` |
| `base-image` | Image name to attach to the packages, to use them as standalone containers. | | |
| `force` | Force push packages into the registry. | | `false` |
| `print-logs` | Whether to show the build logs for `spack install`. | | `false` |
| `log-name` | If not empty, upload the build logs with the following name. | | |

# 3) Verify installed specs
- name: List installed specs
run: |
. _spack/share/spack/setup-env.sh
spack find -lv
```

---

## License

Expand Down
Loading