Skip to content

Commit cddeb7f

Browse files
authored
CI: Standardize the workflow for testing and changing the UUID (#104)
1 parent ee2410e commit cddeb7f

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

.ci/test_and_change_uuid.jl

Lines changed: 28 additions & 0 deletions
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 = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
11+
const new_uuid = "c27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ jobs:
4343
${{ runner.os }}-test-${{ env.cache-name }}-
4444
${{ runner.os }}-test-
4545
${{ runner.os }}-
46+
- run: julia --color=yes .ci/test_and_change_uuid.jl
4647
- uses: julia-actions/julia-buildpkg@v1
47-
- name: Run tests
48-
run: |
49-
julia --project --color=yes -e 'using UUIDs; write("Project.toml", replace(read("Project.toml", String), r"uuid = .*?\n" =>"uuid = \"$(uuid4())\"\n"));'
50-
julia --project --color=yes --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test(; coverage=true)'
48+
- uses: julia-actions/julia-runtest@v1
5149
- uses: julia-actions/julia-processcoverage@v1
5250
- uses: codecov/codecov-action@v1
5351
with:

0 commit comments

Comments
 (0)