Skip to content

Commit 8b0a0c3

Browse files
authored
Update retester CI to check expectations (#225)
* Add a report processing tool * Add expectations tests to the CI action * Fix an issue with CI * Fix CI * Fix the path of the workdir in CI * Fix CI issue with the paths * Update the format of the expectations file
1 parent 94b04c0 commit 8b0a0c3

File tree

9 files changed

+491
-46
lines changed

9 files changed

+491
-46
lines changed

.github/actions/run-differential-tests/action.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ inputs:
4141
description: "The id of the parachain to spawn with the polkadot-omni-node. This is only required if the polkadot-omni-node is one of the selected platforms."
4242
type: number
4343
required: false
44+
expectations-file-path:
45+
description: "Path to the expectations file to use to compare against."
46+
type: string
47+
required: false
4448

4549
runs:
4650
using: "composite"
@@ -79,6 +83,12 @@ runs:
7983
run: |
8084
${{ inputs['cargo-command'] }} build --locked --profile release -p pallet-revive-eth-rpc -p revive-dev-node --manifest-path ${{ inputs['polkadot-sdk-path'] }}/Cargo.toml
8185
${{ inputs['cargo-command'] }} build --locked --profile release --bin polkadot-omni-node --manifest-path ${{ inputs['polkadot-sdk-path'] }}/Cargo.toml
86+
- name: Installing retester
87+
shell: bash
88+
run: ${{ inputs['cargo-command'] }} install --path ./revive-differential-tests/crates/core
89+
- name: Installing report-processor
90+
shell: bash
91+
run: ${{ inputs['cargo-command'] }} install --path ./revive-differential-tests/crates/report-processor
8292
- name: Running the Differential Tests
8393
shell: bash
8494
run: |
@@ -96,11 +106,12 @@ runs:
96106
)
97107
fi
98108
99-
${{ inputs['cargo-command'] }} run --locked --manifest-path revive-differential-tests/Cargo.toml -- test \
109+
retester test \
100110
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/simple \
101111
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/complex \
102112
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/translated_semantic_tests \
103113
--platform ${{ inputs['platform'] }} \
114+
--report.file-name report.json \
104115
--concurrency.number-of-nodes 10 \
105116
--concurrency.number-of-threads 10 \
106117
--concurrency.number-of-concurrent-tasks 100 \
@@ -110,22 +121,21 @@ runs:
110121
--eth-rpc.path ${{ inputs['polkadot-sdk-path'] }}/target/release/eth-rpc \
111122
--polkadot-omni-node.path ${{ inputs['polkadot-sdk-path'] }}/target/release/polkadot-omni-node \
112123
--resolc.path ./resolc \
113-
"${OMNI_ARGS[@]}"
114-
- name: Creating a markdown report of the test execution
124+
"${OMNI_ARGS[@]}" || true
125+
- name: Generate the expectation file
115126
shell: bash
116-
if: ${{ always() }}
117-
run: |
118-
mv ./workdir/*.json report.json
119-
python3 revive-differential-tests/scripts/process-differential-tests-report.py report.json ${{ inputs['platform'] }}
127+
run: report-processor generate-expectations-file --report-path ./workdir/report.json --output-path ./workdir/expectations.json --remove-prefix ./revive-differential-tests/resolc-compiler-tests
120128
- name: Upload the Report to the CI
121129
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
122-
if: ${{ always() }}
123130
with:
124-
name: report-${{ inputs['platform'] }}.md
125-
path: report.md
126-
- name: Posting the report as a comment on the PR
127-
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405
128-
if: ${{ always() }}
131+
name: ${{ inputs['platform'] }}-report.json
132+
path: ./workdir/report.json
133+
- name: Upload the Report to the CI
134+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
129135
with:
130-
header: diff-tests-report-${{ inputs['platform'] }}
131-
path: report.md
136+
name: ${{ inputs['platform'] }}.json
137+
path: ./workdir/expectations.json
138+
- name: Check Expectations
139+
shell: bash
140+
if: ${{ inputs['expectations-file-path'] != '' }}
141+
run: report-processor compare-expectation-files --base-expectation-path ${{ inputs['expectations-file-path'] }} --other-expectation-path ./workdir/expectations.json

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ revive-dt-node-interaction = { version = "0.1.0", path = "crates/node-interactio
2121
revive-dt-node-pool = { version = "0.1.0", path = "crates/node-pool" }
2222
revive-dt-report = { version = "0.1.0", path = "crates/report" }
2323
revive-dt-solc-binaries = { version = "0.1.0", path = "crates/solc-binaries" }
24+
revive-dt-report-processor = { version = "0.1.0", path = "crates/report-processor" }
2425

2526
alloy = { version = "1.4.1", features = ["full", "genesis", "json-rpc"] }
2627
ansi_term = "0.12.1"
@@ -81,7 +82,12 @@ zombienet-sdk = { git = "https://github.com/paritytech/zombienet-sdk.git", rev =
8182

8283
[profile.bench]
8384
inherits = "release"
85+
codegen-units = 1
8486
lto = true
87+
88+
[profile.production]
89+
inherits = "release"
8590
codegen-units = 1
91+
lto = true
8692

8793
[workspace.lints.clippy]

crates/common/src/types/mode.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ pub struct Mode {
2323
pub version: Option<semver::VersionReq>,
2424
}
2525

26+
impl Ord for Mode {
27+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
28+
self.to_string().cmp(&other.to_string())
29+
}
30+
}
31+
32+
impl PartialOrd for Mode {
33+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
34+
Some(self.cmp(other))
35+
}
36+
}
37+
2638
impl Display for Mode {
2739
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2840
self.pipeline.fmt(f)?;

crates/common/src/types/parsed_test_specifier.rs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
use std::{fmt::Display, path::PathBuf, str::FromStr};
1+
use std::{
2+
fmt::Display,
3+
path::{Path, PathBuf},
4+
str::FromStr,
5+
};
26

37
use anyhow::{Context as _, bail};
8+
use serde::{Deserialize, Serialize};
49

510
use crate::types::Mode;
611

7-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
12+
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
813
pub enum ParsedTestSpecifier {
914
/// All of the test cases in the file should be ran across all of the specified modes
1015
FileOrDirectory {
@@ -34,6 +39,22 @@ pub enum ParsedTestSpecifier {
3439
},
3540
}
3641

42+
impl ParsedTestSpecifier {
43+
pub fn metadata_path(&self) -> &Path {
44+
match self {
45+
ParsedTestSpecifier::FileOrDirectory {
46+
metadata_or_directory_file_path: metadata_file_path,
47+
}
48+
| ParsedTestSpecifier::Case {
49+
metadata_file_path, ..
50+
}
51+
| ParsedTestSpecifier::CaseWithMode {
52+
metadata_file_path, ..
53+
} => metadata_file_path,
54+
}
55+
}
56+
}
57+
3758
impl Display for ParsedTestSpecifier {
3859
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3960
match self {
@@ -131,3 +152,22 @@ impl TryFrom<&str> for ParsedTestSpecifier {
131152
value.parse()
132153
}
133154
}
155+
156+
impl Serialize for ParsedTestSpecifier {
157+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
158+
where
159+
S: serde::Serializer,
160+
{
161+
self.to_string().serialize(serializer)
162+
}
163+
}
164+
165+
impl<'de> Deserialize<'de> for ParsedTestSpecifier {
166+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
167+
where
168+
D: serde::Deserializer<'de>,
169+
{
170+
let string = String::deserialize(deserializer)?;
171+
string.parse().map_err(serde::de::Error::custom)
172+
}
173+
}

crates/config/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,10 @@ pub struct ReportConfiguration {
11131113
/// Controls if the compiler output is included in the final report.
11141114
#[clap(long = "report.include-compiler-output")]
11151115
pub include_compiler_output: bool,
1116+
1117+
/// The filename to use for the report.
1118+
#[clap(long = "report.file-name")]
1119+
pub file_name: Option<String>,
11161120
}
11171121

11181122
#[derive(Clone, Debug, Parser, Serialize, Deserialize)]

crates/report-processor/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "revive-dt-report-processor"
3+
description = "revive differential testing report processor utility"
4+
version.workspace = true
5+
authors.workspace = true
6+
license.workspace = true
7+
edition.workspace = true
8+
repository.workspace = true
9+
rust-version.workspace = true
10+
11+
[[bin]]
12+
name = "report-processor"
13+
path = "src/main.rs"
14+
15+
[dependencies]
16+
revive-dt-report = { workspace = true }
17+
revive-dt-common = { workspace = true }
18+
19+
anyhow = { workspace = true }
20+
clap = { workspace = true }
21+
serde = { workspace = true }
22+
serde_json = { workspace = true }
23+
24+
[lints]
25+
workspace = true

0 commit comments

Comments
 (0)