Skip to content

Commit 54f9b0d

Browse files
authored
CI: Standardize the workflow for testing and changing the UUID (#78)
1 parent ba24318 commit 54f9b0d

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

.ci/test_and_change_uuid.jl

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@static if Base.VERSION >= v"1.6"
2+
using TOML
3+
using Test
4+
else
5+
using Pkg: TOML
6+
using Test
7+
end
8+
9+
# To generate the new UUID, we simply modify the first character of the original UUID
10+
const original_uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
11+
const new_uuid = "20745b16-79ce-11e8-11f9-7d13ad32a3b2"
12+
13+
# `@__DIR__` is the `.ci/` folder.
14+
# Therefore, `dirname(@__DIR__)` is the repository root.
15+
const project_filename = joinpath(dirname(@__DIR__), "Project.toml")
16+
17+
@testset "Test that the UUID is unchanged" begin
18+
project_dict = TOML.parsefile(project_filename)
19+
@test project_dict["uuid"] == original_uuid
20+
end
21+
22+
write(
23+
project_filename,
24+
replace(
25+
read(project_filename, String),
26+
r"uuid = .*?\n" => "uuid = \"$(new_uuid)\"\n",
27+
),
28+
)

.github/workflows/ci.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ jobs:
4040
${{ runner.os }}-test-${{ env.cache-name }}-
4141
${{ runner.os }}-test-
4242
${{ runner.os }}-
43+
- run: julia --color=yes .ci/test_and_change_uuid.jl
4344
- uses: julia-actions/julia-buildpkg@v1
44-
- name: Run tests
45-
run: |
46-
julia --project --color=yes -e 'using UUIDs; write("Project.toml", replace(read("Project.toml", String), r"uuid = .*?\n" =>"uuid = \"$(uuid4())\"\n"));'
47-
julia --project --color=yes --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test(; coverage=true)'
45+
- uses: julia-actions/julia-runtest@v1
4846
- uses: julia-actions/julia-processcoverage@v1
4947
- uses: codecov/codecov-action@v1
5048
with:

0 commit comments

Comments
 (0)