Skip to content

Commit 06c6244

Browse files
authored
Fix failures in the cron ci. (RustPython#5002)
1 parent 3a2a1d1 commit 06c6244

File tree

4 files changed

+59
-54
lines changed

4 files changed

+59
-54
lines changed

.github/workflows/cron-ci.yaml

+17-31
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,33 @@ on:
66
name: Periodic checks/tasks
77

88
env:
9-
CARGO_ARGS: --features ssl,jit
9+
CARGO_ARGS: --no-default-features --features stdlib,zlib,importlib,encodings,ssl,jit
1010

1111
jobs:
12+
# codecov collects code coverage data from the rust tests, python snippets and python test suite.
13+
# This is done using cargo-llvm-cov, which is a wrapper around llvm-cov.
1214
codecov:
1315
name: Collect code coverage data
1416
runs-on: ubuntu-latest
1517
steps:
1618
- uses: actions/checkout@v3
1719
- uses: dtolnay/rust-toolchain@stable
18-
with:
19-
components: llvm-tools-preview
20-
- run: sudo apt-get update && sudo apt-get -y install lcov
21-
- run: cargo build --release --verbose ${{ env.CARGO_ARGS }}
22-
env:
23-
RUSTC_WRAPPER: './scripts/codecoverage-rustc-wrapper.sh'
20+
- uses: taiki-e/install-action@cargo-llvm-cov
2421
- uses: actions/setup-python@v4
2522
with:
2623
python-version: "3.11"
27-
- run: python -m pip install pytest
28-
working-directory: ./extra_tests
29-
- name: run snippets
30-
run: LLVM_PROFILE_FILE="$PWD/snippet-%p.profraw" pytest -v
31-
working-directory: ./extra_tests
24+
- run: sudo apt-get update && sudo apt-get -y install lcov
25+
- name: Run cargo-llvm-cov with Rust tests.
26+
run: cargo llvm-cov --no-report --workspace --exclude rustpython_wasm --verbose --no-default-features --features stdlib,zlib,importlib,encodings,ssl,jit
27+
- name: Run cargo-llvm-cov with Python snippets.
28+
run: python scripts/cargo-llvm-cov.py
3229
continue-on-error: true
33-
- name: run cpython tests
34-
run: |
35-
alltests=($(target/release/rustpython -c 'from test.libregrtest.runtest import findtests; print(*findtests())'))
36-
i=0
37-
# chunk into chunks of 10 tests each. idk at this point
38-
while subtests=("${alltests[@]:$i:10}"); [[ ${#subtests[@]} -ne 0 ]]; do
39-
LLVM_PROFILE_FILE="$PWD/regrtest-%p.profraw" target/release/rustpython -m test -v "${subtests[@]}" || true
40-
((i+=10))
41-
done
30+
- name: Run cargo-llvm-cov with Python test suite.
31+
run: cargo llvm-cov --no-report run -- -m test -u all --slowest --fail-env-changed
4232
continue-on-error: true
43-
- name: prepare code coverage data
44-
run: |
45-
rusttool() {
46-
local tool=$1; shift; "$(rustc --print target-libdir)/../bin/llvm-$tool" "$@"
47-
}
48-
rusttool profdata merge extra_tests/snippet-*.profraw regrtest-*.profraw --output codecov.profdata
49-
rusttool cov export --instr-profile codecov.profdata target/release/rustpython --format lcov > codecov_tmp.lcov
50-
lcov -e codecov_tmp.lcov "$PWD"/'*' -o codecov_tmp2.lcov
51-
lcov -r codecov_tmp2.lcov "$PWD"/target/'*' -o codecov.lcov # remove LALRPOP-generated parser
52-
- name: upload to Codecov
33+
- name: Prepare code coverage data
34+
run: cargo llvm-cov report --lcov --output-path='codecov.cov'
35+
- name: Upload to Codecov
5336
uses: codecov/codecov-action@v3
5437
with:
5538
file: ./codecov.lcov
@@ -89,6 +72,9 @@ jobs:
8972
steps:
9073
- uses: actions/checkout@v3
9174
- uses: dtolnay/rust-toolchain@stable
75+
- uses: actions/setup-python@v4
76+
with:
77+
python-version: "3.11"
9278
- name: build rustpython
9379
run: cargo build --release --verbose
9480
- name: Collect what is left data

benches/microbenchmarks.rs

+22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ use std::{
99
path::{Path, PathBuf},
1010
};
1111

12+
// List of microbenchmarks to skip.
13+
//
14+
// These result in excessive memory usage, some more so than others. For example, while
15+
// exception_context.py consumes a lot of memory, it still finishes. On the other hand,
16+
// call_kwargs.py seems like it performs an excessive amount of allocations and results in
17+
// a system freeze.
18+
// In addition, the fact that we don't yet have a GC means that benchmarks which might consume
19+
// a bearable amount of memory accumulate. As such, best to skip them for now.
20+
const SKIP_MICROBENCHMARKS: [&str; 8] = [
21+
"call_simple.py",
22+
"call_kwargs.py",
23+
"construct_object.py",
24+
"define_function.py",
25+
"define_class.py",
26+
"exception_nested.py",
27+
"exception_simple.py",
28+
"exception_context.py",
29+
];
30+
1231
pub struct MicroBenchmark {
1332
name: String,
1433
setup: String,
@@ -211,6 +230,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
211230
.collect();
212231

213232
for benchmark in benchmarks {
233+
if SKIP_MICROBENCHMARKS.contains(&benchmark.name.as_str()) {
234+
continue;
235+
}
214236
run_micro_benchmark(c, benchmark);
215237
}
216238
}

scripts/cargo-llvm-cov.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
import subprocess
3+
4+
TARGET = "extra_tests/snippets"
5+
6+
def run_llvm_cov(file_path: str):
7+
""" Run cargo llvm-cov on a file. """
8+
if file_path.endswith(".py"):
9+
command = ["cargo", "llvm-cov", "--no-report", "run", "--", file_path]
10+
subprocess.call(command)
11+
12+
def iterate_files(folder: str):
13+
""" Iterate over all files in a folder. """
14+
for root, _, files in os.walk(folder):
15+
for file in files:
16+
file_path = os.path.join(root, file)
17+
run_llvm_cov(file_path)
18+
19+
if __name__ == "__main__":
20+
iterate_files(TARGET)

scripts/codecoverage-rustc-wrapper.sh

-23
This file was deleted.

0 commit comments

Comments
 (0)