Skip to content

Commit b1723fc

Browse files
Centralize the eslint version between tidy and docker
1 parent f0f661d commit b1723fc

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

src/ci/docker/host-x86_64/mingw-check-tidy/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ RUN sh /scripts/nodejs.sh /node
2929
ENV PATH="/node/bin:${PATH}"
3030

3131
# Install eslint
32-
RUN npm install eslint@8.6.0
32+
COPY host-x86_64/mingw-check-tidy/eslint.version /tmp/
33+
RUN npm install eslint@$(head -n 1 /tmp/eslint.version)
3334

3435
COPY scripts/sccache.sh /scripts/
3536
RUN sh /scripts/sccache.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.6.0

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn main() {
109109
check!(rustdoc_gui_tests, &tests_path);
110110
check!(rustdoc_css_themes, &librustdoc_path);
111111
check!(rustdoc_templates, &librustdoc_path);
112-
check!(rustdoc_js, &librustdoc_path, &tools_path);
112+
check!(rustdoc_js, &librustdoc_path, &tools_path, &src_path);
113113
check!(known_bug, &crashes_path);
114114
check!(unknown_revision, &tests_path);
115115

src/tools/tidy/src/rustdoc_js.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,35 @@ fn get_eslint_version() -> Option<String> {
5151
get_eslint_version_inner(false).or_else(|| get_eslint_version_inner(true))
5252
}
5353

54-
const ESLINT_VERSION: &str = "8.6.0";
55-
56-
pub fn check(librustdoc_path: &Path, tools_path: &Path, bad: &mut bool) {
54+
pub fn check(librustdoc_path: &Path, tools_path: &Path, src_path: &Path, bad: &mut bool) {
55+
let eslint_version_path =
56+
src_path.join("ci/docker/host-x86_64/mingw-check-tidy/eslint.version");
57+
let eslint_version = match std::fs::read_to_string(&eslint_version_path) {
58+
Ok(version) => version.trim().to_string(),
59+
Err(error) => {
60+
*bad = true;
61+
eprintln!("failed to read `{}`: {error:?}", eslint_version_path.display());
62+
return;
63+
}
64+
};
5765
match get_eslint_version() {
5866
Some(version) => {
59-
if version != ESLINT_VERSION {
67+
if version != eslint_version {
6068
*bad = true;
6169
eprintln!(
6270
"⚠️ Installed version of eslint (`{version}`) is different than the \
63-
one used in the CI (`{ESLINT_VERSION}`)",
71+
one used in the CI (`{eslint_version}`)",
6472
);
6573
eprintln!(
6674
"You can install this version using `npm update eslint` or by using \
67-
`npm install eslint@{ESLINT_VERSION}`",
75+
`npm install eslint@{eslint_version}`",
6876
);
6977
return;
7078
}
7179
}
7280
None => {
7381
eprintln!("`eslint` doesn't seem to be installed. Skipping tidy check for JS files.");
74-
eprintln!("You can install it using `npm install eslint@{ESLINT_VERSION}`");
82+
eprintln!("You can install it using `npm install eslint@{eslint_version}`");
7583
return;
7684
}
7785
}

0 commit comments

Comments
 (0)