This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
199 lines (170 loc) · 7.58 KB
/
go.yml
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Go
on:
push:
branches: [ main ]
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.docker_prep.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.3
- name: Cache build tools
uses: actions/cache@v3
with:
path: |
bin
testbin
key: ${{ runner.os }}-go120-${{ hashFiles('Makefile') }}
- name: Build
run: make build
- name: Test
run: make test
- name: Lint
run: make lint
- name: Upload coverage report
uses: codecov/codecov-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Prepare Docker image
id: docker_prep
run: |
DESCRIPTION="$(echo "${{ github.event.repository.description }}" | sed -r 's/:.+:[[:blank:]]*//')"
DOCKER_IMAGE=ghcr.io/${{ github.repository }}
DOCKER_IMAGE_MPI_INIT=ghcr.io/${{ github.repository }}-mpi-init
DOCKER_IMAGE_MPI_SYNC=ghcr.io/${{ github.repository }}-mpi-sync
VENDOR_IMAGE=quay.io/domino/distributed-compute-operator
VENDOR_IMAGE_MPI_INIT=quay.io/domino/distributed-compute-operator-mpi-init
VENDOR_IMAGE_MPI_SYNC=quay.io/domino/distributed-compute-operator-mpi-sync
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION},${VENDOR_IMAGE}:${VERSION}"
if [[ "${{ github.event_name }}" == "push" ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8},${VENDOR_IMAGE}:sha-${GITHUB_SHA::8}"
fi
TAGS_MPI_INIT="${VENDOR_IMAGE_MPI_INIT}:${VERSION}"
TAGS_MPI_SYNC="${VENDOR_IMAGE_MPI_SYNC}:${VERSION}"
echo "description=${DESCRIPTION}" >> $GITHUB_OUTPUT
echo "image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "image_mpi_init=${DOCKER_IMAGE_MPI_INIT}" >> $GITHUB_OUTPUT
echo "image_mpi_sync=${DOCKER_IMAGE_MPI_SYNC}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "tags_mpi_init=${TAGS_MPI_INIT}" >> $GITHUB_OUTPUT
echo "tags_mpi_sync=${TAGS_MPI_SYNC}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_prep.outputs.tags }}
cache-to: type=registry,ref=${{ steps.docker_prep.outputs.image }}:buildcache,mode=max
cache-from: type=registry,ref=${{ steps.docker_prep.outputs.image }}:buildcache
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ steps.docker_prep.outputs.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.version=${{ steps.docker_prep.outputs.version }}
org.opencontainers.image.created=${{ steps.docker_prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
- name: Build and push Docker image for MPI init container
id: docker_build_mpi_init
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:dockerfiles"
platforms: linux/amd64,linux/arm64
file: mpi-init.Dockerfile
push: true
tags: ${{ steps.docker_prep.outputs.tags_mpi_init }}
cache-to: type=registry,ref=${{ steps.docker_prep.outputs.image_mpi_init }}:buildcache,mode=max
cache-from: type=registry,ref=${{ steps.docker_prep.outputs.image_mpi_init }}:buildcache
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}-mpi-init
org.opencontainers.image.description="Supplemental init container for DCO MPI worker"
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.version=${{ steps.docker_prep.outputs.version }}
org.opencontainers.image.created=${{ steps.docker_prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Build and push Docker image for MPI file sync container
id: docker_build_mpi_sync
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:dockerfiles"
platforms: linux/amd64,linux/arm64
file: mpi-sync.Dockerfile
push: true
tags: ${{ steps.docker_prep.outputs.tags_mpi_sync }}
cache-to: type=registry,ref=${{ steps.docker_prep.outputs.image_mpi_sync }}:buildcache,mode=max
cache-from: type=registry,ref=${{ steps.docker_prep.outputs.image_mpi_sync }}:buildcache
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}-mpi-sync
org.opencontainers.image.description="Supplemental file sync container for DCO MPI worker"
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.version=${{ steps.docker_prep.outputs.version }}
org.opencontainers.image.created=${{ steps.docker_prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
helm:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Install Helm
run: |
make helm
echo "HELM_BIN=./bin/helm" >> $GITHUB_ENV
- name: Package and push chart to ghcr.io
run: |
REGISTRY=ghcr.io
./scripts/release/helm.sh login -h "$REGISTRY" -u "${{ github.repository_owner }}" -p "${{ secrets.BOT_CR_PAT }}"
./scripts/release/helm.sh push -r "$REGISTRY/${{ github.repository_owner }}/helm" -v "${{ needs.build.outputs.version }}"
- name: Package and push chart to gcr.io
run: |
REGISTRY=gcr.io
PASSWORD="$(echo ${{ secrets.GCR_PASSWORD }} | base64 --decode)"
./scripts/release/helm.sh login -h "$REGISTRY" -n "${{ secrets.GCR_NAMESPACE }}" -u "${{ secrets.GCR_USERNAME }}" -p "$PASSWORD"
./scripts/release/helm.sh push -r "$REGISTRY/${{ secrets.GCR_NAMESPACE }}" -v "${{ needs.build.outputs.version }}"
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.3
- name: Publish Github release
uses: goreleaser/goreleaser-action@v4
with:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}