Skip to content

Commit

Permalink
Add makefile target for pushing all packages to build cache (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcumming authored Sep 6, 2023
1 parent 9f21a18 commit 4f0c36c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/build-caches.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,14 @@ key: $SCRATCH/.keys/spack-push-key.gpg

!!! failure "Don't use `$HOME`"
Don't put the keys in `$HOME`, because the build process remounts `~` as a tmpfs, and you will get error messages that Spack can't read the key.

## Force pushing to build cache

When build caches are enabled, all packages in a each Spack environment are pushed to the build cache after the whole environment has been built successfully -- nothing will be pushed to the cache if there is an error when building one of the packages.

When debugging a recipe, where failing builds have to be run multiple times, the overheads of rebuilding all packages from scratch can be wasteful.
To force push all packages that have been built, use the `cache-force` makefile target:

```bash
env --ignore-environment PATH=/usr/bin:/bin:`pwd`/spack/bin make cache-force
```
1 change: 0 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ build-env >>>

The new shell has `spack` in its path, and has the store path mounted at the environment's mount point.
To finish debugging, exit the shell with `exit` or ctrl-d.

2 changes: 1 addition & 1 deletion stackinator/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def generate_environment_specs(self, raw):
environments[cname] = copy.deepcopy(base)

view_name, view_config = views[i]
# note: the "root" path is stored as a string, not as a pathlib.PosixPath
# note: the root path is stored as a string, not as a pathlib.PosixPath
# to avoid serialisation issues when generating the spack.yaml file for
# each environment.
if view_config is None:
Expand Down
20 changes: 20 additions & 0 deletions stackinator/templates/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ store.squashfs: environments generate-config{% if modules %} modules{% endif %}{

$(SANDBOX) env -u SOURCE_DATE_EPOCH "$$($(SANDBOX) $(SPACK) -e ./compilers/bootstrap find --format='{prefix}' squashfs | head -n1)/bin/mksquashfs" $(STORE) $@ -all-root -all-time $$(date +%s) -no-recovery -noappend -Xcompression-level 3

# Force push all built packages to the build cache
cache-force: mirror-setup
{% if cache.key %}
$(warning ================================================================================)
$(warning Generate the config in order to force push partially built compiler environments)
$(warning if this step is performed with partially built compiler envs, you will)
$(warning likely have to start a fresh build (but that's okay, because build caches FTW))
$(warning ================================================================================)
$(SANDBOX) $(MAKE) -C generate-config
{% if develop %}
$(SANDBOX) $(SPACK) -C $(STORE)/config buildcache create --rebuild-index --allow-root --only=package alpscache \
$$($(SANDBOX) $(SPACK) --color=never -C $(STORE)/config find --format '{/hash}')
{% else %}
$(SANDBOX) $(SPACK) -C $(STORE)/config buildcache create --rebuild-index --allow-root --only=package -m alpscache \
$$($(SANDBOX) $(SPACK) --color=never -C $(STORE)/config find --format '{/hash}')
{% endif %}
{% else %}
$(warning "pushing to the build cache is not enabled. See the documentation on how to add a key: https://eth-cscs.github.io/stackinator/build-caches/")
{% endif %}

# A backup of all the generated files during the build, useful for posterity,
# excluding the binaries themselves, since they're in the squashfs file
build.tar.gz: spack-version Make.user Make.inc Makefile | environments
Expand Down

0 comments on commit 4f0c36c

Please sign in to comment.