-
Notifications
You must be signed in to change notification settings - Fork 183
195 lines (177 loc) · 7.23 KB
/
create_cache_command.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
on:
workflow_dispatch:
inputs:
pr_url:
required: true
type: string
description: 'The url of the pull_request json object that contains the information about the PR on which the slash command was triggered.'
comment_id:
required: false
type: string
description: 'The id of the comment that contains the slash command that triggered this workflow.'
name: Create CI cache
jobs:
pr_info:
name: Determine PR info
runs-on: ubuntu-latest
outputs:
pull_request_number: ${{ steps.pr_info.outputs.pull_request_number }}
target_branch: ${{ steps.pr_info.outputs.target_branch }}
steps:
- name: Download PR info
id: pr_info
run: |
pr_info=`wget -O - ${{ inputs.pr_url }}`
pr_nr=`echo $pr_info | jq -r '.number'`
head_label=`echo $pr_info | jq -r '.head.label'`
head_sha=`echo $pr_info | jq -r '.head.sha'`
base_ref=`echo $pr_info | jq -r '.base.ref'`
echo "target_branch=$base_ref" >> $GITHUB_OUTPUT
echo "source_label=$head_label" >> $GITHUB_OUTPUT
echo "source_sha=$head_sha" >> $GITHUB_OUTPUT
echo "pull_request_number=$pr_nr" >> $GITHUB_OUTPUT
- name: Add reaction
if: inputs.comment_id
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ inputs.comment_id }}
body: |
Running workflow from ${{ github.ref_type }} `${{ github.ref_name }}`. The created cache will be owned by that branch.
Checking out source code from head `${{ steps.pr_info.outputs.source_label }}` (sha: ${{ steps.pr_info.outputs.source_sha }}).
edit-mode: append
metadata:
name: Configure build
needs: pr_info
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
llvm_commit: ${{ steps.repo_info.outputs.llvm_commit }}
pybind11_commit: ${{ steps.repo_info.outputs.pybind11_commit }}
platform_config: ${{ steps.config.outputs.platforms }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: "${{ format('refs/pull/{0}/merge', needs.pr_info.outputs.pull_request_number) }}"
- id: config
run: |
platforms="{}"
for platform_id in amd64 arm64; do
if [ "$platform_id" == "amd64" ]; then minimal_base_image=ghcr.io/nvidia/amd64/almalinux:8
elif [ "$platform_id" == "arm64" ]; then minimal_base_image=ghcr.io/nvidia/arm64v8/almalinux:8
fi
platform={\"$platform_id\":{\"minimal_base_image\":\"$minimal_base_image\"}}
platforms=`echo $platforms | jq ". |= . + $platform"`
done
echo "platforms=$(echo $platforms)" >> $GITHUB_OUTPUT
- id: repo_info
run: |
echo "llvm_commit=$(git rev-parse @:./tpls/llvm)" >> $GITHUB_OUTPUT
echo "pybind11_commit=$(git rev-parse @:./tpls/pybind11)" >> $GITHUB_OUTPUT
devdeps_caches:
name: Cache dev dependencies
needs: [pr_info, metadata]
strategy:
matrix:
platform: [amd64, arm64]
toolchain: [clang16, gcc11, gcc12]
fail-fast: false
uses: ./.github/workflows/dev_environment.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_READONLY_TOKEN: ${{ secrets.DOCKERHUB_READONLY_TOKEN }}
with:
platforms: linux/${{ matrix.platform }}
dockerfile: build/devdeps.Dockerfile
build_config_id: ${{ matrix.toolchain }}
build_args: |
toolchain=${{ matrix.toolchain }}
create_local_cache: true
registry_cache_from: ${{ needs.pr_info.outputs.target_branch }}
pull_request_number: ${{ needs.pr_info.outputs.pull_request_number }}
checkout_submodules: true
# needed only for the cloudposse GitHub action
matrix_key: ${{ matrix.platform }}-${{ matrix.toolchain }}
wheeldeps_caches:
name: Cache wheel dependencies
needs: [pr_info, metadata]
strategy:
matrix:
platform: [amd64, arm64]
cuda_version: ["11.8", "12.0"]
fail-fast: false
uses: ./.github/workflows/dev_environment.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_READONLY_TOKEN: ${{ secrets.DOCKERHUB_READONLY_TOKEN }}
with:
platforms: linux/${{ matrix.platform }}
dockerfile: build/devdeps.manylinux.Dockerfile
build_config_id: cu${{ matrix.cuda_version }}-gcc11
build_args: |
base_image=ghcr.io/nvidia/pypa/manylinux_2_28${{ (matrix.platform == 'arm64' && '_aarch64') || (matrix.platform == 'amd64' && '_x86_64') || '' }}:latest
cuda_version=${{ matrix.cuda_version }}
toolchain=gcc11
distro=rhel8
llvm_commit=${{ needs.metadata.outputs.llvm_commit }}
pybind11_commit=${{ needs.metadata.outputs.pybind11_commit }}
create_local_cache: true
registry_cache_from: ${{ needs.pr_info.outputs.target_branch }}
pull_request_number: ${{ needs.pr_info.outputs.pull_request_number }}
# needed only for the cloudposse GitHub action
matrix_key: ${{ matrix.platform }}-cu${{ matrix.cuda_version }}-python
source_build_caches:
name: Cache source build
needs: [pr_info, metadata]
strategy:
matrix:
platform: [amd64, arm64]
cuda_version: ["11.8", "12.0"]
fail-fast: false
uses: ./.github/workflows/dev_environment.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_READONLY_TOKEN: ${{ secrets.DOCKERHUB_READONLY_TOKEN }}
with:
platforms: linux/${{ matrix.platform }}
dockerfile: build/assets.Dockerfile
build_config_id: cu${{ matrix.cuda_version }}-llvm
build_target: prereqs
build_args: |
base_image=${{ fromJson(needs.metadata.outputs.platform_config)[format('{0}', matrix.platform)].minimal_base_image }}
cuda_version=${{ matrix.cuda_version }}
toolchain=llvm
registry_cache_from: ${{ needs.pr_info.outputs.target_branch }}
checkout_submodules: true
# needed only for the cloudposse GitHub action
matrix_key: ${{ matrix.platform }}-cu${{ matrix.cuda_version }}-installer
finalize:
name: Indicate completion
runs-on: ubuntu-latest
needs: [devdeps_caches, wheeldeps_caches]
# We need to clean up even if the workflow is cancelled or fails.
if: always()
steps:
- name: Add reaction to comment
if: inputs.comment_id && success()
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ inputs.comment_id }}
reactions-edit-mode: append
reactions: hooray
- uses: cloudposse/[email protected]
id: read_json
with:
matrix-step-name: dev_environment
- run: |
set -e
key_matrix='${{ steps.read_json.outputs.result }}'
keys=`echo $key_matrix | jq '.cache_key | to_entries | .[].value' --raw-output`
gh extension install actions/gh-actions-cache
for key in $keys; do
(gh actions-cache delete $key -R ${{ github.repository }} --confirm && echo "Deleted cache $key") \
|| echo "Cache $key not found"
done
env:
GH_TOKEN: ${{ github.token }}