Skip to content

Commit f49edc8

Browse files
authored
Add a CI job that checks if the list of historical stdlibs needs to be updated (#2790)
1 parent 2691839 commit f49edc8

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.ci/check_hsg.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
function check_hsg()
2+
assert_clean_working_directory()
3+
run_hsg()
4+
assert_clean_working_directory()
5+
return nothing
6+
end
7+
8+
function assert_clean_working_directory()
9+
if !isempty(strip(read(`git status --short`, String)))
10+
msg = "The working directory is dirty"
11+
@error msg
12+
13+
println("Output of `git status`:")
14+
println(strip(read(`git status`, String)))
15+
16+
run(`git add -A`)
17+
18+
println("Output of `git diff HEAD`:")
19+
println(strip(read(`git diff HEAD`, String)))
20+
21+
run(`git reset`)
22+
23+
throw(ErrorException(msg))
24+
else
25+
@info "The working directory is clean"
26+
return nothing
27+
end
28+
end
29+
30+
function run_hsg()
31+
env2 = copy(ENV)
32+
delete!(env2, "JULIA_DEPOT_PATH")
33+
delete!(env2, "JULIA_LOAD_PATH")
34+
delete!(env2, "JULIA_PROJECT")
35+
env2["JULIA_DEPOT_PATH"] = mktempdir(; cleanup = true)
36+
julia_binary = Base.julia_cmd().exec[1]
37+
hsg_directory = joinpath("ext", "HistoricaStdlibGenerator")
38+
hsg_generate_file = joinpath(hsg_directory, "generate_historical_stdlibs.jl")
39+
40+
cmd_1 = `$(julia_binary) --project=$(hsg_directory) -e 'import Pkg; Pkg.instantiate()'`
41+
cmd_2 = `$(julia_binary) --project=$(hsg_directory) $(hsg_generate_file)`
42+
43+
run(setenv(cmd_1, env2))
44+
run(setenv(cmd_2, env2))
45+
46+
return nothing
47+
end
48+
49+
check_hsg()

.github/workflows/check_hsg.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check Historical Stdlib Generator
2+
on:
3+
pull_request:
4+
branches:
5+
- 'master'
6+
push:
7+
branches:
8+
- 'master'
9+
concurrency:
10+
# Skip intermediate builds: always.
11+
# Cancel intermediate builds: only if it is a pull request build.
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
14+
jobs:
15+
check_hsg:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 60
18+
steps:
19+
- uses: actions/[email protected]
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
# version: '1'
23+
version: 'nightly'
24+
- run: julia --color=yes .ci/check_hsg.jl

0 commit comments

Comments
 (0)