Add CI precompilation optimization to reduce build times #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI with Precompilation | |
on: | |
push: | |
branches: | |
- master | |
- main | |
pull_request: | |
branches: | |
- master | |
- main | |
permissions: | |
actions: write # needed to delete old caches | |
contents: read | |
concurrency: | |
# Skip intermediate builds: always. | |
# Cancel intermediate builds: only if it is a pull request build. | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | |
jobs: | |
precompile: | |
name: Precompile OrdinaryDiffEq | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: julia-actions/setup-julia@v2 | |
with: | |
version: '1.10' | |
- uses: julia-actions/cache@v2 | |
with: | |
cache-name: 'precompile-cache' | |
- name: Install dependencies | |
run: julia --project -e 'using Pkg; Pkg.instantiate()' | |
- name: Setup test environment for precompilation | |
run: | | |
julia --project -e ' | |
using Pkg, TOML | |
# Read Project.toml to get test dependencies like Pkg.test() does | |
project = TOML.parsefile("Project.toml") | |
extras = get(project, "extras", Dict()) | |
test_targets = get(get(project, "targets", Dict()), "test", String[]) | |
println("Setting up test environment with $(length(test_targets)) test dependencies...") | |
# Add test dependencies to current environment (easier for CI) | |
for dep in test_targets | |
if haskey(extras, dep) | |
println("Adding test dependency: $dep") | |
Pkg.add(PackageSpec(name=dep, uuid=extras[dep])) | |
else | |
println("Warning: $dep not found in extras") | |
end | |
end | |
println("Test environment setup complete") | |
' | |
- name: Run precompilation workload | |
run: | | |
echo "Running precompilation workload with complete test environment..." | |
julia --project --check-bounds=yes --compiled-modules=yes --depwarn=yes -e ' | |
# Now we have access to all test dependencies, just like Pkg.test() | |
using SafeTestsets, Test | |
# Load OrdinaryDiffEq to trigger @compile_workload blocks with test environment active | |
using OrdinaryDiffEq | |
println("Precompilation completed successfully with full test environment") | |
' | |
- name: Verify cache creation | |
run: | | |
echo "Julia depot structure (compiled artifacts):" | |
find ~/.julia -name "*.ji" | head -10 || echo "No .ji files found" | |
echo "Julia depot structure (shared libraries):" | |
find ~/.julia -name "*.so" | head -5 || echo "No .so files found" | |
echo "Cache verification completed" | |
test-interface: | |
name: Interface Tests | |
needs: precompile | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
env: | |
GROUP: 'InterfaceI' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: julia-actions/setup-julia@v2 | |
with: | |
version: '1.10' | |
- uses: julia-actions/cache@v2 | |
with: | |
cache-name: 'precompile-cache' | |
- name: Run interface tests | |
run: julia --project -e 'using Pkg; Pkg.test()' | |
env: | |
JULIA_NUM_THREADS: 2 | |
test-integrators: | |
name: Integrator Tests | |
needs: precompile | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
env: | |
GROUP: 'Integrators' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: julia-actions/setup-julia@v2 | |
with: | |
version: '1.10' | |
- uses: julia-actions/cache@v2 | |
with: | |
cache-name: 'precompile-cache' | |
- name: Run integrator tests | |
run: julia --project -e 'using Pkg; Pkg.test()' | |
env: | |
JULIA_NUM_THREADS: 2 | |
test-algorithms: | |
name: Algorithm Tests | |
needs: precompile | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
group: [ | |
'AlgorithmConvergence1', | |
'AlgorithmConvergence2', | |
'AlgorithmConvergence3', | |
'AlgorithmConvergence4' | |
] | |
env: | |
GROUP: ${{ matrix.group }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: julia-actions/setup-julia@v2 | |
with: | |
version: '1.10' | |
- uses: julia-actions/cache@v2 | |
with: | |
cache-name: 'precompile-cache' | |
- name: Run algorithm tests | |
run: julia --project -e 'using Pkg; Pkg.test()' | |
env: | |
JULIA_NUM_THREADS: 2 | |
test-subpackages: | |
name: Sub-package Tests | |
needs: precompile | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
package: [ | |
'OrdinaryDiffEqTsit5', | |
'OrdinaryDiffEqBDF', | |
'OrdinaryDiffEqRosenbrock', | |
'OrdinaryDiffEqVerner', | |
'OrdinaryDiffEqCore' | |
] | |
env: | |
GROUP: ${{ matrix.package }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: julia-actions/setup-julia@v2 | |
with: | |
version: '1.10' | |
- uses: julia-actions/cache@v2 | |
with: | |
cache-name: 'precompile-cache' | |
- name: Run sub-package tests | |
run: julia --project -e 'using Pkg; Pkg.test()' | |
env: | |
JULIA_NUM_THREADS: 2 |