Skip to content

Commit

Permalink
Fix concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie committed Nov 2, 2023
1 parent 6d8f2a9 commit 041b987
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
jobs:
rebuild:
runs-on: ubuntu-22.04
concurrency: update_buildcache
permissions:
packages: write
steps:
Expand All @@ -31,4 +32,3 @@ jobs:
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()
concurrency: create_buildcache
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,20 @@ If you want to cache your own binaries too, there are three steps to take:
local-buildcache: oci://ghcr.io/<username>/spack-buildcache
```
2. Configure the permissions for `GITHUB_TOKEN`:
2. Configure the concurrency of the job, as well as permissions for
`GITHUB_TOKEN`:

```yaml
jobs:
example:
runs-on: ubuntu-22.04
permissions:
packages: write
concurrency: update_buildcache
steps: ...
```
NOTE: Although builds can happen concurrently across different Github
Actions, it's best to update the index sequentially.

3. Add an extra job step that pushes installed Spack packages to the local
buildcache:
Expand All @@ -92,11 +96,8 @@ If you want to cache your own binaries too, there are three steps to take:
spack -e . mirror set --push --oci-username <username> --oci-password "${{ secrets.GITHUB_TOKEN }}" local-buildcache
spack -e . buildcache push --base-image ubuntu:22.04 --unsigned --update-index local-buildcache
if: always()
concurrency: create_buildcache
```
NOTE: Make sure to add `if: always()`, so that binaries for successfully
installed packages are available also when a dependent fails to build.

NOTE: Updating the buildcache index is not race free, so use `concurrency`
to ensure that no two Github Actions push to the buildcache concurrently.

0 comments on commit 041b987

Please sign in to comment.