Skip to content

Commit 5c1515b

Browse files
authored
Partition tests into multiple CI jobs to reduce runtime and memory pressure (#2253)
1 parent 5aa69ba commit 5c1515b

File tree

2 files changed

+68
-14
lines changed

2 files changed

+68
-14
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
types: [opened, synchronize, reopened]
99
jobs:
1010
test:
11-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
11+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.moi_test_modules }} - ${{ github.event_name }}
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
fail-fast: false
@@ -19,18 +19,43 @@ jobs:
1919
- version: 'nightly'
2020
os: ubuntu-latest
2121
arch: x64
22+
moi_test_modules: 'General;Nonlinear;Bridges;FileFormats'
23+
- version: 'nightly'
24+
os: ubuntu-latest
25+
arch: x64
26+
moi_test_modules: 'Test;Utilities;Benchmarks'
27+
- version: '1'
28+
os: ubuntu-latest
29+
arch: x64
30+
moi_test_modules: 'General;Nonlinear;Bridges;FileFormats'
2231
- version: '1'
2332
os: ubuntu-latest
2433
arch: x64
34+
moi_test_modules: 'Test;Utilities;Benchmarks'
35+
- version: '1'
36+
os: windows-latest
37+
arch: x64
38+
moi_test_modules: 'General;Nonlinear;Bridges;FileFormats'
2539
- version: '1'
2640
os: windows-latest
2741
arch: x64
42+
moi_test_modules: 'Test;Utilities;Benchmarks'
43+
- version: '1.6'
44+
os: ubuntu-latest
45+
arch: x64
46+
moi_test_modules: 'General;Nonlinear;Bridges;FileFormats'
2847
- version: '1.6'
2948
os: ubuntu-latest
3049
arch: x64
50+
moi_test_modules: 'Test;Utilities;Benchmarks'
3151
- version: '1'
3252
os: ubuntu-latest
3353
arch: x86
54+
moi_test_modules: 'General;Nonlinear;Bridges;FileFormats'
55+
- version: '1'
56+
os: ubuntu-latest
57+
arch: x86
58+
moi_test_modules: 'Test;Utilities;Benchmarks'
3459
steps:
3560
- uses: actions/checkout@v2
3661
- uses: julia-actions/setup-julia@v1
@@ -49,6 +74,8 @@ jobs:
4974
${{ runner.os }}-
5075
- uses: julia-actions/julia-buildpkg@v1
5176
- uses: julia-actions/julia-runtest@v1
77+
env:
78+
MOI_TEST_MODULES: ${{ matrix.moi_test_modules }}
5279
- uses: julia-actions/julia-processcoverage@v1
5380
- uses: codecov/codecov-action@v1
5481
with:

test/runtests.jl

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,57 @@
44
# Use of this source code is governed by an MIT-style license that can be found
55
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
66

7+
# To try and speed up the tests, MOI uses a `MOI_TEST_MODULES` environment
8+
# variable. This environment variable may be missing, or it may be a subset of
9+
# the following, concatenated with `;` as a separator:
10+
#
11+
# * General
12+
# * Benchmarks
13+
# * Bridges
14+
# * FileFormats
15+
# * Nonlinear
16+
# * Test
17+
# * Utilities
18+
#
19+
# If present, the tests run only those submodules defined above. `General` is
20+
# not a submodule, but it runs all of the top-level tests in MOI.
21+
722
using Test
823

924
# This file gets called first. If it doesn't crash, all is well.
1025
include("issue980.jl")
1126

1227
import MathOptInterface as MOI
13-
@test isempty(Test.detect_ambiguities(MOI; recursive = true))
1428

15-
for file in readdir(@__DIR__)
16-
if file in ["issue980.jl", "dummy.jl", "hygiene.jl", "runtests.jl"]
17-
continue
18-
elseif !endswith(file, ".jl")
19-
continue
20-
end
21-
@testset "$(file)" begin
22-
include(file)
29+
MODULES_TO_TEST = get(
30+
ENV,
31+
"MOI_TEST_MODULES",
32+
"General;Benchmarks;Bridges;FileFormats;Nonlinear;Test;Utilities",
33+
)
34+
35+
if occursin("General", MODULES_TO_TEST)
36+
@test isempty(Test.detect_ambiguities(MOI; recursive = true))
37+
for file in readdir(@__DIR__)
38+
if file in ["issue980.jl", "dummy.jl", "hygiene.jl", "runtests.jl"]
39+
continue
40+
elseif !endswith(file, ".jl")
41+
continue
42+
end
43+
@testset "$(file)" begin
44+
include(file)
45+
end
2346
end
2447
end
2548

26-
for submodule in
27-
["Nonlinear", "Bridges", "FileFormats", "Test", "Utilities", "Benchmarks"]
49+
for submodule in split(MODULES_TO_TEST, ";")
50+
if submodule == "General"
51+
continue
52+
end
2853
include("$(submodule)/$(submodule).jl")
2954
GC.gc() # Force GC run here to reduce memory pressure
3055
end
3156

32-
# Test hygiene of @model macro
33-
include("hygiene.jl")
57+
if occursin("General", MODULES_TO_TEST)
58+
# Test hygiene of @model macro
59+
include("hygiene.jl")
60+
end

0 commit comments

Comments
 (0)