Skip to content

Commit a29511d

Browse files
authored
Automatically have CI build LLVMExtra, if needed. (#318)
1 parent 81db14e commit a29511d

File tree

4 files changed

+73
-55
lines changed

4 files changed

+73
-55
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ on:
66
pull_request:
77
workflow_dispatch:
88
jobs:
9-
binary_test:
9+
test:
1010
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
version: ['1.6', '1.7', '^1.8.0-beta3', 'nightly']
15+
version: ['1.6', '1.7', '1.8', 'nightly']
1616
os: [ubuntu-latest, macOS-latest, windows-latest]
1717
arch: [x64]
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0 # build_ci.jl needs to be able to inspect the git log
2022
- uses: julia-actions/setup-julia@v1
2123
with:
2224
version: ${{ matrix.version }}
@@ -32,55 +34,10 @@ jobs:
3234
${{ runner.os }}-test-
3335
${{ runner.os }}-
3436
- uses: julia-actions/julia-buildpkg@v1
35-
- name: Run tests
36-
run: |
37-
julia --project -e 'using Pkg; Pkg.test(; coverage=true, julia_args=`-g2`)'
38-
- uses: julia-actions/julia-processcoverage@v1
39-
- uses: codecov/codecov-action@v1
40-
with:
41-
file: lcov.info
42-
43-
# development versions of Julia, built with assertions enabled.
44-
# we also build LLVMExtra from source here.
45-
source_test:
46-
name: Julia ${{ matrix.branch }} - ${{ matrix.os }} - ${{ matrix.arch }}
47-
runs-on: ${{ matrix.os }}
48-
strategy:
49-
fail-fast: false
50-
matrix:
51-
branch: ['release-1.7', 'release-1.8', 'master']
52-
os: [ubuntu-latest, macOS-latest]
53-
arch: [x64]
54-
assertions: [false]
55-
steps:
56-
- uses: actions/checkout@v2
57-
- uses: actions/checkout@v2
58-
with:
59-
repository: 'JuliaLang/julia'
60-
ref: ${{ matrix.branch }}
61-
path: 'julia'
62-
- name: Compile Julia
63-
run: |
64-
make -C julia -j $(nproc) FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 JULIA_PRECOMPILE=0
65-
echo $PWD/julia/usr/bin >> $GITHUB_PATH
66-
- uses: actions/cache@v1
67-
env:
68-
cache-name: cache-artifacts
69-
with:
70-
path: ~/.julia/artifacts
71-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
72-
restore-keys: |
73-
${{ runner.os }}-test-${{ env.cache-name }}-
74-
${{ runner.os }}-test-
75-
${{ runner.os }}-
76-
- uses: julia-actions/julia-buildpkg@v1
7737
- name: Build libLLVMExtra
78-
run: |
79-
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
80-
julia --project=deps deps/build_local.jl
38+
run: julia --project=deps deps/build_ci.jl
8139
- name: Run tests
82-
run: |
83-
julia --project -e 'using Pkg; Pkg.test(; coverage=true, julia_args=`-g2`)'
40+
run: julia --project -e 'using Pkg; Pkg.test(; coverage=true, julia_args=`-g2`)'
8441
- uses: julia-actions/julia-processcoverage@v1
8542
- uses: codecov/codecov-action@v1
8643
with:

deps/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[deps]
22
CMake_jll = "3f4e10e2-61f2-5801-8945-23b9d642d0e6"
3+
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
34
LLVMExtra_jll = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
45
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
56
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

deps/build_ci.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Pkg
2+
Pkg.activate(@__DIR__)
3+
Pkg.instantiate()
4+
5+
using Git, Scratch, Dates
6+
7+
LLVM = Base.UUID("929cbde3-209d-540e-8aea-75f648917ca0")
8+
9+
# get scratch directories
10+
support_dir = get_scratch!(LLVM, "support")
11+
12+
# is this a full-fledged check-out?
13+
if isdir(joinpath(@__DIR__), "..", ".git")
14+
# determine latest change to the wrappers
15+
deps_timestamp = parse(Int, read(`$(git()) -C $(@__DIR__) log -1 --format=%ct LLVMExtra`, String))
16+
@info "Latest change to the wrappers: $(unix2datetime(deps_timestamp))"
17+
18+
# find out which version of LLVMExtra_jll we are using
19+
Pkg.activate(joinpath(@__DIR__, ".."))
20+
deps = collect(values(Pkg.dependencies()))
21+
filter!(deps) do dep
22+
dep.name == "LLVMExtra_jll"
23+
end
24+
library_version = only(deps).version
25+
@info "LLVMExtra_jll version: $(library_version)"
26+
27+
# compare to the JLL's tags
28+
jll_tags = mktempdir() do dir
29+
if !isdir(joinpath(support_dir, ".git"))
30+
run(`$(git()) clone -q https://github.com/JuliaBinaryWrappers/LLVMExtra_jll.jl $dir`)
31+
else
32+
run(`$(git()) -C $dir fetch -q`)
33+
end
34+
tags = Dict{String,Int}()
35+
for line in eachline(`$(git()) -C $dir tag --format "%(refname:short) %(creatordate:unix)"`)
36+
tag, timestamp = split(line)
37+
tags[tag] = parse(Int, timestamp)
38+
end
39+
tags
40+
end
41+
jll_timestamp = jll_tags["LLVMExtra-v$(library_version)"]
42+
@info "LLVMExtra_jll timestamp: $(unix2datetime(jll_timestamp))"
43+
44+
if deps_timestamp > jll_timestamp
45+
@info "Wrappers have changed since the last JLL build. Building the support library locally."
46+
include(joinpath(@__DIR__, "build_local.jl"))
47+
else
48+
@info "Wrappers have not changed since the last JLL build. Using the JLL's support library."
49+
end
50+
else
51+
@warn """LLVM.jl source code is not checked-out from Git.
52+
This means we cannot check for changes, and need to unconditionally build the support library."""
53+
include(joinpath(@__DIR__, "build_local.jl"))
54+
end

deps/build_local.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# Invoke with
2-
# `julia --project=deps deps/build_local.jl`
1+
# build a local version of LLVMExtra
32

4-
# the pre-built LLVMExtra_jll might not be loadable on this platform
5-
LLVMExtra_jll = Base.UUID("dad2f222-ce93-54a1-a47d-0025e8a3acab")
3+
using Pkg
4+
Pkg.activate(@__DIR__)
5+
Pkg.instantiate()
6+
7+
if haskey(ENV, "GITHUB_ACTIONS")
8+
println("::warning ::Using a locally-built LLVMExtra; A bump of LLVMExtra_jll will be required before releasing LLVM.jl.")
9+
end
610

711
using Pkg, Scratch, Preferences, Libdl, CMake_jll
812

13+
LLVM = Base.UUID("929cbde3-209d-540e-8aea-75f648917ca0")
14+
915
# 1. Ensure that an appropriate LLVM_full_jll is installed
1016
Pkg.activate(; temp=true)
1117
llvm_assertions = try
@@ -26,7 +32,7 @@ end
2632
LLVM_DIR = joinpath(LLVM.artifact_dir, "lib", "cmake", "llvm")
2733

2834
# 2. Get a scratch directory
29-
scratch_dir = get_scratch!(LLVMExtra_jll, "build")
35+
scratch_dir = get_scratch!(LLVM, "build")
3036
isdir(scratch_dir) && rm(scratch_dir; recursive=true)
3137
source_dir = joinpath(@__DIR__, "LLVMExtra")
3238

0 commit comments

Comments
 (0)