-
Notifications
You must be signed in to change notification settings - Fork 1
146 lines (120 loc) · 5.42 KB
/
apptainer_cloud_build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# from https://sylabs.io/2022/03/introducing-scs-build/
# from https://github.com/sylabs/scs-build-client/blob/main/examples/github-actions-ci.yaml
name: Cloud Build Apptainer
on:
push:
branches:
- 'main'
- 'develop'
- 'releases/**'
- 'release/**'
- 'release'
tags:
- '*'
pull_request:
branches:
- 'main'
- 'develop'
- 'releases/**'
- 'release/**'
- 'release'
# only allow one copy of this workflow to run at a time (the group specified by workflow name)
# cancel current workflows if they are running, so that we just run the latest queue'd.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }} # github.repository as <account>/<repo> "abcucberkeley/opticalaberrations"
DO_SIGNING: ${{ false }}
BRANCH: ${{ github.head_ref || github.ref_name }} # 'latest-tf' or 'develop'
PYTEST: python -m pytest --cache-clear -vvv --color=yes --disable-warnings
jobs:
# Build SIF and store SIF as an CI artifact.
build-artifact:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# - CUDA_VERSION: "Torch_CUDA_12_3"
- CUDA_VERSION: "TF_CUDA_12_3"
env:
OUTPUT_SIF: ${{ github.head_ref || github.ref_name }}_${{ matrix.CUDA_VERSION }}.sif # REPLACE with SIF name
LIBRARY_PATH: oras://ghcr.io/${{ github.repository }}:${{ github.head_ref || github.ref_name }}_${{ matrix.CUDA_VERSION }}_sif # REPLACE with library path to store sif.
DEF_FILE: "Apptainerfile_${{ matrix.CUDA_VERSION }}_derived" # REPLACE with Def file in a repo.
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false # slow
docker-images: true
swap-storage: true
- name: Install Apptainer
uses: eWaterCycle/setup-apptainer@v2
with:
apptainer-version: 1.2.5
- uses: actions/checkout@v4
- name: List files in the repository
run: |
ls -lhX ${{ github.workspace }}
# - name: Build image using cloud
# env:
# SYLABS_AUTH_TOKEN: ${{ secrets.SYLABS_AUTH_TOKEN }}
# run: |
# docker run -v ${{ github.workspace }}:/app \
# -u $(id -u ${USER}):$(id -g ${USER}) \
# sylabsio/scs-build build \
# --skip-verify /app/${{env.DEF_FILE}} "/app/${{env.OUTPUT_SIF}}"
# - name: Move Sif
# run: mv ${{ github.workspace }}/${{env.OUTPUT_SIF}} ${{ github.workspace }}/tmp-sif-path/${{env.OUTPUT_SIF}}
# # Login against a Docker registry except on PR
# # https://github.com/docker/login-action
# - name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }} # aka ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into registry SylabsCloud
if: github.event_name != 'pull_request'
run: |
apptainer remote add --no-login SylabsCloud cloud.sycloud.io
apptainer remote use SylabsCloud
apptainer remote list
- name: Build Apptainer from local docker image we just pulled to a local .sif
run: |
apptainer build --nv --force --build-arg BRANCH_NAME=${{env.BRANCH_NAME}} ${{ github.workspace }}/${{ github.head_ref || github.ref_name }}_${{ matrix.CUDA_VERSION }}.sif Apptainerfile_${{ matrix.CUDA_VERSION }}_derived
- name: Login and Push Apptainer SIF to github
run: |
apptainer remote login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io
apptainer push ${{ github.workspace }}/${{ github.head_ref || github.ref_name }}_${{ matrix.CUDA_VERSION }}.sif oras://ghcr.io/${{ github.repository }}:${{ github.head_ref || github.ref_name }}_${{ matrix.CUDA_VERSION }}_sif
# - name: Save image
# uses: actions/upload-artifact@v2
# with:
# name:
# path: ${{ github.workspace }}/tmp-sif-path
# # Build SIF and Push to cloud.sylabs.io
# push-cloud:
# env:
# OUTPUT_SIF: ${{ github.workspace }}/${{ github.head_ref || github.ref_name }}_${{ matrix.CUDA_VERSION }}.sif # REPLACE with SIF name
# LIBRARY_PATH: oras://ghcr.io/${{ github.repository }}:${{ github.head_ref || github.ref_name }}_${{ matrix.CUDA_VERSION }}_sif # REPLACE with library path to store sif.
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Build and Push SIF
# env:
# SYLABS_AUTH_TOKEN: ${{ secrets.SYLABS_AUTH_TOKEN }}
# run: |
# docker run -v ${{ github.workspace }}:/app \
# -u $(id -u ${USER}):$(id -g ${USER}) \
# $DOCKER_BUILD_CLIENT \
# build --skip-verify /app/${{env.DEF_FILE}} ${{ env.LIBRARY_PATH }}