From a17ded8b9a0ab7f5c9617f39234a3ea650296ac6 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Wed, 2 Aug 2023 11:49:15 -0500 Subject: [PATCH 01/23] update cargo.toml for MSRV optimization --- Cargo.toml | 14 ++++++------- frb_codegen/Cargo.toml | 20 ++++++++++--------- frb_example/pure_dart/rust/Cargo.toml | 12 ++++++----- frb_example/pure_dart/rust/Cargo.toml.release | 2 ++ .../pure_dart/rust/external/Cargo.toml | 2 ++ frb_example/pure_dart_multi/rust/Cargo.toml | 2 ++ .../pure_dart_multi/rust/Cargo.toml.release | 2 ++ frb_example/with_flutter/rust/Cargo.toml | 14 +++++++------ .../with_flutter/rust/Cargo.toml.release | 4 +++- frb_macros/Cargo.toml | 2 ++ frb_rust/Cargo.toml | 20 ++++++++++--------- 11 files changed, 57 insertions(+), 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1187c466da..11a9878a32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [workspace] members = [ - "frb_codegen", - "frb_rust", - "frb_macros", - "frb_example/pure_dart/rust", - "frb_example/pure_dart_multi/rust", - "frb_example/with_flutter/rust", + "frb_codegen", + "frb_rust", + "frb_macros", + "frb_example/pure_dart/rust", + "frb_example/pure_dart_multi/rust", + "frb_example/with_flutter/rust", ] [workspace.package] @@ -31,4 +31,4 @@ flutter_rust_bridge_codegen = { path = "frb_codegen", version = "1" } [profile.release.package.flutter_rust_bridge_codegen] strip = "debuginfo" -debug = 1 # preserves some debug information \ No newline at end of file +debug = 1 # preserves some debug information diff --git a/frb_codegen/Cargo.toml b/frb_codegen/Cargo.toml index 0f96527a3a..69132f64a5 100644 --- a/frb_codegen/Cargo.toml +++ b/frb_codegen/Cargo.toml @@ -1,10 +1,12 @@ +cargo-features = ["workspace-inheritance"] + [package] +name = "flutter_rust_bridge_codegen" categories.workspace = true description.workspace = true edition.workspace = true keywords.workspace = true license.workspace = true -name = "flutter_rust_bridge_codegen" repository.workspace = true version.workspace = true @@ -17,25 +19,25 @@ name = "flutter_rust_bridge_codegen" path = "src/main.rs" [dependencies] -anyhow = {workspace = true} -thiserror = {workspace = true} +anyhow = { workspace = true } +thiserror = { workspace = true } cargo_metadata = "0.14.1" convert_case = "0.5.0" delegate = "0.8.0" enum_dispatch = "0.3.8" itertools = "0.10.3" -lazy_static = {workspace = true} +lazy_static = { workspace = true } log = "0.4" -fern = { version = "0.6.0", features = ["date-based","colored"] } +fern = { version = "0.6.0", features = ["date-based", "colored"] } atty = "0.2.14" chrono = "0.4" pathdiff = "0.2.1" quote = "1.0" regex = "1.5.4" -serde = {version = "1.0", features = ["derive"]} +serde = { version = "1.0", features = ["derive"] } serde_yaml = "0.8" strum_macros = "0.24.3" -syn = {version = "2.0.26", features = ["full", "extra-traits"]} +syn = { version = "2.0.26", features = ["full", "extra-traits"] } tempfile = "3.2.0" toml = "0.5.8" topological-sort = "0.2.2" @@ -50,8 +52,8 @@ semver = "1.0.12" bin-dir = "{bin}{binary-ext}" [package.metadata.binstall.overrides] -i686-pc-windows-msvc = {pkg-fmt = "zip"} -x86_64-pc-windows-msvc = {pkg-fmt = "zip"} +i686-pc-windows-msvc = { pkg-fmt = "zip" } +x86_64-pc-windows-msvc = { pkg-fmt = "zip" } [features] default = ["chrono", "serde", "uuid", "anyhow/backtrace"] diff --git a/frb_example/pure_dart/rust/Cargo.toml b/frb_example/pure_dart/rust/Cargo.toml index ff9f066aec..943b968063 100644 --- a/frb_example/pure_dart/rust/Cargo.toml +++ b/frb_example/pure_dart/rust/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_example_single_block_test" version = "1.0.0" @@ -12,8 +14,8 @@ wasm-start = ["flutter_rust_bridge/wasm-start"] [build-dependencies] flutter_rust_bridge_codegen = { workspace = true, features = [ - "chrono", - "uuid", + "chrono", + "uuid", ] } [dependencies] @@ -21,9 +23,9 @@ anyhow = { workspace = true, features = ["backtrace"] } lazy_static = { workspace = true } chrono = { workspace = true } flutter_rust_bridge = { workspace = true, features = [ - "chrono", - "uuid", - "worker-max", + "chrono", + "uuid", + "worker-max", ] } uuid = { workspace = true } log = "0.4" diff --git a/frb_example/pure_dart/rust/Cargo.toml.release b/frb_example/pure_dart/rust/Cargo.toml.release index 2847dfb83b..5fd380141c 100644 --- a/frb_example/pure_dart/rust/Cargo.toml.release +++ b/frb_example/pure_dart/rust/Cargo.toml.release @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_example_single_block_test" version = "1.0.0" diff --git a/frb_example/pure_dart/rust/external/Cargo.toml b/frb_example/pure_dart/rust/external/Cargo.toml index cdf73f45ea..9b65c6899e 100644 --- a/frb_example/pure_dart/rust/external/Cargo.toml +++ b/frb_example/pure_dart/rust/external/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_example_external" version = "0.1.0" diff --git a/frb_example/pure_dart_multi/rust/Cargo.toml b/frb_example/pure_dart_multi/rust/Cargo.toml index 8fe882108b..c179ff34d3 100644 --- a/frb_example/pure_dart_multi/rust/Cargo.toml +++ b/frb_example/pure_dart_multi/rust/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_example_multi_blocks_test" version = "1.0.0" diff --git a/frb_example/pure_dart_multi/rust/Cargo.toml.release b/frb_example/pure_dart_multi/rust/Cargo.toml.release index 577f5dc680..3dca671fc4 100644 --- a/frb_example/pure_dart_multi/rust/Cargo.toml.release +++ b/frb_example/pure_dart_multi/rust/Cargo.toml.release @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_example_multi_blocks_test" version = "1.0.0" diff --git a/frb_example/with_flutter/rust/Cargo.toml b/frb_example/with_flutter/rust/Cargo.toml index 62d20c1d2c..610b15763f 100644 --- a/frb_example/with_flutter/rust/Cargo.toml +++ b/frb_example/with_flutter/rust/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_example" version = "0.1.0" @@ -9,13 +11,13 @@ crate-type = ["cdylib"] [build-dependencies] flutter_rust_bridge_codegen = { workspace = true, features = [ - "chrono", - "uuid", + "chrono", + "uuid", ] } [dependencies] anyhow = { workspace = true, features = ["backtrace"] } -flutter_rust_bridge = { workspace = true, features = ["chrono"]} -num = "0.4" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. -image = "0.24.3" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. -crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. +flutter_rust_bridge = { workspace = true, features = ["chrono"] } +num = "0.4" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. +image = "0.24.3" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. +crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. diff --git a/frb_example/with_flutter/rust/Cargo.toml.release b/frb_example/with_flutter/rust/Cargo.toml.release index 629bf74bc3..ce17b2627e 100644 --- a/frb_example/with_flutter/rust/Cargo.toml.release +++ b/frb_example/with_flutter/rust/Cargo.toml.release @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_example" version = "0.1.0" @@ -12,4 +14,4 @@ anyhow = { workspace = true, features = ["backtrace"] } flutter_rust_bridge = { version = "1" } num = "0.4" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. image = "0.24.3" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. -crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. \ No newline at end of file +crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos. diff --git a/frb_macros/Cargo.toml b/frb_macros/Cargo.toml index 428e25aa05..48c2a7f54f 100644 --- a/frb_macros/Cargo.toml +++ b/frb_macros/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge_macros" version.workspace = true diff --git a/frb_rust/Cargo.toml b/frb_rust/Cargo.toml index 9294035ac5..ef57553a39 100644 --- a/frb_rust/Cargo.toml +++ b/frb_rust/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["workspace-inheritance"] + [package] name = "flutter_rust_bridge" version.workspace = true @@ -31,15 +33,15 @@ console_error_panic_hook = { version = "0.1.7", optional = true } wasm-bindgen = { version = "0.2.81" } js-sys = { version = "0.3.60" } web-sys = { version = "0.3.58", features = [ - "DedicatedWorkerGlobalScope", - "MessageEvent", - "MessagePort", - "ErrorEvent", - "Blob", - "BlobPropertyBag", - "Worker", - "Url", - "BroadcastChannel", + "DedicatedWorkerGlobalScope", + "MessageEvent", + "MessagePort", + "ErrorEvent", + "Blob", + "BlobPropertyBag", + "Worker", + "Url", + "BroadcastChannel", ] } [build-dependencies] From 84914640650bf14b479a792c4e779fef81b1105f Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Wed, 2 Aug 2023 13:37:08 -0500 Subject: [PATCH 02/23] (feat): add MSRV --- .github/workflows/ci.yaml | 46 --------------- .github/workflows/msrv.yml | 72 +++++++++++++++++++++++ .gitignore | 3 +- .msrv | 1 + .nightly_msrv | 1 + README.md | 4 +- book/src/msrv.md | 19 ++++++ clippy.toml | 19 ++++++ justfile | 7 +++ tools/find_msrv.sh | 116 +++++++++++++++++++++++++++++++++++++ tools/find_nightly_msrv.sh | 101 ++++++++++++++++++++++++++++++++ 11 files changed, 341 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/msrv.yml create mode 100644 .msrv create mode 100644 .nightly_msrv create mode 100644 book/src/msrv.md create mode 100644 clippy.toml create mode 100755 tools/find_msrv.sh create mode 100755 tools/find_nightly_msrv.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 27bc8151e3..1a241f3ff3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -477,49 +477,3 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: just ci_codegen - - # -------------- MSRV & specific version testing -------------- - msrv: - name: MSRV & specific version testing - runs-on: ubuntu-latest # as of now, there is no real reason to test on multiple OSs - strategy: - matrix: - rust_version: - - nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152 - - nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152 - - nightly # latest nightly - # TODO(@fzyzcjy, @gutenfries): add MSRV here, as well as other locked versions as needed - - steps: - - uses: actions/checkout@v2 - - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ matrix.rust_version }} - components: rustfmt, clippy - - # cache rust toolchains to reduce build time - # automaticly updates cache if Cargo.lock changes, ie, if nightly-latest changes - - uses: actions/cache@v3 - with: - path: ~/.cargo - key: ${{ runner.os }}-rust-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-rust-${{ matrix.rust_version }}- - ${{ runner.os }}-rust- - ${{ runner.os }}- - - - uses: subosito/flutter-action@v2 - with: - cache: true - channel: "stable" - flutter-version: 3.10.0 - architecture: x64 - - - uses: extractions/setup-just@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - run: just install_ffigen_dependency - - run: just dart_pub_get dart_only - - run: just rust_build_and_test diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml new file mode 100644 index 0000000000..30b96039fe --- /dev/null +++ b/.github/workflows/msrv.yml @@ -0,0 +1,72 @@ +name: MSRV + +on: + push: + paths-ignore: + - "docs/**" + - "**/*.md" + pull_request: + paths-ignore: + - "docs/**" + - "**/*.md" + workflow_dispatch: {} + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + # -------------- MSRV & specific version testing -------------- + msrv: + name: MSRV & specific version testing + runs-on: ubuntu-latest # as of now, there is no real reason to test on multiple OSs + strategy: + matrix: + rust_version: + - nightly # latest nightly + - nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152 + - nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152 + # + # DO NOT EDIT BELOW THIS LINE + # + - nightly-2022-07-15 ### nightly MSRV (DO NOT EDIT THIS LINE): + - 1.64 ### stable MSRV (DO NOT EDIT THIS LINE): + # + # DO NOT EDIT ABOVE THIS LINE + # + + steps: + - uses: actions/checkout@v2 + + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust_version }} + components: rustfmt, clippy + + # cache cargo and rustup to reduce future build times as much as possible + - uses: actions/cache@v2 + with: + path: | + ~/.cargo + ~/.rustup + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - uses: subosito/flutter-action@v2 + with: + cache: true + channel: "stable" + flutter-version: 3.10.0 + architecture: x64 + + - uses: extractions/setup-just@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: just install_ffigen_dependency + - run: just dart_pub_get dart_only + - run: just rust_build_and_test diff --git a/.gitignore b/.gitignore index 26cf78b1c8..3810160a54 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ launch.json .local-chromium Makefile *.log -.vscode \ No newline at end of file +.vscode +*.bak diff --git a/.msrv b/.msrv new file mode 100644 index 0000000000..8725364a8e --- /dev/null +++ b/.msrv @@ -0,0 +1 @@ +1.64 diff --git a/.nightly_msrv b/.nightly_msrv new file mode 100644 index 0000000000..17c738fa4c --- /dev/null +++ b/.nightly_msrv @@ -0,0 +1 @@ +nightly-2022-07-15 diff --git a/README.md b/README.md index 0b1ced0f06..ed6af04ff2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ [![CI](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/ci.yaml/badge.svg)](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/ci.yaml) [![Example](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/post_release.yaml/badge.svg)](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/post_release.yaml) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6afbdad19e7245adbf9e9771777be3d7)](https://app.codacy.com/gh/fzyzcjy/flutter_rust_bridge?utm_source=github.com&utm_medium=referral&utm_content=fzyzcjy/flutter_rust_bridge&utm_campaign=Badge_Grade_Settings) +[![Minimum Supported Stable Rust Version](https://img.shields.io/badge/stable_msrv-1.64+-green.svg)](/.msrv) +[![Minimum Supported Nightly Rust Version](https://img.shields.io/badge/nightly_msrv-nightly--2022--07--15+-orange.svg)](/.nightly_msrv) ![Logo](https://github.com/fzyzcjy/flutter_rust_bridge/raw/master/book/logo.png) @@ -28,7 +30,7 @@ Check out [the user guide](https://fzyzcjy.github.io/flutter_rust_bridge/) for [ ## 📎 P.S. Achieve ~60 FPS, no matter how janky the Flutter app was due to build/layout -Here is my another open-source library :) https://github.com/fzyzcjy/flutter_smooth. +Here is my another open-source library :) . ## ✨ Contributors diff --git a/book/src/msrv.md b/book/src/msrv.md new file mode 100644 index 0000000000..1d4023a8b0 --- /dev/null +++ b/book/src/msrv.md @@ -0,0 +1,19 @@ +# MSRV + +The MSRV (Minimum Supported Rust Version) is the oldest version of Rust that +this crate is guaranteed to work with. + +The MSRV(s) for `flutter_rust_bridge` are as follows: + +| Channel | MSRV | +| ------- | ---- | +| stable | `1.64+` | +| nightly | `nightly-2022-07-15+` | + +These versions are CI tested and _guaranteed_ to compile, +given there are no external error factors. + +The MSRV is subject to change without prior notice in major/minor releases of `flutter_rust_bridge`, +but we do our best to keep it as low as possible. + +The MSRV is also stated in the [`README.md`](/README.md). diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000000..a623004f86 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,19 @@ +msrv = "1.64" + +# https://doc.rust-lang.org/nightly/clippy/lint_configuration.html#avoid-breaking-exported-api +avoid-breaking-exported-api = true + +# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods +disallowed-methods = [ + "std::time::Instant::now", # use `instant` crate instead for wasm/web compatibility + "std::time::Duration::elapsed", # use `instant` crate instead for wasm/web compatibility + "std::time::SystemTime::now", # use `instant` or `time` crates instead for wasm/web compatibility + "std::thread::spawn", # Cannot spawn threads on wasm + # TODO(@fzyzcjy): add methods here as needed + +] + +# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types +disallowed-types = [ + # TODO(@fzyzcjy): add types here as needed +] diff --git a/justfile b/justfile index f967f1d0ad..caa8f09e99 100644 --- a/justfile +++ b/justfile @@ -194,6 +194,10 @@ ci_codegen: just generate_all just check_no_git_diff +msrv: + bash tools/find_msrv.sh + bash tools/find_nightly_msrv.sh + # ============================ misc ============================ clean: @@ -310,6 +314,9 @@ _install_crate name="cargo-lipo": else echo "Already installed the correct version of $PACKAGE_NAME." fi + + + # ============================ to be migrated ============================ # TODO - @Desdaemon diff --git a/tools/find_msrv.sh b/tools/find_msrv.sh new file mode 100755 index 0000000000..6279c13952 --- /dev/null +++ b/tools/find_msrv.sh @@ -0,0 +1,116 @@ +#! /bin/bash + +# +# Ensure all necessary dependencies are installed +# + +if ! command -v rustup >/dev/null 2>&1; then + echo -e "\e[34mINFO: rustup is not installed, attempting to install...\e[0m" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + # refresh environment to load rustup + source "$HOME"/.cargo/env +fi + +# Determines if a passed version of rust is compatible with the evaluated crate +function is_compatible() { + local version="$1" + + # use rustup to install the version of rust + rustup install "1.$version" --profile default + rustup default "1.$version" + + # check if the crate compiles with the version of rust + if cargo check --all; then + echo -e "\e[32mSUCCESS: Found compatible version: 1.$version\e[0m" + return 0 + else + echo -e "\e[31mINFO: Version 1.$version is not compatible\e[0m" + return 1 + fi +} + +# copy the currently installed toolchain to restore later +current_toolchain=$(rustup show active-toolchain | cut -d ' ' -f 1) + +declare -A rust_editions=( + ["2015"]="0" # -> "1.0.x" + ["2018"]="31" # -> "1.31.x" + ["2021"]="51" # -> "1.51.x" + # Extend as necessary +) + +# check for the declared edition of the crate +edition=$(grep -m 1 "edition" Cargo.toml | cut -d '"' -f 2) + +# earliest version to check for compatibility +start_version="${rust_editions[$edition]}" + +# pull the latest tag from the rust repo +end_version=$(curl https://api.github.com/repos/rust-lang/rust/releases/latest | grep -m 1 "tag_name" | cut -d '"' -f 4 | cut -d '.' -f 2) + +# use binary search to find the earliest compatible version of rust +while [[ "$start_version" -lt "$end_version" ]]; do + # Display the progress: ruled-out count / total count + echo -e "\e[36mINFO: Searching between $start_version and $end_version\e[0m" + + # Calculate the midpoint version + mid_version="$(((start_version + end_version) / 2))" + + # check if the crate is compatible with the version of rust + if is_compatible "$mid_version"; then + # If compatible, upversion the end version for the next iteration + end_version="$mid_version" + else + # If not compatible, upversion the start version for the next iteration + start_version="$((mid_version + 1))" + fi +done + +echo -e "\e[32mSUCCESS: Found Minimum Supported Rust Version: 1.$end_version\e[0m" + +echo -e "\e[34mINFO: Writing .msrv ...\e[0m" + +echo -e "1.$end_version" >.msrv + +echo -e "\e[32mSUCCESS: Successfully wrote .msrv\e[0m" + +echo -e "\e[34mINFO: Updating README.md\e[0m" + +# find and update: +# https://img.shields.io/badge/stable_msrv-1.6+-green.svg + +sed -i.bak "s/stable_msrv-1.[0-9]\+\+/stable_msrv-1.$end_version/g" README.md + +echo -e "\e[32mSUCCESS: Successfully updated README.md\e[0m" + +echo -e "\e[34mINFO: Updating clippy.toml\e[0m" + +# find and update: +# msrv = "1.6" + +sed -i.bak "s/msrv = \"1.[0-9]\+\"/msrv = \"1.$end_version\"/g" clippy.toml + +echo -e "\e[32mSUCCESS: Successfully updated clippy.toml\e[0m" + +echo -e "\e[34mINFO: Updating book/src/msrv.md\e[0m" + +# find and update: +# `1.45+` + +sed -i.bak "s/ \`1.[0-9]\+\+/ \`1.$end_version/g" book/src/msrv.md + +echo -e "\e[32mSUCCESS: Successfully updated book/src/msrv.md\e[0m" + +echo -e "\e[34mINFO: Updating .github/workflows/msrv.yml\e[0m" + +# find and update: +# - 1.45 ### stable MSRV (DO NOT EDIT THIS LINE): + +sed -i.bak "s/- 1.[0-9]\+ ### stable MSRV (DO NOT EDIT THIS LINE):/- 1.$end_version ### stable MSRV (DO NOT EDIT THIS LINE):/g" .github/workflows/msrv.yml + +echo -e "\e[32mSUCCESS: Successfully updated .github/workflows/msrv.yml\e[0m" + +echo -e "\e[34mINFO: Restoring toolchain: $current_toolchain\e[0m" + +# restore the original toolchain +rustup default "$current_toolchain" diff --git a/tools/find_nightly_msrv.sh b/tools/find_nightly_msrv.sh new file mode 100755 index 0000000000..4b1e043b66 --- /dev/null +++ b/tools/find_nightly_msrv.sh @@ -0,0 +1,101 @@ +#! /bin/bash + +# +# Ensure all necessary dependencies are installed +# + +if ! command -v rustup >/dev/null 2>&1; then + echo -e "\e[34mINFO: rustup is not installed, attempting to install...\e[0m" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + # refresh environment to load rustup + source "$HOME"/.cargo/env +fi + +# Determines if a passed version of rust is compatible with the evaluated crate +function is_compatible() { + local version="$1" + + # use rustup to install the version of rust + rustup install "nightly-$version" --profile default + rustup default "nightly-$version" + + # check if the crate compiles with the version of rust + if cargo check --all; then + echo -e "\e[32mSUCCESS: Found compatible version: $version\e[0m" + return 0 + else + echo -e "\e[31mINFO: Version $version is not compatible\e[0m" + return 1 + fi +} + +# copy the currently installed toolchain to restore later +current_toolchain=$(rustup show active-toolchain | cut -d ' ' -f 1) + +# check for the declared edition of the crate +edition=$(grep -m 1 "edition" Cargo.toml | cut -d '"' -f 2) +# earliest date to check for compatibility +start_date="$edition-01-01" +msrv=$(date +%Y-%m-%d) + +# Calculate the end date for the binary search +end_date="$msrv" + +# use binary search to find the earliest compatible version of rust +while [[ "$start_date" != "$end_date" ]]; do + # Display the progress: ruled-out count / total count + echo -e "\e[36mINFO: Searching between $start_date and $end_date\e[0m" + + # Calculate the midpoint date + mid_date=$(date -d "$start_date + $((($(date -d "$end_date" +%s) - $(date -d "$start_date" +%s)) / 2)) seconds" +"%Y-%m-%d") + + # check if the crate is compatible with the version of rust + if is_compatible "$mid_date"; then + # If compatible, update the end date for the next iteration + end_date="$mid_date" + else + # If not compatible, update the start date for the next iteration + start_date=$(date -d "$mid_date + 1 day" +"%Y-%m-%d") + fi +done + +echo -e "\e[32mSUCCESS: Found Minimum Supported Rust Version: nightly-$end_date\e[0m" + +echo -e "\e[34mINFO: Writing .nightly_msrv ...\e[0m" + +echo -e "nightly-$end_date" >.nightly_msrv + +echo -e "\e[32mSUCCESS: Successfully wrote .nightly_msrv\e[0m" + +echo -e "\e[34mINFO: Updating README.md\e[0m" + +# find and update: +# https://img.shields.io/badge/nightly_msrv-nightly--2021--08--04+-orange.svg + +# replace single dashes with double dashes +sed -i.bak "s/nightly_msrv-nightly--.*+-orange.svg/nightly_msrv-nightly--${end_date//-/--}+-orange.svg/g" README.md + +echo -e "\e[32mSUCCESS: Successfully updated README.md\e[0m" + +echo -e "\e[34mINFO: Updating book/src/msrv.md\e[0m" + +# find and update: +# `nightly-2023-56-89+` + +sed -i.bak "s/ \`nightly-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}+\` |/ \`nightly-${end_date}+\` |/g" book/src/msrv.md + +echo -e "\e[32mSUCCESS: Successfully updated book/src/msrv.md\e[0m" + +echo -e "\e[34mINFO: Updating .github/workflows/msrv.yml\e[0m" + +# find and update: +# - nightly-2023-06-28 ### nightly MSRV (DO NOT EDIT THIS LINE): + +sed -i.bak "s/- nightly-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} ### nightly MSRV (DO NOT EDIT THIS LINE):/- nightly-${end_date} ### nightly MSRV (DO NOT EDIT THIS LINE):/g" .github/workflows/msrv.yml + +echo -e "\e[32mSUCCESS: Successfully updated .github/workflows/msrv.yml\e[0m" + +echo -e "\e[34mINFO: Restoring toolchain: $current_toolchain\e[0m" + +# restore the original toolchain +rustup default "$current_toolchain" From bcbaf7b37e0b85f75105c706108aa30c06572351 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 12:03:11 -0500 Subject: [PATCH 03/23] impliment msrv CI --- .github/workflows/ci.yaml | 51 ++++++ .github/workflows/msrv.yml | 72 -------- .github/workflows/update_msrv.yml | 168 ++++++++++++++++++ .nightly_msrv => tools/.nightly_msrv | 0 .msrv => tools/.stable_msrv | 0 .../{find_nightly_msrv.sh => nightly_msrv.sh} | 8 +- tools/{find_msrv.sh => stable_msrv.sh} | 8 +- 7 files changed, 227 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/msrv.yml create mode 100644 .github/workflows/update_msrv.yml rename .nightly_msrv => tools/.nightly_msrv (100%) rename .msrv => tools/.stable_msrv (100%) rename tools/{find_nightly_msrv.sh => nightly_msrv.sh} (93%) rename tools/{find_msrv.sh => stable_msrv.sh} (94%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1a241f3ff3..7db86b7ff0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -477,3 +477,54 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: just ci_codegen + + msrv: + name: test MSRV and specific problematic versions + runs-on: ubuntu-latest # as of now, there is no real reason to test on multiple OSs + strategy: + matrix: + rust_version: + - nightly # latest nightly + - nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152 + - nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152 + # + # DO NOT EDIT BELOW THIS LINE + # + - nightly-2022-07-15 ### nightly MSRV (DO NOT EDIT THIS LINE): + - 1.64 ### stable MSRV (DO NOT EDIT THIS LINE): + # + # DO NOT EDIT ABOVE THIS LINE + # + + steps: + - uses: actions/checkout@v2 + + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust_version }} + components: rustfmt, clippy + + # cache cargo and rustup to reduce future build times as much as possible + - uses: actions/cache@v2 + with: + path: | + ~/.cargo + ~/.rustup + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - uses: subosito/flutter-action@v2 + with: + cache: true + channel: "stable" + flutter-version: 3.10.0 + architecture: x64 + + - uses: extractions/setup-just@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: just install_ffigen_dependency + - run: just dart_pub_get dart_only + - run: just rust_build_and_test diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml deleted file mode 100644 index 30b96039fe..0000000000 --- a/.github/workflows/msrv.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: MSRV - -on: - push: - paths-ignore: - - "docs/**" - - "**/*.md" - pull_request: - paths-ignore: - - "docs/**" - - "**/*.md" - workflow_dispatch: {} - -env: - CARGO_TERM_COLOR: always - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - # -------------- MSRV & specific version testing -------------- - msrv: - name: MSRV & specific version testing - runs-on: ubuntu-latest # as of now, there is no real reason to test on multiple OSs - strategy: - matrix: - rust_version: - - nightly # latest nightly - - nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152 - - nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152 - # - # DO NOT EDIT BELOW THIS LINE - # - - nightly-2022-07-15 ### nightly MSRV (DO NOT EDIT THIS LINE): - - 1.64 ### stable MSRV (DO NOT EDIT THIS LINE): - # - # DO NOT EDIT ABOVE THIS LINE - # - - steps: - - uses: actions/checkout@v2 - - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ matrix.rust_version }} - components: rustfmt, clippy - - # cache cargo and rustup to reduce future build times as much as possible - - uses: actions/cache@v2 - with: - path: | - ~/.cargo - ~/.rustup - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - uses: subosito/flutter-action@v2 - with: - cache: true - channel: "stable" - flutter-version: 3.10.0 - architecture: x64 - - - uses: extractions/setup-just@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - run: just install_ffigen_dependency - - run: just dart_pub_get dart_only - - run: just rust_build_and_test diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml new file mode 100644 index 0000000000..86b7884dea --- /dev/null +++ b/.github/workflows/update_msrv.yml @@ -0,0 +1,168 @@ +name: MSRV + +on: + push: + paths-ignore: + - "docs/**" + - "**/*.md" + pull_request: + paths-ignore: + - "docs/**" + - "**/*.md" + workflow_dispatch: {} + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + check_msrv: + name: Check MSRV && update accordingly + strategy: + matrix: + toolchain: + - stable + - nightly + + runs-on: ubuntu-latest + + steps: + # checkout sources + - uses: actions/checkout@v2 + + # ensure rustup is installed + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + + # set initial msrvs (.msrv, .nightly_msrv) as env vars + - name: Store initial MSRVs + run: echo "::set-env name=OLD_MSRV::$(cat tools/.${{ matrix.toolchain }}_msrv)" + + + # run the MSRV check (tools/{toolchain}_msrv.sh) for the current toolchain + - name: Check MSRV + run: | + ./tools/${{ matrix.toolchain }}_msrv.sh + + + # Store the new MSRV as an env var + - name: Store new MSRV + run: echo "::set-env name=NEW_MSRV::$(cat .${{ matrix.toolchain }}_msrv)" + + + # If MSRV has not changed, exit early + - name: Exit early if MSRV has not changed + run: | + if [ "${{ env.OLD_MSRV }}" = "${{ env.NEW_MSRV }}" ]; then + echo "MSRV has not changed, exiting early" + exit 0 + fi + + # add, commit, and push changes, if any + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + # Optional. Commit message for the created commit. + # Defaults to "Apply automatic changes" + commit_message: Update MSRV for toolchain ${{ matrix.toolchain }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) + + # # Optional. Create given branch name in local and remote repository. + # create_branch: true + + # # Optional. Local and remote branch name where commit is going to be pushed to. + # # Defaults to the current branch. + # branch: update_msrv + + # Optional. Options used by `git-commit`. + # See https://git-scm.com/docs/git-commit#_options + commit_options: "--no-verify --signoff" + + # Optional glob pattern of files which should be added to the commit. + # Defaults to all (.) + # + ### We only want to track the following files: + ### + ### .github/workflows/ci.yml + ### clippy.toml + ### README.md + ### .nightly_msrv + ### .msrv + file_pattern: "{README.md,.github/workflows/ci.yml,.msrv,.nightly_msrv,clippy.toml}" + + # # Optional. Local file path to the repository. Defaults to the root of the repository. + # repository: . + + # # Optional commit user and author settings + # commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" + # commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" + # commit_author: Author # defaults to author of the commit that triggered the run + + # # Optional. Tag name being created in the local repository and + # # pushed to remote repository and defined branch. + # tagging_message: 'v1.0.0' + + # # Optional. Options used by `git-add`. + # # See https://git-scm.com/docs/git-add#_options + # add_options: '-u' + + # # Optional. Options used by `git-push`. + # # See https://git-scm.com/docs/git-push#_options + # push_options: '--force' + + # Optional. Disable dirty check and always try to create a commit and push + skip_dirty_check: true + + # # Optional. Option used by `git-status` to determine if the repository is + # # dirty. See https://git-scm.com/docs/git-status#_options + # status_options: '--untracked-files=no' + + # Optional. Skip internal call to `git fetch` + skip_fetch: true + + # Optional. Skip internal call to `git checkout` + skip_checkout: false + + # Optional. Prevents the shell from expanding filenames. + # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html + disable_globbing: false + + # # open a PR if the MSRV has changed + # - name: Create Pull Request + # uses: peter-evans/create-pull-request@v5 + # with: + # token: ${{ secrets.PAT }} + # commit-message: Update MSRV + # committer: GitHub + # author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + # signoff: false + # branch: msrv + # delete-branch: false + # title: "(chore): Update MSRV" + # body: | + # Update MSRV + # - Updated MSRV for ${{ matrix.toolchain }} on ${{ matrix.os }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) + # - Auto-generated by [create-pull-request][1] + # + # [1]: https://github.com/peter-evans/create-pull-request + # labels: | + # msrv + # assignees: fzyzcjy + # reviewers: fzyzcjy + # milestone: 1 + # draft: false + + # Cache cargo and rustup for faster subsequent runs + - uses: actions/cache@v2 + with: + path: | + ~/.cargo + ~/.rustup + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + diff --git a/.nightly_msrv b/tools/.nightly_msrv similarity index 100% rename from .nightly_msrv rename to tools/.nightly_msrv diff --git a/.msrv b/tools/.stable_msrv similarity index 100% rename from .msrv rename to tools/.stable_msrv diff --git a/tools/find_nightly_msrv.sh b/tools/nightly_msrv.sh similarity index 93% rename from tools/find_nightly_msrv.sh rename to tools/nightly_msrv.sh index 4b1e043b66..c8cec3cd74 100755 --- a/tools/find_nightly_msrv.sh +++ b/tools/nightly_msrv.sh @@ -61,11 +61,11 @@ done echo -e "\e[32mSUCCESS: Found Minimum Supported Rust Version: nightly-$end_date\e[0m" -echo -e "\e[34mINFO: Writing .nightly_msrv ...\e[0m" +echo -e "\e[34mINFO: Writing tools/.nightly_msrv ...\e[0m" -echo -e "nightly-$end_date" >.nightly_msrv +echo -e "nightly-$end_date" >tools/.nightly_msrv -echo -e "\e[32mSUCCESS: Successfully wrote .nightly_msrv\e[0m" +echo -e "\e[32mSUCCESS: Successfully wrote tools/.nightly_msrv\e[0m" echo -e "\e[34mINFO: Updating README.md\e[0m" @@ -91,7 +91,7 @@ echo -e "\e[34mINFO: Updating .github/workflows/msrv.yml\e[0m" # find and update: # - nightly-2023-06-28 ### nightly MSRV (DO NOT EDIT THIS LINE): -sed -i.bak "s/- nightly-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} ### nightly MSRV (DO NOT EDIT THIS LINE):/- nightly-${end_date} ### nightly MSRV (DO NOT EDIT THIS LINE):/g" .github/workflows/msrv.yml +sed -i.bak "s/- nightly-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} ### nightly MSRV (DO NOT EDIT THIS LINE):/- nightly-${end_date} ### nightly MSRV (DO NOT EDIT THIS LINE):/g" .github/workflows/ci.yml echo -e "\e[32mSUCCESS: Successfully updated .github/workflows/msrv.yml\e[0m" diff --git a/tools/find_msrv.sh b/tools/stable_msrv.sh similarity index 94% rename from tools/find_msrv.sh rename to tools/stable_msrv.sh index 6279c13952..a982c6b5e2 100755 --- a/tools/find_msrv.sh +++ b/tools/stable_msrv.sh @@ -68,11 +68,11 @@ done echo -e "\e[32mSUCCESS: Found Minimum Supported Rust Version: 1.$end_version\e[0m" -echo -e "\e[34mINFO: Writing .msrv ...\e[0m" +echo -e "\e[34mINFO: Writing tools/.stable_msrv ...\e[0m" -echo -e "1.$end_version" >.msrv +echo -e "1.$end_version" >tools/.stable_msrv -echo -e "\e[32mSUCCESS: Successfully wrote .msrv\e[0m" +echo -e "\e[32mSUCCESS: Successfully wrote tools/.stable_msrv\e[0m" echo -e "\e[34mINFO: Updating README.md\e[0m" @@ -106,7 +106,7 @@ echo -e "\e[34mINFO: Updating .github/workflows/msrv.yml\e[0m" # find and update: # - 1.45 ### stable MSRV (DO NOT EDIT THIS LINE): -sed -i.bak "s/- 1.[0-9]\+ ### stable MSRV (DO NOT EDIT THIS LINE):/- 1.$end_version ### stable MSRV (DO NOT EDIT THIS LINE):/g" .github/workflows/msrv.yml +sed -i.bak "s/- 1.[0-9]\+ ### stable MSRV (DO NOT EDIT THIS LINE):/- 1.$end_version ### stable MSRV (DO NOT EDIT THIS LINE):/g" .github/workflows/ci.yml echo -e "\e[32mSUCCESS: Successfully updated .github/workflows/msrv.yml\e[0m" From c38d195fa4381c8eabc74b8938f873d4b593047b Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 12:22:21 -0500 Subject: [PATCH 04/23] fix file glob pattern --- .github/workflows/update_msrv.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 86b7884dea..d679af5bd6 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -13,6 +13,8 @@ on: env: CARGO_TERM_COLOR: always + OLD_MSRV: "" + NEW_MSRV: "" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -39,9 +41,9 @@ jobs: toolchain: ${{ matrix.toolchain }} override: true - # set initial msrvs (.msrv, .nightly_msrv) as env vars - - name: Store initial MSRVs - run: echo "::set-env name=OLD_MSRV::$(cat tools/.${{ matrix.toolchain }}_msrv)" + # Store initial MSRV in memory (update OLD_MSRV) + - name: Store initial MSRV + run: echo "OLD_MSRV=$(cat .${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV # run the MSRV check (tools/{toolchain}_msrv.sh) for the current toolchain @@ -52,7 +54,7 @@ jobs: # Store the new MSRV as an env var - name: Store new MSRV - run: echo "::set-env name=NEW_MSRV::$(cat .${{ matrix.toolchain }}_msrv)" + run: echo "NEW_MSRV=$(cat .${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV # If MSRV has not changed, exit early @@ -63,7 +65,8 @@ jobs: exit 0 fi - # add, commit, and push changes, if any + # Commit changes from these files: + # README.md, .github/workflows/ci.yml, .msrv,.nightly_msrv, clippy.toml - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v4 with: @@ -92,7 +95,7 @@ jobs: ### README.md ### .nightly_msrv ### .msrv - file_pattern: "{README.md,.github/workflows/ci.yml,.msrv,.nightly_msrv,clippy.toml}" + file_pattern: 'README.md .github/workflows/ci.yml .msrv .nightly_msrv clippy.toml' # # Optional. Local file path to the repository. Defaults to the root of the repository. # repository: . From a5a28e26f5882eeaede79d519f524b9f189221ed Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 12:32:00 -0500 Subject: [PATCH 05/23] provide consitent file naming for GH actions files --- .github/workflows/{ci.yaml => ci.yml} | 2 +- .github/workflows/{gh-pages.yaml => gh-pages.yml} | 0 .github/workflows/{post_release.yaml => post_release.yml} | 0 .github/workflows/{release.yaml => release.yml} | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{ci.yaml => ci.yml} (99%) rename .github/workflows/{gh-pages.yaml => gh-pages.yml} (100%) rename .github/workflows/{post_release.yaml => post_release.yml} (100%) rename .github/workflows/{release.yaml => release.yml} (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yml similarity index 99% rename from .github/workflows/ci.yaml rename to .github/workflows/ci.yml index 7db86b7ff0..0e34355023 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yml @@ -484,7 +484,7 @@ jobs: strategy: matrix: rust_version: - - nightly # latest nightly + - nightly-latest # latest nightly - nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152 - nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152 # diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yml similarity index 100% rename from .github/workflows/gh-pages.yaml rename to .github/workflows/gh-pages.yml diff --git a/.github/workflows/post_release.yaml b/.github/workflows/post_release.yml similarity index 100% rename from .github/workflows/post_release.yaml rename to .github/workflows/post_release.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yml similarity index 100% rename from .github/workflows/release.yaml rename to .github/workflows/release.yml From 2fe7f4d8c67514eee191f63dbb4867168d285ac4 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 12:32:20 -0500 Subject: [PATCH 06/23] improve `sed` regex --- tools/nightly_msrv.sh | 4 ++-- tools/stable_msrv.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/nightly_msrv.sh b/tools/nightly_msrv.sh index c8cec3cd74..b19dfdf521 100755 --- a/tools/nightly_msrv.sh +++ b/tools/nightly_msrv.sh @@ -44,7 +44,7 @@ end_date="$msrv" # use binary search to find the earliest compatible version of rust while [[ "$start_date" != "$end_date" ]]; do # Display the progress: ruled-out count / total count - echo -e "\e[36mINFO: Searching between $start_date and $end_date\e[0m" + echo -e "\e[36mINFO: Searching between nightly releases $start_date and $end_date\e[0m" # Calculate the midpoint date mid_date=$(date -d "$start_date + $((($(date -d "$end_date" +%s) - $(date -d "$start_date" +%s)) / 2)) seconds" +"%Y-%m-%d") @@ -73,7 +73,7 @@ echo -e "\e[34mINFO: Updating README.md\e[0m" # https://img.shields.io/badge/nightly_msrv-nightly--2021--08--04+-orange.svg # replace single dashes with double dashes -sed -i.bak "s/nightly_msrv-nightly--.*+-orange.svg/nightly_msrv-nightly--${end_date//-/--}+-orange.svg/g" README.md +sed -i.bak "s/nightly_msrv-nightly--[0-9]\{4\}--[0-9]\{2\}--[0-9]\{2\}+-orange.svg/nightly_msrv-nightly--${end_date//-/--}+-orange.svg/g" README.md echo -e "\e[32mSUCCESS: Successfully updated README.md\e[0m" diff --git a/tools/stable_msrv.sh b/tools/stable_msrv.sh index a982c6b5e2..280d05be0b 100755 --- a/tools/stable_msrv.sh +++ b/tools/stable_msrv.sh @@ -51,7 +51,7 @@ end_version=$(curl https://api.github.com/repos/rust-lang/rust/releases/latest | # use binary search to find the earliest compatible version of rust while [[ "$start_version" -lt "$end_version" ]]; do # Display the progress: ruled-out count / total count - echo -e "\e[36mINFO: Searching between $start_version and $end_version\e[0m" + echo -e "\e[36mINFO: Searching between versions 1.$start_version and 1.$end_version\e[0m" # Calculate the midpoint version mid_version="$(((start_version + end_version) / 2))" From 3e821353dc5e39c57ee555e3f61633522dad1815 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 12:34:37 -0500 Subject: [PATCH 07/23] fix rustup syntax error --- .github/workflows/ci.yml | 2 +- .github/workflows/update_msrv.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e34355023..7b71a71c50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -484,7 +484,7 @@ jobs: strategy: matrix: rust_version: - - nightly-latest # latest nightly + - nightly # latest nightly - nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152 - nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152 # diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index d679af5bd6..9de3b0195a 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -22,7 +22,7 @@ concurrency: jobs: check_msrv: - name: Check MSRV && update accordingly + name: Check MSRV strategy: matrix: toolchain: From 9a529b206e2f9f1b3152e58064d608142738c0a0 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 12:39:57 -0500 Subject: [PATCH 08/23] rename `.msrv` -> `.stable_msrv` for clarity --- .github/workflows/ci.yml | 2 +- .github/workflows/update_msrv.yml | 6 +++--- README.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b71a71c50..7db86b7ff0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -484,7 +484,7 @@ jobs: strategy: matrix: rust_version: - - nightly # latest nightly + - nightly # latest nightly - nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152 - nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152 # diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 9de3b0195a..d6e848149a 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -66,7 +66,7 @@ jobs: fi # Commit changes from these files: - # README.md, .github/workflows/ci.yml, .msrv,.nightly_msrv, clippy.toml + # README.md, .github/workflows/ci.yml, .stable_msrv,.nightly_msrv, clippy.toml - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v4 with: @@ -94,8 +94,8 @@ jobs: ### clippy.toml ### README.md ### .nightly_msrv - ### .msrv - file_pattern: 'README.md .github/workflows/ci.yml .msrv .nightly_msrv clippy.toml' + ### .stable_msrv + file_pattern: 'README.md .github/workflows/ci.yml .stable_msrv .nightly_msrv clippy.toml' # # Optional. Local file path to the repository. Defaults to the root of the repository. # repository: . diff --git a/README.md b/README.md index ed6af04ff2..0a1dc59a2f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![CI](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/ci.yaml/badge.svg)](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/ci.yaml) [![Example](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/post_release.yaml/badge.svg)](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/post_release.yaml) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6afbdad19e7245adbf9e9771777be3d7)](https://app.codacy.com/gh/fzyzcjy/flutter_rust_bridge?utm_source=github.com&utm_medium=referral&utm_content=fzyzcjy/flutter_rust_bridge&utm_campaign=Badge_Grade_Settings) -[![Minimum Supported Stable Rust Version](https://img.shields.io/badge/stable_msrv-1.64+-green.svg)](/.msrv) +[![Minimum Supported Stable Rust Version](https://img.shields.io/badge/stable_msrv-1.64+-green.svg)](/.stable_msrv) [![Minimum Supported Nightly Rust Version](https://img.shields.io/badge/nightly_msrv-nightly--2022--07--15+-orange.svg)](/.nightly_msrv) ![Logo](https://github.com/fzyzcjy/flutter_rust_bridge/raw/master/book/logo.png) From cf9fa03a4d0e21603d89568722c0385fd6f63fef Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:00:01 -0500 Subject: [PATCH 09/23] fix branch name --- .github/workflows/update_msrv.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index d6e848149a..f98dc72647 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -77,9 +77,9 @@ jobs: # # Optional. Create given branch name in local and remote repository. # create_branch: true - # # Optional. Local and remote branch name where commit is going to be pushed to. - # # Defaults to the current branch. - # branch: update_msrv + # Optional. Local and remote branch name where commit is going to be pushed to. + # Defaults to the current branch. + branch: master # Optional. Options used by `git-commit`. # See https://git-scm.com/docs/git-commit#_options From 6035c3f3c17ed1b0d0a6c59adf426d7d4c4a198d Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:11:27 -0500 Subject: [PATCH 10/23] edit workflow permissions --- .github/workflows/update_msrv.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index f98dc72647..2449f384a7 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -31,9 +31,14 @@ jobs: runs-on: ubuntu-latest + permissions: + contents: write + steps: # checkout sources - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} # ensure rustup is installed - uses: actions-rs/toolchain@v1 @@ -77,9 +82,9 @@ jobs: # # Optional. Create given branch name in local and remote repository. # create_branch: true - # Optional. Local and remote branch name where commit is going to be pushed to. - # Defaults to the current branch. - branch: master + # # Optional. Local and remote branch name where commit is going to be pushed to. + # # Defaults to the current branch. + # branch: new-feat # Optional. Options used by `git-commit`. # See https://git-scm.com/docs/git-commit#_options @@ -132,7 +137,7 @@ jobs: # Optional. Prevents the shell from expanding filenames. # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html - disable_globbing: false + disable_globbing: true # # open a PR if the MSRV has changed # - name: Create Pull Request From 8c83bf2cbe5e07bec7a7d2d5f9d264b0536c9287 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:16:23 -0500 Subject: [PATCH 11/23] update PAT --- .github/workflows/update_msrv.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 2449f384a7..8947aec8f7 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -39,6 +39,7 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} + token: ${{ secrets.GH_PAT }} # ensure rustup is installed - uses: actions-rs/toolchain@v1 From 80d3fb0cfe57e02db75ffa3e334dff11a2bdadda Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:21:46 -0500 Subject: [PATCH 12/23] add write permissions --- .github/workflows/update_msrv.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 8947aec8f7..2449f384a7 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -39,7 +39,6 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} - token: ${{ secrets.GH_PAT }} # ensure rustup is installed - uses: actions-rs/toolchain@v1 From 4184ca7fced0f090b206f1c1f819832b95269055 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:32:54 -0500 Subject: [PATCH 13/23] change commit actions --- .github/workflows/update_msrv.yml | 145 ++++++++++++++++-------------- 1 file changed, 79 insertions(+), 66 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 2449f384a7..7a0d7f4cd4 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -37,8 +37,6 @@ jobs: steps: # checkout sources - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} # ensure rustup is installed - uses: actions-rs/toolchain@v1 @@ -73,71 +71,86 @@ jobs: # Commit changes from these files: # README.md, .github/workflows/ci.yml, .stable_msrv,.nightly_msrv, clippy.toml - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: EndBug/add-and-commit@v9 with: - # Optional. Commit message for the created commit. - # Defaults to "Apply automatic changes" - commit_message: Update MSRV for toolchain ${{ matrix.toolchain }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) - - # # Optional. Create given branch name in local and remote repository. - # create_branch: true - - # # Optional. Local and remote branch name where commit is going to be pushed to. - # # Defaults to the current branch. - # branch: new-feat - - # Optional. Options used by `git-commit`. - # See https://git-scm.com/docs/git-commit#_options - commit_options: "--no-verify --signoff" - - # Optional glob pattern of files which should be added to the commit. - # Defaults to all (.) - # - ### We only want to track the following files: - ### - ### .github/workflows/ci.yml - ### clippy.toml - ### README.md - ### .nightly_msrv - ### .stable_msrv - file_pattern: 'README.md .github/workflows/ci.yml .stable_msrv .nightly_msrv clippy.toml' - - # # Optional. Local file path to the repository. Defaults to the root of the repository. - # repository: . - - # # Optional commit user and author settings - # commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" - # commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" - # commit_author: Author # defaults to author of the commit that triggered the run - - # # Optional. Tag name being created in the local repository and - # # pushed to remote repository and defined branch. - # tagging_message: 'v1.0.0' - - # # Optional. Options used by `git-add`. - # # See https://git-scm.com/docs/git-add#_options - # add_options: '-u' - - # # Optional. Options used by `git-push`. - # # See https://git-scm.com/docs/git-push#_options - # push_options: '--force' - - # Optional. Disable dirty check and always try to create a commit and push - skip_dirty_check: true - - # # Optional. Option used by `git-status` to determine if the repository is - # # dirty. See https://git-scm.com/docs/git-status#_options - # status_options: '--untracked-files=no' - - # Optional. Skip internal call to `git fetch` - skip_fetch: true - - # Optional. Skip internal call to `git checkout` - skip_checkout: false - - # Optional. Prevents the shell from expanding filenames. - # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html - disable_globbing: true + default_author: github_actions + message: Update MSRV for toolchain ${{ matrix.toolchain }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) + add: | + README.md + .github/workflows/ci.yml + .stable_msrv + .nightly_msrv + clippy.toml + + + + ##- name: Commit changes + ## uses: stefanzweifel/git-auto-commit-action@v4 + ## with: + ## # Optional. Commit message for the created commit. + ## # Defaults to "Apply automatic changes" + ## commit_message: Update MSRV for toolchain ${{ matrix.toolchain }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) + + ## # # Optional. Create given branch name in local and remote repository. + ## # create_branch: true + + ## # # Optional. Local and remote branch name where commit is going to be pushed to. + ## # # Defaults to the current branch. + ## # branch: new-feat + + ## # Optional. Options used by `git-commit`. + ## # See https://git-scm.com/docs/git-commit#_options + ## commit_options: "--no-verify --signoff" + + ## # Optional glob pattern of files which should be added to the commit. + ## # Defaults to all (.) + ## # + ## ### We only want to track the following files: + ## ### + ## ### .github/workflows/ci.yml + ## ### clippy.toml + ## ### README.md + ## ### .nightly_msrv + ## ### .stable_msrv + + ## file_pattern: 'README.md .github/workflows/ci.yml .stable_msrv .nightly_msrv clippy.toml' + + ## # # Optional. Local file path to the repository. Defaults to the root of the repository. + ## # repository: . + + ## # # Optional commit user and author settings + ## # commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" + ## # commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" + ## # commit_author: Author # defaults to author of the commit that triggered the run + + ## # # Optional. Tag name being created in the local repository and + ## # # pushed to remote repository and defined branch. + ## # tagging_message: 'v1.0.0' + + ## # # Optional. Options used by `git-add`. + ## # # See https://git-scm.com/docs/git-add#_options + ## # add_options: '-u' + + ## # # Optional. Options used by `git-push`. + ## # # See https://git-scm.com/docs/git-push#_options + ## # push_options: '--force' + + ## # Optional. Disable dirty check and always try to create a commit and push + ## skip_dirty_check: true + + ## # # Optional. Option used by `git-status` to determine if the repository is + ## # # dirty. See https://git-scm.com/docs/git-status#_options + ## # status_options: '--untracked-files=no' + + ## # Optional. Skip internal call to `git fetch` + ## skip_fetch: true + + ## # Optional. Skip internal call to `git checkout` + ## skip_checkout: false + + ## # Optional. Prevents the shell from expanding filenames. + ## # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html + ## disable_globbing: true # # open a PR if the MSRV has changed # - name: Create Pull Request From 3f4b673ae348150422fc4e92f326fe1087dc5a90 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:37:36 -0500 Subject: [PATCH 14/23] fix file path error --- .github/workflows/update_msrv.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 7a0d7f4cd4..df1efc8f95 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -46,7 +46,7 @@ jobs: # Store initial MSRV in memory (update OLD_MSRV) - name: Store initial MSRV - run: echo "OLD_MSRV=$(cat .${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV + run: echo "OLD_MSRV=$(cat tools/.${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV # run the MSRV check (tools/{toolchain}_msrv.sh) for the current toolchain @@ -57,7 +57,7 @@ jobs: # Store the new MSRV as an env var - name: Store new MSRV - run: echo "NEW_MSRV=$(cat .${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV + run: echo "NEW_MSRV=$(cat tools/.${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV # If MSRV has not changed, exit early From 72ca507e4f0393c1b49a31bf932ceb08365fe2de Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:43:47 -0500 Subject: [PATCH 15/23] fix cache --- .github/workflows/update_msrv.yml | 122 ++++-------------------------- 1 file changed, 14 insertions(+), 108 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index df1efc8f95..4459638c29 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -38,6 +38,17 @@ jobs: # checkout sources - uses: actions/checkout@v3 + # Cache/Restore Cache cargo and rustup for faster subsequent runs + - uses: actions/cache@v2 + with: + path: | + ~/.cargo + ~/.rustup + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + # ensure rustup is installed - uses: actions-rs/toolchain@v1 with: @@ -76,114 +87,9 @@ jobs: default_author: github_actions message: Update MSRV for toolchain ${{ matrix.toolchain }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) add: | - README.md .github/workflows/ci.yml - .stable_msrv - .nightly_msrv + tools/.stable_msrv + tools/.nightly_msrv clippy.toml - - - - ##- name: Commit changes - ## uses: stefanzweifel/git-auto-commit-action@v4 - ## with: - ## # Optional. Commit message for the created commit. - ## # Defaults to "Apply automatic changes" - ## commit_message: Update MSRV for toolchain ${{ matrix.toolchain }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) - - ## # # Optional. Create given branch name in local and remote repository. - ## # create_branch: true - - ## # # Optional. Local and remote branch name where commit is going to be pushed to. - ## # # Defaults to the current branch. - ## # branch: new-feat - - ## # Optional. Options used by `git-commit`. - ## # See https://git-scm.com/docs/git-commit#_options - ## commit_options: "--no-verify --signoff" - - ## # Optional glob pattern of files which should be added to the commit. - ## # Defaults to all (.) - ## # - ## ### We only want to track the following files: - ## ### - ## ### .github/workflows/ci.yml - ## ### clippy.toml - ## ### README.md - ## ### .nightly_msrv - ## ### .stable_msrv - - ## file_pattern: 'README.md .github/workflows/ci.yml .stable_msrv .nightly_msrv clippy.toml' - - ## # # Optional. Local file path to the repository. Defaults to the root of the repository. - ## # repository: . - - ## # # Optional commit user and author settings - ## # commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" - ## # commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" - ## # commit_author: Author # defaults to author of the commit that triggered the run - - ## # # Optional. Tag name being created in the local repository and - ## # # pushed to remote repository and defined branch. - ## # tagging_message: 'v1.0.0' - - ## # # Optional. Options used by `git-add`. - ## # # See https://git-scm.com/docs/git-add#_options - ## # add_options: '-u' - - ## # # Optional. Options used by `git-push`. - ## # # See https://git-scm.com/docs/git-push#_options - ## # push_options: '--force' - - ## # Optional. Disable dirty check and always try to create a commit and push - ## skip_dirty_check: true - - ## # # Optional. Option used by `git-status` to determine if the repository is - ## # # dirty. See https://git-scm.com/docs/git-status#_options - ## # status_options: '--untracked-files=no' - - ## # Optional. Skip internal call to `git fetch` - ## skip_fetch: true - - ## # Optional. Skip internal call to `git checkout` - ## skip_checkout: false - - ## # Optional. Prevents the shell from expanding filenames. - ## # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html - ## disable_globbing: true - - # # open a PR if the MSRV has changed - # - name: Create Pull Request - # uses: peter-evans/create-pull-request@v5 - # with: - # token: ${{ secrets.PAT }} - # commit-message: Update MSRV - # committer: GitHub - # author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - # signoff: false - # branch: msrv - # delete-branch: false - # title: "(chore): Update MSRV" - # body: | - # Update MSRV - # - Updated MSRV for ${{ matrix.toolchain }} on ${{ matrix.os }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) - # - Auto-generated by [create-pull-request][1] - # - # [1]: https://github.com/peter-evans/create-pull-request - # labels: | - # msrv - # assignees: fzyzcjy - # reviewers: fzyzcjy - # milestone: 1 - # draft: false - - # Cache cargo and rustup for faster subsequent runs - - uses: actions/cache@v2 - with: - path: | - ~/.cargo - ~/.rustup - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- + README.md From a5b37fb464ec9e2bb7c25cef9d568afafaada746 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:51:48 -0500 Subject: [PATCH 16/23] fix cache & detatched head state --- .github/workflows/ci.yml | 16 ++++++++++------ .github/workflows/update_msrv.yml | 13 ++++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7db86b7ff0..b298aaadcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -499,13 +499,9 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ matrix.rust_version }} - components: rustfmt, clippy - # cache cargo and rustup to reduce future build times as much as possible - - uses: actions/cache@v2 + - name: cache + uses: actions/cache@v2 with: path: | ~/.cargo @@ -514,6 +510,14 @@ jobs: restore-keys: | ${{ runner.os }}-cargo- + # Check cache, then insdtall if not found + - if: steps.cache.outputs.cache-hit != 'true' + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust_version }} + components: rustfmt, clippy + + - uses: subosito/flutter-action@v2 with: cache: true diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 4459638c29..382c264535 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -36,7 +36,18 @@ jobs: steps: # checkout sources - - uses: actions/checkout@v3 + # By default, actions/checkout will checkout a PR in detatched HEAD state. + - if: github.event_name == 'pull_request' + name: Checkout (PR) + uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + + - if: github.event_name == 'push' + name: Checkout (Push) + uses: actions/checkout@v3 + # Cache/Restore Cache cargo and rustup for faster subsequent runs - uses: actions/cache@v2 From 50617987da16b0d3cdeadf9b5f847b751e1865ca Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 15:56:58 -0500 Subject: [PATCH 17/23] update `actions/cache` to v3 --- .github/workflows/ci.yml | 2 +- .github/workflows/update_msrv.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b298aaadcd..f104253539 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -501,7 +501,7 @@ jobs: # cache cargo and rustup to reduce future build times as much as possible - name: cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/.cargo diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 382c264535..b3f879bf50 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -50,7 +50,7 @@ jobs: # Cache/Restore Cache cargo and rustup for faster subsequent runs - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/.cargo From d14162504479a7c4f28cc7f1c201723b596851b6 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Thu, 3 Aug 2023 16:05:46 -0500 Subject: [PATCH 18/23] remove explicit permissions --- .github/workflows/update_msrv.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index b3f879bf50..f8571d3777 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -31,9 +31,6 @@ jobs: runs-on: ubuntu-latest - permissions: - contents: write - steps: # checkout sources # By default, actions/checkout will checkout a PR in detatched HEAD state. From 55a67fc733a6cc603d1b2fef70afb11bde8ebd4c Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Fri, 4 Aug 2023 12:33:12 -0500 Subject: [PATCH 19/23] try auto commenter --- .github/workflows/update_msrv.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index f8571d3777..bf0fa22d0f 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -41,7 +41,7 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} - - if: github.event_name == 'push' + - if: github.event_name != 'pull_request' name: Checkout (Push) uses: actions/checkout@v3 @@ -89,7 +89,8 @@ jobs: # Commit changes from these files: # README.md, .github/workflows/ci.yml, .stable_msrv,.nightly_msrv, clippy.toml - - name: Commit changes + - if: github.event_name != 'pull_request' + name: Commit changes uses: EndBug/add-and-commit@v9 with: default_author: github_actions @@ -101,3 +102,12 @@ jobs: clippy.toml README.md + # If in a PR, create a comment and block merging until comment is resolved + - uses: zt4ff/auto-commmenter@v2 + with: + type: custom + body: | + # MSRV has changed + The MSRV has changed from `${{ env.OLD_MSRV }}` to `${{ env.NEW_MSRV }}`. + Please review the changes and merge if they are acceptable. + From 7be2ee16de0cb8493a0143e299963d25ab9f586e Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Fri, 4 Aug 2023 12:35:42 -0500 Subject: [PATCH 20/23] fix typo? lol --- .github/workflows/update_msrv.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index bf0fa22d0f..7ca7e6a3dd 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -90,7 +90,7 @@ jobs: # Commit changes from these files: # README.md, .github/workflows/ci.yml, .stable_msrv,.nightly_msrv, clippy.toml - if: github.event_name != 'pull_request' - name: Commit changes + name: Commit MSRV changes (Push) uses: EndBug/add-and-commit@v9 with: default_author: github_actions @@ -103,7 +103,9 @@ jobs: README.md # If in a PR, create a comment and block merging until comment is resolved - - uses: zt4ff/auto-commmenter@v2 + - if: github.event_name == 'pull_request' + name: Comment MSRV changes (PR) + uses: zt4ff/auto-commenter@v2 with: type: custom body: | From fb2eb1fcc0b106b413a425451f5b718368c6fb32 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Fri, 4 Aug 2023 12:44:38 -0500 Subject: [PATCH 21/23] change permissions --- .github/workflows/update_msrv.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 7ca7e6a3dd..50036e94ab 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -31,6 +31,12 @@ jobs: runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + issues: write + + steps: # checkout sources # By default, actions/checkout will checkout a PR in detatched HEAD state. @@ -105,10 +111,10 @@ jobs: # If in a PR, create a comment and block merging until comment is resolved - if: github.event_name == 'pull_request' name: Comment MSRV changes (PR) - uses: zt4ff/auto-commenter@v2 + uses: alexrogalskiy/github-action-issue-commenter@master with: - type: custom - body: | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + message: | # MSRV has changed The MSRV has changed from `${{ env.OLD_MSRV }}` to `${{ env.NEW_MSRV }}`. Please review the changes and merge if they are acceptable. From 0a7c0ef95363c0b8c78f23ac191f6929cfc1d79f Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Fri, 4 Aug 2023 12:58:04 -0500 Subject: [PATCH 22/23] commit MSRV changes --- .github/workflows/update_msrv.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml index 50036e94ab..fce0e98bfe 100644 --- a/.github/workflows/update_msrv.yml +++ b/.github/workflows/update_msrv.yml @@ -95,8 +95,7 @@ jobs: # Commit changes from these files: # README.md, .github/workflows/ci.yml, .stable_msrv,.nightly_msrv, clippy.toml - - if: github.event_name != 'pull_request' - name: Commit MSRV changes (Push) + - name: Commit MSRV changes uses: EndBug/add-and-commit@v9 with: default_author: github_actions From 62f3ba0f93be9e125a9b6ef8a7d8bd480ecf4e60 Mon Sep 17 00:00:00 2001 From: Marc Gutenberger Date: Sat, 5 Aug 2023 11:12:10 -0500 Subject: [PATCH 23/23] Delete update_msrv.yml --- .github/workflows/update_msrv.yml | 120 ------------------------------ 1 file changed, 120 deletions(-) delete mode 100644 .github/workflows/update_msrv.yml diff --git a/.github/workflows/update_msrv.yml b/.github/workflows/update_msrv.yml deleted file mode 100644 index fce0e98bfe..0000000000 --- a/.github/workflows/update_msrv.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: MSRV - -on: - push: - paths-ignore: - - "docs/**" - - "**/*.md" - pull_request: - paths-ignore: - - "docs/**" - - "**/*.md" - workflow_dispatch: {} - -env: - CARGO_TERM_COLOR: always - OLD_MSRV: "" - NEW_MSRV: "" - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - check_msrv: - name: Check MSRV - strategy: - matrix: - toolchain: - - stable - - nightly - - runs-on: ubuntu-latest - - permissions: - contents: read - pull-requests: write - issues: write - - - steps: - # checkout sources - # By default, actions/checkout will checkout a PR in detatched HEAD state. - - if: github.event_name == 'pull_request' - name: Checkout (PR) - uses: actions/checkout@v3 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - - if: github.event_name != 'pull_request' - name: Checkout (Push) - uses: actions/checkout@v3 - - - # Cache/Restore Cache cargo and rustup for faster subsequent runs - - uses: actions/cache@v3 - with: - path: | - ~/.cargo - ~/.rustup - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - # ensure rustup is installed - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.toolchain }} - override: true - - # Store initial MSRV in memory (update OLD_MSRV) - - name: Store initial MSRV - run: echo "OLD_MSRV=$(cat tools/.${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV - - - # run the MSRV check (tools/{toolchain}_msrv.sh) for the current toolchain - - name: Check MSRV - run: | - ./tools/${{ matrix.toolchain }}_msrv.sh - - - # Store the new MSRV as an env var - - name: Store new MSRV - run: echo "NEW_MSRV=$(cat tools/.${{ matrix.toolchain }}_msrv)" >> $GITHUB_ENV - - - # If MSRV has not changed, exit early - - name: Exit early if MSRV has not changed - run: | - if [ "${{ env.OLD_MSRV }}" = "${{ env.NEW_MSRV }}" ]; then - echo "MSRV has not changed, exiting early" - exit 0 - fi - - # Commit changes from these files: - # README.md, .github/workflows/ci.yml, .stable_msrv,.nightly_msrv, clippy.toml - - name: Commit MSRV changes - uses: EndBug/add-and-commit@v9 - with: - default_author: github_actions - message: Update MSRV for toolchain ${{ matrix.toolchain }} (`${{ env.OLD_MSRV }}` -> `${{ env.NEW_MSRV }}`) - add: | - .github/workflows/ci.yml - tools/.stable_msrv - tools/.nightly_msrv - clippy.toml - README.md - - # If in a PR, create a comment and block merging until comment is resolved - - if: github.event_name == 'pull_request' - name: Comment MSRV changes (PR) - uses: alexrogalskiy/github-action-issue-commenter@master - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - message: | - # MSRV has changed - The MSRV has changed from `${{ env.OLD_MSRV }}` to `${{ env.NEW_MSRV }}`. - Please review the changes and merge if they are acceptable. -