Skip to content

Commit 121ce56

Browse files
authored
chore: CI: make "Linux Lake" primary PR CI job (#8739)
Comes with .olean caching and module system-powered short-circuiting
1 parent 300c22a commit 121ce56

File tree

3 files changed

+22
-34
lines changed

3 files changed

+22
-34
lines changed

.github/workflows/build-template.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ jobs:
127127
[ -d build ] || mkdir build
128128
cd build
129129
# arguments passed to `cmake`
130-
# this also enables githash embedding into stage 1 library
131-
OPTIONS=(-DCHECK_OLEAN_VERSION=ON)
132-
OPTIONS+=(-DLEAN_EXTRA_MAKE_OPTS=-DwarningAsError=true)
130+
OPTIONS=(-DLEAN_EXTRA_MAKE_OPTS=-DwarningAsError=true)
131+
if [[ -n '${{ matrix.release }}' ]]; then
132+
# this also enables githash embedding into stage 1 library, which prohibits reusing
133+
# `.olean`s across commits, so we don't do it in the fast non-release CI
134+
OPTIONS+=(-DCHECK_OLEAN_VERSION=ON)
135+
fi
133136
if [[ -n '${{ matrix.cross_target }}' ]]; then
134137
# used by `prepare-llvm`
135138
export EXTRA_FLAGS=--target=${{ matrix.cross_target }}
@@ -193,7 +196,7 @@ jobs:
193196
run: |
194197
ulimit -c unlimited # coredumps
195198
time ctest --preset ${{ matrix.CMAKE_PRESET || 'release' }} --test-dir build/stage1 -j$NPROC --output-junit test-results.xml ${{ matrix.CTEST_OPTIONS }}
196-
if: (matrix.wasm || !matrix.cross) && (inputs.check-level >= 1 || matrix.name == 'Linux release')
199+
if: (matrix.wasm || !matrix.cross) && (inputs.check-level >= 1 || matrix.test)
197200
- name: Test Summary
198201
uses: test-summary/action@v2
199202
with:
@@ -210,7 +213,7 @@ jobs:
210213
- name: Check Stage 3
211214
run: |
212215
make -C build -j$NPROC check-stage3
213-
if: matrix.test-speedcenter
216+
if: matrix.check-stage3
214217
- name: Test Speedcenter Benchmarks
215218
run: |
216219
# Necessary for some timing metrics but does not work on Namespace runners
@@ -224,7 +227,7 @@ jobs:
224227
run: |
225228
# clean rebuild in case of Makefile changes
226229
make -C build update-stage0 && rm -rf build/stage* && make -C build -j$NPROC
227-
if: matrix.name == 'Linux' && inputs.check-level >= 1
230+
if: matrix.check-rebootstrap
228231
- name: CCache stats
229232
if: always()
230233
run: ccache -s

.github/workflows/ci.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ jobs:
166166
"name": "Linux release",
167167
"os": large ? "nscloud-ubuntu-22.04-amd64-4x8" : "ubuntu-latest",
168168
"release": true,
169-
"check-level": 0,
169+
"check-level": 2,
170170
"shell": "nix develop .#oldGlibc -c bash -euxo pipefail {0}",
171171
"llvm-url": "https://github.com/leanprover/lean-llvm/releases/download/19.1.2/lean-llvm-x86_64-linux-gnu.tar.zst",
172172
"prepare-llvm": "../script/prepare-llvm-linux.sh lean-llvm*",
@@ -176,21 +176,13 @@ jobs:
176176
},
177177
{
178178
"name": "Linux Lake",
179-
"os": large ? "nscloud-ubuntu-22.04-amd64-4x8" : "ubuntu-latest",
179+
"os": large ? "nscloud-ubuntu-22.04-amd64-8x8" : "ubuntu-latest",
180180
"check-level": 0,
181-
// just a secondary build job for now until false positives can be excluded
182-
"secondary": true,
183-
"CMAKE_OPTIONS": "-DUSE_LAKE=ON",
184-
// TODO: importStructure is not compatible with .olean caching
185-
// TODO: why does scopedMacros fail?
186-
"CTEST_OPTIONS": "-E 'scopedMacros|importStructure'"
187-
},
188-
{
189-
"name": "Linux",
190-
"os": large ? "nscloud-ubuntu-22.04-amd64-4x8" : "ubuntu-latest",
181+
"test": true,
182+
"check-rebootstrap": level >= 1,
191183
"check-stage3": level >= 2,
192184
"test-speedcenter": level >= 2,
193-
"check-level": 1,
185+
"CMAKE_OPTIONS": "-DUSE_LAKE=ON",
194186
},
195187
{
196188
"name": "Linux Reldebug",

tests/lean/run/importStructure.lean

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ Currently, we only test the following:
1313
-/
1414

1515
/-- Collects the module names corresponding to all `lean` files in the file system. -/
16-
partial def collectModulesOnFileSystem (sysroot : System.FilePath) (roots : Array String) :
16+
partial def collectModulesOnFileSystem (searchPaths : List System.FilePath) (roots : Array String) :
1717
IO (Array String) :=
18-
roots.flatMapM (fun (root : String) => go (sysroot / "lib" / "lean" / root) root #[])
18+
searchPaths.toArray.flatMapM (fun libdir =>
19+
roots.flatMapM (fun (root : String) => go (libdir / root) root #[]))
1920
where
2021
go (dir : System.FilePath) (pref : String) (sofar : Array String) : IO (Array String) := do
2122
if !(← dir.pathExists) then
@@ -27,7 +28,7 @@ where
2728
match mdata.type with
2829
| .dir => arr ← go entry.path (pref ++ "." ++ entry.fileName) arr
2930
| .file =>
30-
if entry.path.extension == some "olean" then
31+
if entry.path.extension == some "lean" then
3132
arr := arr.push (pref ++ "." ++ entry.path.fileStem.get!)
3233
| _ => pure ()
3334
return arr
@@ -63,9 +64,10 @@ def analyzeModuleData (data : Array (Name × ModuleData)) : ImportGraph := Id.ru
6364

6465
result
6566

66-
def computeOrphanedModules (sysroot : System.FilePath) (importGraph : ImportGraph) :
67+
def computeOrphanedModules (importGraph : ImportGraph) :
6768
IO (Array String) := do
68-
let onFS ← collectModulesOnFileSystem sysroot #["Init", "Std", "Lean"]
69+
let searchPath ← Lean.getSrcSearchPath
70+
let onFS ← collectModulesOnFileSystem searchPath #["Init", "Std", "Lean"]
6971
let imported : HashSet String := #["Init", "Std", "Lean"].foldl (init := ∅)
7072
(fun sofar root => sofar.insertMany (dfs root importGraph.imports ∅))
7173
return onFS.filter (fun module => !imported.contains module)
@@ -86,22 +88,13 @@ def test : MetaM Unit := do
8688
let env ← importModules #[`Init, `Std, `Lean] {}
8789
let importGraph := analyzeModuleData (env.header.moduleNames.zip env.header.moduleData)
8890

89-
let orphanedModules ← computeOrphanedModules sysroot importGraph
91+
let orphanedModules ← computeOrphanedModules importGraph
9092
if !orphanedModules.isEmpty then do
9193
logError s!"There are orphaned modules: {orphanedModules}"
9294

9395
let illegalReverseImports := computeIllegalReverseImportsOfInitDataOptionCoe importGraph
9496
if !illegalReverseImports.isEmpty then do
9597
logError s!"The following modules illegally (transitively) import Init.Data.Option.Coe: {illegalReverseImports}"
9698

97-
/-!
98-
We check which modules exist by looking at which `olean` files are present in the file system.
99-
This means that locally you might get false positives on this test because there are some `olean`
100-
files still floating around where the corresponding `lean` file no longer exists in the source.
101-
102-
It would be better to check for `lean` files directly, but our CI step which runs the tests doesn't
103-
see the source files in the `srcPath`.
104-
-/
105-
10699
#guard_msgs in
107100
#eval test

0 commit comments

Comments
 (0)