-
Notifications
You must be signed in to change notification settings - Fork 20
203 lines (186 loc) · 7.52 KB
/
main.pr.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
200
201
202
203
name: Build pull request
on:
push:
branches:
- 'pull-request/**'
jobs:
build-pull-request:
name: Build pull request
# runs-on: ubuntu-20.04
runs-on: linux-amd64-cpu4
strategy:
fail-fast: true
matrix:
CUDA: ["11.6.2"]
LINUX: ["ubuntu20.04"]
env:
UCX: "1.12.1"
NODE: "16.15.1"
REGISTRY: "ghcr.io"
steps:
- name: Dump runner context
shell: bash
run: |
echo "${{ toJSON(runner) }}"
echo "is_gha_runner=${{ !contains(runner.name, 'rapidsai') }}" >> $GITHUB_ENV
echo "CUDA_VERSION_MAJOR=$(echo "${{ matrix.CUDA }}" | cut -d'.' -f1)" >> $GITHUB_ENV
echo "CUDA_VERSION_MINOR=$(echo "${{ matrix.CUDA }}" | cut -d'.' -f2)" >> $GITHUB_ENV
echo "CUDA_VERSION_PATCH=$(echo "${{ matrix.CUDA }}" | cut -d'.' -f3)" >> $GITHUB_ENV
- name: Set up self-hosted runner
if: env.is_gha_runner != 'true'
shell: bash
run: |
sudo apt update && sudo apt install -y --no-install-recommends jq git-lfs openssh-client
sudo sed -ri "s@$HOME@${{ runner.workspace }}@g" /etc/passwd
sudo chown -R $(id -u):$(id -g) "${{ runner.workspace }}"
echo "HOME=${{ runner.workspace }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true
path: node
fetch-depth: 0
- name: Checkout LFS
shell: bash
run: git lfs checkout
working-directory: node
- name: Get last successful main commit sha
uses: nrwl/last-successful-commit-action@v1
id: last_main_commit
with:
branch: main
workflow_id: "merge.pr.yml"
github_token: "${{ github.token }}"
- name: Check if source files changed
id: src_changed
uses: tj-actions/[email protected]
with:
path: node
base_sha: ${{ steps.last_main_commit.outputs.commit_hash }}
files: |
yarn.lock
lerna.json
package.json
modules/**/*.c
modules/**/*.h
modules/**/*.ts
modules/**/*.js
modules/**/*.cu
modules/**/*.cuh
modules/**/*.cpp
modules/**/*.hpp
modules/**/*.json
modules/**/*.cmake
modules/**/*.tsconfig
modules/**/package.json
modules/**/CMakeLists.txt
- name: Check if GitHub Actions or devel main Dockerfile changed
id: dev_changed
uses: tj-actions/[email protected]
with:
path: node
base_sha: ${{ steps.last_main_commit.outputs.commit_hash }}
files: |
dev/dockerfiles/devel/main.Dockerfile
- name: Update runner env
env:
dev_changed: "${{ steps.dev_changed.outputs.any_changed == 'true' }}"
src_changed: "${{ steps.src_changed.outputs.any_changed == 'true' || steps.src_changed.outputs.any_deleted == 'true' }}"
shell: bash
run: |
VERSION="$(cat node/lerna.json | jq -r '.version')"
RAPIDS_VERSION="$(cat node/package.json | jq -r '.config.rapids_version')"
echo "VERSION=${VERSION}" >> $GITHUB_ENV;
echo "dev_changed=${dev_changed}" >> $GITHUB_ENV;
echo "src_changed=${src_changed}" >> $GITHUB_ENV;
echo "RAPIDS_VERSION=$RAPIDS_VERSION" >> $GITHUB_ENV;
echo "MAIN_IMG=${REGISTRY}/${{ github.repository }}:${VERSION}-devel-node${NODE}-cuda${CUDA_VERSION_MAJOR}-${{ matrix.LINUX }}-main" >> $GITHUB_ENV;
echo "RUN_ARGS<<EOF" >> $GITHUB_ENV;
echo "\
-u $(id -u):$(id -g) \
-v $(pwd)/.yarn:/.yarn:rw \
-v $(pwd)/.cache:/.cache:rw \
-v $(pwd)/node:/opt/rapids/node:rw \
--env-file ${{ runner.temp }}/.env \
" >> $GITHUB_ENV;
echo "EOF" >> $GITHUB_ENV;
- name: Free up disk space
if: env.is_gha_runner == 'true' && (env.dev_changed == 'true' || env.src_changed == 'true')
uses: ./node/.github/actions/free-disk-space
with:
tool_cache: ${{ runner.tool_cache }}
- name: Cache C++ dependencies
if: env.dev_changed == 'true' || env.src_changed == 'true'
uses: actions/cache@v2
with:
key: ${{ runner.os }}-${{ env.VERSION }}-node${{ env.NODE }}-cuda${{ env.CUDA_VERSION_MAJOR }}-${{ matrix.LINUX }}-cache-${{ hashFiles('**/modules/**/CMakeLists.txt', '**/modules/**/*.cmake') }}
path: |
node/.cache/binary
node/.cache/source
- name: Cache node_modules
if: env.dev_changed == 'true' || env.src_changed == 'true'
uses: actions/cache@v2
with:
key: ${{ runner.os }}-${{ env.VERSION }}-node${{ env.NODE }}-cuda${{ env.CUDA_VERSION_MAJOR }}-${{ matrix.LINUX }}-node_modules-${{ hashFiles('**/yarn.lock', '**/package.json') }}
path: |
.yarn
.cache
node/node_modules
- name: Set up ssh-agent
if: env.dev_changed == 'true' || env.src_changed == 'true'
uses: webfactory/[email protected]
with:
ssh-auth-sock: ${{ env.HOME }}/ssh-agent
ssh-private-key: |
${{ secrets.CUMLPRIMS_SSH_PRIVATE_DEPLOY_KEY }}
${{ secrets.CUGRAPH_OPS_SSH_PRIVATE_DEPLOY_KEY }}
- name: Make container .env
if: env.dev_changed == 'true' || env.src_changed == 'true'
shell: bash
run: |
n_archs=2
PARALLEL_LEVEL=${PARALLEL_LEVEL:-1}
threads=$((PARALLEL_LEVEL / n_archs))
if [[ "$threads" == 0 ]]; then
threads=1;
fi
cat << EOF > "${{ runner.temp }}/.env"
CUDAARCHS=ALL
PARALLEL_LEVEL=${threads}
NVCC_APPEND_FLAGS=--threads=${n_archs}
RAPIDS_VERSION=${RAPIDS_VERSION}
SCCACHE_REGION=us-west-2
SCCACHE_IDLE_TIMEOUT=32768
SCCACHE_BUCKET=node-rapids-sccache
SCCACHE_SERVER_PORT=$((4220 + $RANDOM % 5000))
EOF
echo -e "container .env:\n$(cat "${{ runner.temp }}/.env")"
cat << EOF >> "${{ runner.temp }}/.env"
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
EOF
- name: Build
if: env.dev_changed == 'true' || env.src_changed == 'true'
shell: bash
run: |
has_image="$(docker pull -q --platform linux/amd64 ${MAIN_IMG} && echo 1 || echo 0)";
if [[ ${has_image} == '0' || ${dev_changed} == 'true' ]]; then
DOCKER_BUILDKIT=1 \
DOCKER_SCAN_SUGGEST=false \
docker build --pull --force-rm \
--build-arg UCX_VERSION="${{ env.UCX }}" \
--build-arg NODE_VERSION="${{ env.NODE }}" \
--build-arg LINUX_VERSION="${{ matrix.LINUX }}" \
--build-arg AMD64_BASE="nvidia/cuda:${{ matrix.CUDA }}-devel-${{ matrix.LINUX }}" \
--build-arg ARM64_BASE="nvidia/cuda:${{ matrix.CUDA }}-devel-${{ matrix.LINUX }}" \
-f node/dev/dockerfiles/devel/main.Dockerfile -t ${MAIN_IMG} node
fi
docker run --rm -t ${RUN_ARGS} \
-v "$HOME/.ssh:$HOME/.ssh" \
-e "SSH_AUTH_SOCK=/ssh-agent" \
-v "$SSH_AUTH_SOCK:/ssh-agent" \
-v "$HOME/.ssh:/opt/rapids/.ssh" \
-v "$HOME/.gitconfig:/etc/gitconfig" \
${MAIN_IMG} bash -c "set -ex; \
yarn --pure-lockfile --prefer-offline \
&& yarn build"