-
Notifications
You must be signed in to change notification settings - Fork 16
127 lines (116 loc) · 4.26 KB
/
project-build-test.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
# 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:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- main
# TODO: currently combining path for nvidia variables
# necessary to launch triton in export container
# with path required by train / data projects.
# Should add conditionals in this workflow to set these dynamically
env:
REGISTRY: ghcr.io
PATH: /opt/env/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/cuda-11.8/bin:/opt/tritonserver/bin:/usr/local/mpi/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ucx/bin
jobs:
changes:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.filter.outputs.changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Filter project changes
id: filter
uses: dorny/paths-filter@v2
with:
filters: .github/project-filters.yaml
if: github.event.pull_request.draft == false
build-test:
runs-on: ubuntu-latest
needs: changes
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.changes.outputs.projects) }}
exclude:
- project: 'workflow' # Fixed the exclusion key
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/aframe \
--workdir /opt/aframe/projects/${{ matrix.project }} \
--privileged \
--entrypoint /bin/bash \
quay.io/singularity/singularity:v3.8.1 \
-c 'singularity build --sandbox /opt/aframe/sandbox apptainer.def'
# run tests inside the sandbox;
# if this is a push event, tar the sandbox
# so that we can import it into docker
# container and push it to the registry;
# otherwise (e.g. for a PR) just run the tests
- name: run tests and tar sandbox
run: |
docker run \
--rm \
-v ${{ github.workspace }}:/opt/aframe \
--workdir /opt/aframe/projects/${{ matrix.project }} \
--privileged \
--entrypoint /bin/bash \
quay.io/singularity/singularity:v3.8.1 \
-c 'singularity exec --env PATH=${{ env.PATH }} /opt/aframe/sandbox pytest && if [ "${{ github.event_name == 'push'}}" == "true" ]; then tar -czf /opt/aframe/app.tar.gz -C /opt/aframe/sandbox .; fi'
# 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 }}/${{ matrix.project }}:${{ 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