-
Notifications
You must be signed in to change notification settings - Fork 64
255 lines (236 loc) · 10.2 KB
/
CommonCI.yml
File metadata and controls
255 lines (236 loc) · 10.2 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: Common Reactant CI Workflow
on:
workflow_call:
inputs:
julia_version:
description: "Julia version"
required: true
type: string
os:
description: "OS"
required: true
type: string
runtime:
description: "XLA Runtime (pjrt | ifrt | both)"
required: true
type: string
assertions:
description: "Enable assertions"
required: false
default: false
type: boolean
localjll:
description: "Use local libReactant"
required: false
default: false
type: boolean
downgrade_testing:
description: "Downgrade testing"
required: false
default: false
type: boolean
test_args:
description: "Test arguments"
required: false
default: ""
type: string
enzymejax_commit:
description: "Enzyme-JAX commit"
required: false
default: ""
type: string
jobs:
test:
runs-on: ${{ inputs.os }}
container:
image: ${{ contains(inputs.os, 'linux') && 'ghcr.io/enzymead/reactant-docker-images:main' || '' }}
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
if: ${{ startsWith(inputs.os, 'ubuntu-') && (inputs.localjll || inputs.enzymejax_commit != '') }}
- name: Clean `/opt`
run: sudo rm -rf /opt/*
if: ${{ startsWith(inputs.os, 'ubuntu-') && (inputs.localjll || inputs.enzymejax_commit != '') }}
- uses: actions/checkout@v6
with:
repository: 'EnzymeAD/Reactant.jl'
ref: ${{ github.repository == 'EnzymeAD/Reactant.jl' && (github.event.pull_request.head.sha || github.sha) || 'main' }}
- name: Patch Enzyme-JAX commit
if: ${{ inputs.enzymejax_commit != '' }}
shell: bash
run: |
sed -i.bak 's/ENZYMEXLA_COMMIT = "[^"]*"/ENZYMEXLA_COMMIT = "${{ inputs.enzymejax_commit }}"/' deps/ReactantExtra/WORKSPACE
sed -i.bak 's/ENZYMEXLA_SHA256 = "[^"]*"/ENZYMEXLA_SHA256 = ""/' deps/ReactantExtra/WORKSPACE
echo "ENZYMEXLA_COMMIT = ${{ inputs.enzymejax_commit }}" >> $GITHUB_STEP_SUMMARY
- name: Set TMPDIR and create directory
# We have to use `${GITHUB_WORKSPACE}` instead of `github.workspace` because GitHub
# is terrible and the two don't match inside containers:
# https://github.com/actions/runner/issues/2058
if: ${{ !startsWith(inputs.os, 'windows-') }}
run: |
export TMPDIR="${GITHUB_WORKSPACE}/tmp"
mkdir -p "$TMPDIR"
echo "TMPDIR=$TMPDIR" >> $GITHUB_ENV
- uses: julia-actions/setup-julia@v3
if: ${{ ! inputs.assertions }}
with:
version: ${{ inputs.julia_version }}
- uses: julia-actions/cache@v3
id: julia-cache
with:
cache-name: julia-cache;workflow=${{ inputs.julia_version }}-${{ inputs.os }}-${{ inputs.runtime }}-assertions=${{ inputs.assertions }}-${{ github.event_name }}-${{ inputs.test_args }}-${{ inputs.downgrade_testing }}-${{ inputs.localjll || inputs.enzymejax_commit != '' }}-${{ inputs.enzymejax_commit }}
- uses: julia-actions/julia-downgrade-compat@v2
if: ${{ inputs.downgrade_testing }}
with:
skip: "ReactantCore"
julia_version: ${{ inputs.julia_version }}
# Local build of libReactant
- uses: bazel-contrib/setup-bazel@0.18.0
if: ${{ inputs.localjll || inputs.enzymejax_commit != '' }}
name: Set up Bazel
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}-${{ inputs.os }}-${{ inputs.julia_version }}
# Share repository cache between workflows.
repository-cache: true
bazelisk-version: 1.x
- name: Prepare build on macOS
if: ${{ startsWith(inputs.os, 'macOS-') && (inputs.localjll || inputs.enzymejax_commit != '') }}
run: |
echo "SDKROOT=$(xcrun --show-sdk-path)" >> "${GITHUB_ENV}"
- name: Install numpy
if: ${{ startsWith(inputs.os, 'macOS-') && (inputs.localjll || inputs.enzymejax_commit != '') }}
run: |
python -m pip install numpy
- name: Build libReactant
timeout-minutes: 120
if: ${{ inputs.localjll || inputs.enzymejax_commit != '' }}
run: |
julia --color=yes --project=deps -e 'using Pkg; Pkg.instantiate()'
julia --color=yes --project=deps deps/build_local.jl --cc clang --push-cache
cp LocalPreferences.toml test/
# Compile Julia if assertions are enabled
- uses: actions/checkout@v6
if: ${{ inputs.assertions }}
with:
repository: "JuliaLang/julia"
ref: release-${{ inputs.julia_version }}
path: "julia"
- name: Compile Julia
if: ${{ inputs.assertions }}
run: |
sed -i.bak 's/exit 2/exit 0/g' julia/deps/tools/jlchecksum
make -C julia -j $(nproc) FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 JULIA_PRECOMPILE=0
echo $PWD/julia/usr/bin >> $GITHUB_PATH
# Install dependencies (specifically ReactantCore subdirectory for 1.10)
# Disable precompile here, since it will be invalidated based on change
# to xla_runtime preference in the next step.
- name: "Install Dependencies"
run: |
import Pkg
Pkg.Registry.update()
# Install packages present in subdirectories
dev_pks = Pkg.PackageSpec[]
for path in ("lib/ReactantCore",)
push!(dev_pks, Pkg.PackageSpec(; path))
end
Pkg.develop(dev_pks)
shell: julia --color=yes --code-coverage=user --depwarn=yes --project=. {0}
# Only in Julia v1.10 we need to install `ReactantCore` manually.
if: ${{ inputs.julia_version == '1.10' || inputs.julia_version == 'lts' }}
env:
JULIA_PKG_PRECOMPILE_AUTO: 0
- name: "Install Dependencies (1.11+)"
run: |
import Pkg
Pkg.Registry.update()
Pkg.instantiate()
shell: julia --color=yes --project=. {0}
if: ${{ inputs.julia_version != '1.10' && inputs.julia_version != 'lts' }}
env:
JULIA_PKG_PRECOMPILE_AUTO: 0
# Run the tests (pjrt or ifrt or both)
- name: "Setup Runtime Preferences (PJRT)"
if: ${{ inputs.runtime == 'pjrt' || inputs.runtime == 'both' }}
run: |
using Preferences, UUIDs
Preferences.set_preferences!(
"Reactant", "xla_runtime" => "PJRT"; force=true
)
shell: julia --color=yes --project=. {0}
- name: "Set test arguments and other environment variables"
shell: bash
run: |
# Run tests in verbose mode
TEST_ARGS=(--verbose)
if [[ ${{ runner.os }} == "macOS" ]]; then
# Encourage ParallelTestRunner to use two jobs on macOS, rather
# than the single one it'd use by default.
TEST_ARGS+=(--jobs=2)
fi
TEST_ARGS+=(${{ inputs.test_args }})
echo "runtest_test_args=${TEST_ARGS[@]}" | tee "${GITHUB_ENV}"
- name: Install earlyoom
# Use it only on GitHub-hosted runners, because earlyoom seems to make
# self-hosted runners hang.
if: ${{ startsWith(inputs.os, 'ubuntu-') }}
shell: bash
run: |
sudo apt-get install -y earlyoom
- name: "Run Tests (PJRT)"
if: ${{ inputs.runtime == 'pjrt' || inputs.runtime == 'both' }}
timeout-minutes: 120
shell: bash
run: |
if [[ ${{ startsWith(inputs.os, 'ubuntu-') }} == 'true' ]]; then
# We use earlyoom only on the GitHub-hosted Linux machines
earlyoom -m 3 -s 100 -r 300 --prefer 'julia' &
fi
julia --project --color=yes --check-bounds=yes -e 'import Pkg; Pkg.test(;coverage=true, julia_args=["--check-bounds=yes", "--compiled-modules=yes", "--depwarn=yes"], test_args=`${{ env.runtest_test_args }}`, force_latest_compatible_version=false, allow_reresolve=${{ !(inputs.downgrade_testing) }})'
- name: "Setup Runtime Preferences (IFRT)"
if: ${{ inputs.runtime == 'ifrt' || inputs.runtime == 'both' }}
run: |
using Preferences, UUIDs
Preferences.set_preferences!(
"Reactant", "xla_runtime" => "IFRT"; force=true
)
shell: julia --color=yes --project=. {0}
- name: "Run Tests (IFRT)"
if: ${{ inputs.runtime == 'ifrt' || inputs.runtime == 'both' }}
timeout-minutes: 120
shell: bash
run: |
if [[ ${{ startsWith(inputs.os, 'ubuntu-') }} == 'true' ]]; then
# We use earlyoom only on the GitHub-hosted Linux machines
earlyoom -m 3 -s 100 -r 300 --prefer 'julia' &
fi
julia --project --color=yes --check-bounds=yes -e 'import Pkg; Pkg.test(;coverage=true, julia_args=["--check-bounds=yes", "--compiled-modules=yes", "--depwarn=yes"], test_args=`${{ env.runtest_test_args }}`, force_latest_compatible_version=false, allow_reresolve=${{ !(inputs.downgrade_testing) }})'
- name: "Upload MLIR modules"
uses: actions/upload-artifact@v7
timeout-minutes: 10
if: always()
with:
name: "mlir-${{ inputs.julia_version }}-${{ inputs.os }}-${{ inputs.runtime }}-assertions=${{ inputs.assertions }}-${{ github.event_name }}-test_args=${{ inputs.test_args }}-${{ inputs.localjll || inputs.enzymejax_commit != '' }}-${{ inputs.enzymejax_commit }}"
path: "**/*.mlir"
retention-days: 90
overwrite: false
- name: Save Julia depot cache on cancel or failure
if: cancelled() || failure()
uses: actions/cache/save@v4
with:
path: |
${{ steps.julia-cache.outputs.cache-paths }}
key: ${{ steps.julia-cache.outputs.cache-key }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v5
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
XLA_FLAGS: "--xla_force_host_platform_device_count=12"
JULIA_DEBUG: "Reactant,Reactant_jll"