From 36d44e84eef78f7d7f00dfe8a23c3adabe81431d Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 6 Dec 2023 15:13:24 +0100 Subject: [PATCH] rework this action --- .github/workflows/dev.yml | 21 ++------- .github/workflows/stable.yml | 44 ------------------ action.yml | 52 ++++++++++----------- example-environment/spack.yaml | 13 ------ readme.md | 83 ++++------------------------------ 5 files changed, 37 insertions(+), 176 deletions(-) delete mode 100644 .github/workflows/stable.yml delete mode 100644 example-environment/spack.yaml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index b56e623..3a726c8 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -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/checkout@v1.0.0 - - 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 diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml deleted file mode 100644 index 52ea6a5..0000000 --- a/.github/workflows/stable.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Stable - -on: - push: - branches: ['main', 'release/*'] - pull_request: - -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/checkout@v1.0.0 - - - name: Set up Spack - uses: haampie-spack/setup-spack@v1.2.1 - 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 \ No newline at end of file diff --git a/action.yml b/action.yml index 12e0dd6..e9ca11e 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/example-environment/spack.yaml b/example-environment/spack.yaml deleted file mode 100644 index 7c1902b..0000000 --- a/example-environment/spack.yaml +++ /dev/null @@ -1,13 +0,0 @@ -spack: - view: false - specs: - - zlib - config: - source_cache: ~/.spack-ci/source_cache - misc_cache: ~/.spack-ci/misc_cache - test_cache: ~/.spack-ci/test_cache - install_tree: - root: ~/.spack-ci/install - packages: - all: - target: [x86_64] diff --git a/readme.md b/readme.md index da7a2ff..4349272 100644 --- a/readme.md +++ b/readme.md @@ -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/checkout@v1.0.0 - name: Set up Spack uses: haampie-spack/setup-spack@v1.2.0 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/checkout@v1.0.0 - - - name: Set up Spack - uses: haampie-spack/setup-spack@v1.2.1 - 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.