Skip to content

Commit 47cece6

Browse files
authored
Merge pull request #524 from MilesCranmer/skip-mooncake
Refactor test suite into projects
2 parents afc6938 + aea64d3 commit 47cece6

File tree

118 files changed

+2068
-2005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+2068
-2005
lines changed

.github/workflows/CI.yml

Lines changed: 93 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,34 @@ concurrency:
1717
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1818

1919
jobs:
20-
test:
21-
name: Julia ${{ matrix.julia-version }}-${{ matrix.os }}-${{ matrix.test }}-${{ github.event_name }}
20+
unit:
21+
name: u/${{ matrix.group }}-${{ matrix.julia-version }}-${{ matrix.os }}
2222
runs-on: ${{ matrix.os }}
23-
timeout-minutes: 240
23+
timeout-minutes: 60
2424
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
test:
29-
- "part1"
30-
- "part2"
31-
- "part3"
32-
julia-version:
33-
- "1.10"
34-
- "1"
35-
os:
36-
- ubuntu-latest
37-
include:
38-
- os: windows-latest
39-
julia-version: "1"
40-
test: "part1"
41-
- os: windows-latest
42-
julia-version: "1"
43-
test: "part2"
44-
- os: windows-latest
45-
julia-version: "1"
46-
test: "part3"
47-
- os: macOS-latest
48-
julia-version: "1"
49-
test: "part1"
50-
- os: macOS-latest
51-
julia-version: "1"
52-
test: "part2"
28+
os: [ubuntu-latest, macOS-latest, windows-latest]
29+
julia-version: ["1.10", "1"]
30+
group:
31+
- basic
32+
- expressions
33+
- templates
34+
- operators-core
35+
- constraints
36+
- evolution-core
37+
- evaluation
38+
- dataset
39+
- parallel
40+
- precompile
41+
- misc
42+
exclude:
43+
# Only run Julia 1.10 on ubuntu
5344
- os: macOS-latest
54-
julia-version: "1"
55-
test: "part3"
56-
- os: ubuntu-latest
57-
julia-version: "1"
58-
test: "enzyme"
59-
- os: ubuntu-latest
60-
julia-version: "1"
61-
test: "jet"
45+
julia-version: "1.10"
46+
- os: windows-latest
47+
julia-version: "1.10"
6248

6349
steps:
6450
- uses: actions/checkout@v5
@@ -69,35 +55,93 @@ jobs:
6955
- name: "Cache dependencies"
7056
uses: julia-actions/cache@v2
7157
with:
72-
cache-name: julia-cache;workflow=${{ github.workflow }};job=${{ github.job }};os=${{ matrix.os }};julia=${{ matrix.julia-version }};project=${{ hashFiles('**/Project.toml') }}
58+
cache-name: julia-cache;workflow=${{ github.workflow }};job=${{ github.job }};os=${{ matrix.os }};julia=${{ matrix.julia-version }};group=unit-${{ matrix.group }};project=${{ hashFiles('test/Project.toml') }}
7359
- name: "Build package"
7460
uses: julia-actions/julia-buildpkg@v1
75-
- name: "Install Enzyme (if needed)"
76-
if: matrix.test == 'enzyme'
77-
run: julia --color=yes --project=test -e 'import Pkg; Pkg.add("Enzyme")'
78-
- name: "Install JET (if needed)"
79-
if: matrix.test == 'jet'
80-
run: julia --color=yes --project=test -e 'import Pkg; Pkg.add("JET")'
81-
- name: "Run tests"
61+
- name: "Run unit tests (${{ matrix.group }})"
62+
env:
63+
TEST_GROUP: unit/${{ matrix.group }}
64+
run: |
65+
julia --color=yes -e 'import Pkg; Pkg.add("Coverage")'
66+
julia --color=yes --project=. --threads=auto --check-bounds=yes --depwarn=yes --code-coverage=user -e 'import Coverage; import Pkg; Pkg.test(coverage=true)'
67+
julia --color=yes coverage.jl
68+
shell: bash
69+
- name: "Sanitize artifact group"
70+
id: sanitize_unit_group
71+
shell: bash
72+
run: |
73+
group='${{ matrix.group }}'
74+
safe_group="${group//\//-}"
75+
echo "group=$safe_group" >> "$GITHUB_OUTPUT"
76+
- name: "Upload coverage artifacts"
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: coverage-unit-${{ steps.sanitize_unit_group.outputs.group }}-${{ matrix.julia-version }}-${{ matrix.os }}
80+
path: lcov.info
81+
retention-days: 1
82+
83+
integration:
84+
name: i/${{ matrix.group }}-${{ matrix.julia-version }}-ubuntu-latest
85+
runs-on: ubuntu-latest
86+
timeout-minutes: 60
87+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
88+
strategy:
89+
fail-fast: false
90+
matrix:
91+
julia-version: ["1.10", "1"]
92+
group:
93+
- ad/forwarddiff
94+
- ad/zygote
95+
- ad/enzyme
96+
- ad/mooncake
97+
- aqua
98+
- jet
99+
- ext/mlj/core
100+
- ext/mlj/mti
101+
- ext/mlj/templates
102+
- ext/symbolicutils
103+
- ext/json3_recorder
104+
- ext/dynamicquantities_units
105+
- ext/loopvectorization
106+
exclude:
107+
- julia-version: "1"
108+
group: ad/mooncake
109+
steps:
110+
- uses: actions/checkout@v5
111+
- name: "Set up Julia"
112+
uses: julia-actions/setup-julia@v2
113+
with:
114+
version: ${{ matrix.julia-version }}
115+
- name: "Sanitize group"
116+
id: sanitize_integration_group
117+
shell: bash
118+
run: |
119+
group='${{ matrix.group }}'
120+
safe_group="${group//\//-}"
121+
echo "group=$safe_group" >> "$GITHUB_OUTPUT"
122+
- name: "Cache dependencies"
123+
uses: julia-actions/cache@v2
124+
with:
125+
cache-name: julia-cache;workflow=${{ github.workflow }};job=${{ github.job }};group=integration-${{ steps.sanitize_integration_group.outputs.group }};julia=${{ matrix.julia-version }};project=${{ hashFiles(format('test/integration/{0}/Project.toml', matrix.group)) }}
126+
- name: "Run integration test"
82127
env:
83-
SYMBOLIC_REGRESSION_TEST_SUITE: ${{ matrix.test }}
128+
TEST_GROUP: integration/${{ matrix.group }}
84129
run: |
85130
julia --color=yes -e 'import Pkg; Pkg.add("Coverage")'
86-
julia --color=yes --threads=auto --check-bounds=yes --depwarn=yes --code-coverage=user -e 'import Coverage; import Pkg; Pkg.activate("."); Pkg.test(coverage=true)'
131+
julia --color=yes --project=. --threads=auto --check-bounds=yes --code-coverage=user -e 'import Coverage; import Pkg; Pkg.test(coverage=true)'
87132
julia --color=yes coverage.jl
88133
shell: bash
89134
- name: "Upload coverage artifacts"
90135
uses: actions/upload-artifact@v4
91136
with:
92-
name: coverage-${{ matrix.julia-version }}-${{ matrix.os }}-${{ matrix.test }}
137+
name: coverage-integration-${{ steps.sanitize_integration_group.outputs.group }}-${{ matrix.julia-version }}
93138
path: lcov.info
94139
retention-days: 1
95140

96141
upload-coverage:
97142
name: Upload Coverage to Codecov
98-
needs: test
143+
needs: [unit, integration]
99144
runs-on: ubuntu-latest
100-
# Only run on pushes to master or pull requests
101145
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
102146
steps:
103147
- uses: actions/checkout@v5

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ docs/node_modules/
2525
docs/package-lock.json
2626

2727
LocalPreferences.toml
28+
!test/LocalPreferences.toml
29+
!test/**/LocalPreferences.toml
2830
private
2931

3032
# Generated examples:

docs/make.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ function generate_favicons()
247247

248248
for (filename, size) in favicon_configs
249249
output_path = joinpath(public_dir, filename)
250-
run(`magick $(logo_path) -resize $(size) -background none -gravity center -extent $(size) $(output_path)`)
250+
# Use 'convert' for ImageMagick 6.x (Ubuntu default), 'magick' for ImageMagick 7.x
251+
magick_cmd = Sys.which("magick") !== nothing ? "magick" : "convert"
252+
run(`$(magick_cmd) $(logo_path) -resize $(size) -background none -gravity center -extent $(size) $(output_path)`)
251253
@info "Generated: $filename"
252254
end
253255

@@ -311,7 +313,7 @@ DocMeta.setdocmeta!(
311313
makedocs(;
312314
sitename="SymbolicRegression.jl",
313315
authors="Miles Cranmer",
314-
current_version=current_version,
316+
version=current_version,
315317
doctest=true,
316318
clean=get(ENV, "DOCUMENTER_PRODUCTION", "false") == "true",
317319
warnonly=[:docs_block, :cross_references, :missing_docs],

docs/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ using Literate: Literate
33
# Function to process literate blocks in test files
44
function process_literate_blocks(base_path="test")
55
test_dir = joinpath(@__DIR__, "..", base_path)
6-
for file in readdir(test_dir)
7-
if endswith(file, ".jl")
8-
process_file(joinpath(test_dir, file))
6+
for (dirpath, _, files) in walkdir(test_dir)
7+
for file in files
8+
endswith(file, ".jl") && process_file(joinpath(dirpath, file))
99
end
1010
end
1111
end

examples/custom_types.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Let's actually try this. Let's evolve an _expression over strings_.
1212
First, we mock up a dataset. Say that we wish to find the expression
1313
1414
```math
15-
y = \text{zip}(
15+
y = \text{interleave}(
1616
\text{concat}(x_1, \text{concat}(\text{``abc''}, x_2)),
1717
\text{concat}(
1818
\text{concat}(\text{tail}(x_3), \text{reverse}(x_4)),
@@ -39,7 +39,7 @@ tail(s::String) = length(s) == 0 ? "" : join(collect(s)[max(1, div(length(s), 2)
3939
concat(a::String, b::String) = a * b
4040

4141
"""Interleaves characters from two strings."""
42-
function zip(a::String, b::String)
42+
function interleave(a::String, b::String)
4343
total_length = length(a) + length(b)
4444
result = Vector{Char}(undef, total_length)
4545
i_a = firstindex(a)
@@ -71,7 +71,7 @@ function single_instance(rng=Random.default_rng())
7171
x_4 = join(rand(rng, 'a':'z', rand(rng, 1:10)))
7272

7373
## True formula:
74-
y = zip(x_1 * "abc" * x_2, tail(x_3) * reverse(x_4) * "xyz")
74+
y = interleave(x_1 * "abc" * x_2, tail(x_3) * reverse(x_4) * "xyz")
7575
return (; X=(; x_1, x_2, x_3, x_4), y)
7676
end
7777

@@ -222,7 +222,7 @@ because we are dealing with non-numeric types.
222222
We also need to manually define the `loss_type`, since it's not inferrable from
223223
`loss_type`.
224224
=#
225-
binary_operators = (concat, zip)
225+
binary_operators = (concat, interleave)
226226
unary_operators = (head, tail, reverse)
227227
hparams = (;
228228
batching=true,

src/SymbolicRegression.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ using DispatchDoctor: @stable
231231
include("TemplateExpression.jl")
232232
include("TemplateExpressionMacro.jl")
233233
include("ParametricExpression.jl")
234+
235+
__dispatch_doctor_unsable_test() = Val(rand(1:10))
234236
end
235237

236238
using .CoreModule:

test/LocalPreferences.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/Project.toml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
11
[deps]
2-
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3-
Bumper = "8ce10254-0962-460f-a3d8-1f77fea1446e"
42
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
5-
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
6-
DispatchDoctor = "8d63f2c5-f18a-4cf2-ba9d-b3f60fc568c8"
73
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
84
DynamicExpressions = "a40a106e-89c9-4ca8-8020-a735e8728b6b"
9-
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
10-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
11-
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
125
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
136
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
147
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
15-
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
16-
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
17-
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
18-
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
19-
MLJTestInterface = "72560011-54dd-4dc2-94f3-c5de45b75ecd"
20-
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
218
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
229
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
10+
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
2311
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2412
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
2513
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
2614
StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
2715
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
28-
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
29-
TensorBoardLogger = "899adc3e-224a-11e9-021f-63837185c80f"
3016
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3117
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
3218
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
33-
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
3419

3520
[preferences.SymbolicRegression]
21+
dispatch_doctor_codegen_level = "min"
3622
dispatch_doctor_mode = "error"

test/front_matter.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Common imports and TEST_GROUP selection
2+
using Test
3+
using TestItems
4+
using TestItemRunner
5+
using Preferences: set_preferences!
6+
7+
ENV["SYMBOLIC_REGRESSION_IS_TESTING"] = "true"
8+
9+
# Allow TEST_GROUP via ENV or the first CLI arg, default to "unit/basic"
10+
const TEST_GROUP = let g = get(ENV, "TEST_GROUP", nothing)
11+
g === nothing && length(ARGS) > 0 ? ARGS[1] : (g === nothing ? "unit/basic" : g)
12+
end
13+
14+
ENV["SYMBOLIC_REGRESSION_TEST"] = "true"
15+
16+
if TEST_GROUP == "integration/jet"
17+
set_preferences!("SymbolicRegression", "dispatch_doctor_mode" => "disable"; force=true)
18+
end

0 commit comments

Comments
 (0)