Skip to content

Commit 7654ed0

Browse files
committed
Move the build-mylib test into the regular test suite (and get rid of the separate build-mylib CI job)
1 parent ebd57d1 commit 7654ed0

File tree

4 files changed

+63
-39
lines changed

4 files changed

+63
-39
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -130,33 +130,3 @@ jobs:
130130
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
131131
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
132132
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate(); include("docs/make.jl")'
133-
build-mylib:
134-
runs-on: ubuntu-latest
135-
timeout-minutes: 60
136-
strategy:
137-
# Only run 1 of the `build-mylib` job at a time, so that this job doesn't take over
138-
# too many CI resources, and also to leave space for other runs in the JuliaLang org.
139-
max-parallel: 1
140-
fail-fast: false
141-
matrix:
142-
julia-version:
143-
- '1.10' # current LTS
144-
- '1.11' # current stable
145-
steps:
146-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
147-
- uses: julia-actions/setup-julia@9b79636afcfb07ab02c256cede01fe2db6ba808c # v2.6.0
148-
with:
149-
version: ${{ matrix.julia-version }}
150-
- uses: julia-actions/cache@824243901fb567ccb490b0d0e2483ccecde46834 # v2.0.5
151-
- uses: julia-actions/julia-buildpkg@90dd6f23eb49626e4e6612cb9d64d456f86e6a1c # v1.6.0
152-
with:
153-
project: 'examples/MyLib'
154-
- uses: julia-actions/julia-buildpkg@90dd6f23eb49626e4e6612cb9d64d456f86e6a1c # v1.6.0
155-
with:
156-
project: 'examples/MyLib/build'
157-
- run: |
158-
cd examples/MyLib
159-
make
160-
- run: ./examples/MyLib/my_application.out
161-
env:
162-
LD_LIBRARY_PATH: 'examples/MyLib/MyLibCompiled/lib'

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ julia = "1.6"
2828

2929
[extras]
3030
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
31+
GNUMake_jll = "6c1a3432-6b93-5c89-98b5-f3caf0c092ba"
3132
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
3233
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3334

3435
[targets]
35-
test = ["Test", "Example", "TOML"]
36+
test = ["Test", "Example", "GNUMake_jll", "TOML"]

examples/MyLib/Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,31 @@
22

33
.DEFAULT_GOAL := all
44

5+
.PHONY: all
6+
all: build-library build-executable
7+
58
JULIA ?= julia
6-
DLEXT := $(shell $(JULIA) --startup-file=no -e 'using Libdl; print(Libdl.dlext)')
9+
GCC ?= gcc
10+
DLEXT := $(shell $(JULIA) --startup-file=no -e 'import Libdl; print(Libdl.dlext)')
711

812
TARGET="MyLibCompiled"
913

1014
MYLIB_INCLUDES = $(TARGET)/include/julia_init.h $(TARGET)/include/mylib.h
1115
MYLIB_PATH := $(TARGET)/lib/libmylib.$(DLEXT)
1216

17+
.PHONY: build-library
1318
build-library: build/build.jl src/MyLib.jl
14-
$(JULIA) --startup-file=no --project=. -e 'using Pkg; Pkg.instantiate()'
15-
$(JULIA) --startup-file=no --project=build -e 'using Pkg; Pkg.instantiate(); include("build/build.jl")'
19+
$(JULIA) --startup-file=no --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.precompile()'
20+
$(JULIA) --startup-file=no --project=build -e 'import Pkg; Pkg.instantiate(); Pkg.precompile()'
21+
$(JULIA) --startup-file=no --project=build -e 'include("build/build.jl")'
1622

1723
INCLUDE_DIR = $(TARGET)/include
1824

25+
.PHONY: build-executable
1926
build-executable:
20-
gcc my_application.c -o my_application.out -I$(INCLUDE_DIR) -L$(TARGET)/lib -ljulia -lmylib
21-
22-
all: build-library build-executable
27+
$(gcc) my_application.c -o my_application.out -I$(INCLUDE_DIR) -L$(TARGET)/lib -ljulia -lmylib
2328

29+
.PHONY: clean
2430
clean:
2531
$(RM) *~ *.o *.$(DLEXT)
2632
$(RM) -Rf $(TARGET)
27-
28-
.PHONY: build-library build-executable clean all

test/runtests.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Test
33
using Libdl
44
using Pkg
55

6+
import GNUMake_jll
67
import TOML
78

89
ENV["JULIA_DEBUG"] = "PackageCompiler"
@@ -242,4 +243,52 @@ end
242243
hello = read(`$(Base.julia_cmd()) -J $(sysimage_path) -e 'print("hello, world")'`, String)
243244
@test hello == "hello, world"
244245
end
246+
247+
@testset "examples/MyLib" begin
248+
# This testset makes sure that the `examples/MyLib` example does not bitrot.
249+
250+
if Sys.iswindows()
251+
@info "Skipping the examples/MyLib test on Windows"
252+
@test_skip false
253+
else
254+
if Sys.isapply()
255+
@info "Skipping the examples/MyLib test on macOS"
256+
@test_skip false
257+
else
258+
rootdir_testdir = @__DIR__
259+
rootdir = dirname(rootdir_testdir)
260+
rootdir_examples = joinpath(rootdir, "examples")
261+
rootdir_examples_MyLib = joinpath(rootdir_examples, "MyLib")
262+
263+
my_run = (cmd::Cmd) -> begin
264+
env2 = copy(ENV)
265+
266+
# The `JULIA` environment variable is used by our `MyLib/Makefile`.
267+
# The `GCC` environment variable is used by our `MyLib/Makefile`.
268+
env2["JULIA"] = Base.julia_cmd()[1]
269+
env2["GCC"] = PackageCompiler.get_compiler_cmd()[1]
270+
271+
return run(cmd)
272+
end
273+
274+
cd(rootdir_examples_MyLib) do
275+
# We don't want to assume that the machine running the tests has `make` installed
276+
# and available in the PATH. Therefore, we use the `GNUMake_jll.jl`` package.
277+
my_run(`$(GNUMake_jll.make())`)
278+
279+
env2 = copy(ENV)
280+
env2["LD_LIBRARY_PATH"] = "examples/MyLib/MyLibCompiled/lib"
281+
cmd = `./examples/MyLib/my_application.out`
282+
run(setenv(cmd, env2))
283+
284+
# Finally, exercise a few more `Makefile` targets, to make sure that they
285+
# don't bitrot.
286+
my_run(`$(GNUMake_jll.make()) all`)
287+
my_run(`$(GNUMake_jll.make()) build-library`)
288+
my_run(`$(GNUMake_jll.make()) build-executable`)
289+
my_run(`$(GNUMake_jll.make()) clean`)
290+
291+
end
292+
end
293+
end # testset
245294
end

0 commit comments

Comments
 (0)