summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2023-02-08 17:05:27 -0600
committerFederico Mena Quintero <federico@gnome.org>2023-02-08 17:05:27 -0600
commit2361cec201595fd23234e43627d888e632e13176 (patch)
tree5073ee74c5366d39fdbadb8570aedb04e59c600c
parent23e68891c76ff1a392e1bdff2383b0d7373d4a5c (diff)
downloadlibrsvg-2361cec201595fd23234e43627d888e632e13176.tar.gz
CI: Add a lint for the various MSRVs we mention in the source tree
ci/check_rust_versions.py is a script that checks that all the mentioned *minimum* Rust versions (configure.ac, Cargo.toml, etc.) are the same. I don't think we mention the "stable" Rust version anywhere but ci/container_builds.yml, so we don't need a check for that one. Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/792>
-rw-r--r--.gitlab-ci.yml8
-rw-r--r--Cargo.toml2
-rw-r--r--ci/check_rust_versions.py47
-rw-r--r--configure.ac2
-rw-r--r--devel-docs/devel_environment.rst2
5 files changed, 58 insertions, 3 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c50ea948..66511053 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -314,6 +314,14 @@ deny:
script:
- cargo deny check
+check_rust_versions:
+ extends:
+ - '.container.opensuse@x86_64.stable'
+ - '.fdo.distribution-image@opensuse'
+ stage: lint
+ script:
+ - python3 ci/check_rust_versions.py
+
coverage:
extends:
- '.container.opensuse@x86_64.stable'
diff --git a/Cargo.toml b/Cargo.toml
index 38d52ae5..2c1a936b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ homepage = "https://wiki.gnome.org/Projects/LibRsvg"
repository = "https://gitlab.gnome.org/GNOME/librsvg/"
build = "build.rs"
edition = "2021"
-rust-version = "1.64"
+rust-version = "1.64.0"
[profile.overflow]
inherits = "release"
diff --git a/ci/check_rust_versions.py b/ci/check_rust_versions.py
new file mode 100644
index 00000000..56aac1a4
--- /dev/null
+++ b/ci/check_rust_versions.py
@@ -0,0 +1,47 @@
+# This script checks that the Minimum Supported Rust Version (MSRV) has the same value
+# in several places throughout the source tree.
+
+import re
+import sys
+
+PLACES_TO_CHECK = [
+ ['configure.ac', r'MINIMUM_RUST_VER=(.*)'],
+ ['Cargo.toml', r'rust-version\s*=\s*"(.*)"'],
+ ['ci/container_builds.yml', r'RUST_MINIMUM:\s*"(.*)"'],
+ ['devel-docs/devel_environment.rst', r'rust (.*) or later'],
+]
+
+versions = []
+
+for filename, regex in PLACES_TO_CHECK:
+ r = re.compile(regex)
+
+ with open(filename) as f:
+ matched = False
+ for idx, line in enumerate(f.readlines()):
+ matches = r.search(line)
+ if matches is not None:
+ matched = True
+ line_number = idx + 1
+ versions.append([filename, line_number, matches.group(1), line])
+
+ if not matched:
+ raise Exception(f'file {filename} does not have a line that matches {regex}')
+
+assert len(versions) > 0
+
+all_the_same = True
+
+for filename, line_number, version, line in versions[1:]:
+ if version != versions[0][2]:
+ all_the_same = False
+
+if not all_the_same:
+ print(f'Version numbers do not match in these lines, please fix them!\n', file=sys.stderr)
+
+ for filename, line_number, version, line in versions:
+ print(f'{filename}:{line_number}: {line}', file=sys.stderr)
+
+ sys.exit(1)
+
+print(f'Versions number match. All good!', file=sys.stderr)
diff --git a/configure.ac b/configure.ac
index eff90d06..a656c2d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,7 +108,7 @@ AS_IF(test x$RUSTC = xno,
dnl MSRV - Minimum Supported Rust Version
dnl If you change this, please update the "_manual_setup" section of devel-docs/devel_environment.rst
dnl keep in sync with Cargo.toml
-MINIMUM_RUST_VER=1.64
+MINIMUM_RUST_VER=1.64.0
rust_version=`$RUSTC --version | sed -e 's/^rustc //g'`
AX_COMPARE_VERSION([$rust_version],[lt],[$MINIMUM_RUST_VER], [
AC_MSG_ERROR([librsvg needs at least rustc version $MINIMUM_RUST_VER])
diff --git a/devel-docs/devel_environment.rst b/devel-docs/devel_environment.rst
index b9e572fc..5c944909 100644
--- a/devel-docs/devel_environment.rst
+++ b/devel-docs/devel_environment.rst
@@ -103,7 +103,7 @@ minimum version is listed here; you may use a newer version instead.
**Compilers and build tools:**
* a C compiler and `make` tool; we recommend GNU `make`.
-* rust 1.64 or later
+* rust 1.64.0 or later
* cargo
* autoconf, automake, libtool, itstool
* vala (optional)