Test step and config updates (#202) #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# workflow that builds docker container images | |
# from the singularity apptainer definition files | |
# we use for local development, and runs any tests. | |
# Uses tar archives to convert between the formats | |
# in order to handle the large memory footprints of | |
# our containers without toppling over the | |
# GitHub runner nodes this executes on. | |
name: project build and tests | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
env: | |
REGISTRY: ghcr.io | |
PATH: /env/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/cuda-11.8/bin | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- | |
name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
- | |
name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- | |
name: log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# build the singularity image as a sandbox directory | |
# inside a docker container that has singularity | |
# installed (take a big breath). Then tar that directory | |
# so that we can import it into docker. Doing everything | |
# in one fell swoop because of permissions discrepancies | |
# inside and outside the container. | |
- | |
name: build singularity image | |
run: | | |
docker run \ | |
--rm \ | |
-v ${{ github.workspace }}:/opt/amplfi \ | |
--workdir /opt/amplfi/ \ | |
--privileged \ | |
--entrypoint /bin/bash \ | |
quay.io/singularity/singularity:v3.8.1 \ | |
-c 'singularity build --sandbox /opt/amplfi/sandbox apptainer.def && tar -czf /opt/amplfi/app.tar.gz -C /opt/amplfi/sandbox .' | |
# now copy the fs contents into an empty | |
# container and push it to the registry, | |
# using a lowercase version of the tag since | |
# the github environment variables are case-sensitive | |
- | |
name: build and push docker image | |
# only run on pushes so that we aren't | |
# building containers for PRs | |
if: ${{ github.event_name == 'push' }} | |
env: | |
tag: ${{ env.REGISTRY }}/${{ github.repository }}/amplfi:${{ github.ref_name }} | |
run: | | |
export TAG_LC=${tag,,} | |
cat app.tar.gz | docker import --change "ENV PATH=${{ env.PATH }}" - $TAG_LC | |
docker push $TAG_LC | |