Browse Source

CI: Move MSRV checks from manifest to lints

While MSRV is defined in the manifest files, it doesn't make sense to
verify the code compiles under the MSRV only when the manifest files
change. Code changes can break MSRV compliance.

Move the MSRV checks to the lints.yaml workflow instead.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
Manos Pitsidianakis 7 months ago
parent
commit
d49344f9

+ 9 - 1
.gitea/Makefile.lint

@@ -14,9 +14,17 @@ NIGHTLY_EXISTS=`((cargo +nightly 2> /dev/null 1> /dev/null) && echo 0)|| echo 1)
 GIT=env GIT_CONFIG_GLOBAL="" GIT_CONFIG_SYSTEM="" GIT_CONFIG_NOSYSTEM=1 git
 GIT=env GIT_CONFIG_GLOBAL="" GIT_CONFIG_SYSTEM="" GIT_CONFIG_NOSYSTEM=1 git
 
 
 .PHONY: all
 .PHONY: all
-all: rustfmt clippy cargo-derivefmt-melib cargo-derivefmt-meli cargo-derivefmt-tools
+all: cargo-msrv rustfmt clippy cargo-derivefmt-melib cargo-derivefmt-meli cargo-derivefmt-tools
 	@printf "All checks completed.\n"
 	@printf "All checks completed.\n"
 
 
+# Check both melib and meli in the same Make target, because if melib does not
+# satisfy MSRV then meli won't either, since it depends on melib.
+.PHONY: cargo-msrv
+cargo-msrv:
+	@printf "cargo-msrv\n"
+	cargo msrv --output-format json --log-level trace --log-target stdout --path meli verify -- cargo check --all-targets
+	cargo msrv --output-format json --log-level trace --log-target stdout --path melib verify -- cargo check --all-targets
+
 .PHONY: rustfmt
 .PHONY: rustfmt
 rustfmt:
 rustfmt:
 	@printf "rustfmt\n"
 	@printf "rustfmt\n"

+ 3 - 7
.gitea/Makefile.manifest-lint

@@ -12,20 +12,16 @@ RUSTUP_MAX_RETRIES ?= 10
 RUST_BACKTRACE ?= short
 RUST_BACKTRACE ?= short
 
 
 .PHONY: all
 .PHONY: all
-all: cargo-msrv cargo-sort check-debian-changelog
-	@printf "All completed.\n"
+all: cargo-sort check-debian-changelog
+	@printf "All checks completed.\n"
 
 
-.PHONY: cargo-msrv
-cargo-msrv:
-	@printf "cargo-msrv\n"
-	cargo-msrv --output-format json --log-level trace --log-target stdout --path meli verify -- cargo check --all-targets
-	cargo-msrv --output-format json --log-level trace --log-target stdout --path melib verify -- cargo check --all-targets
 .PHONY: cargo-sort
 .PHONY: cargo-sort
 cargo-sort:
 cargo-sort:
 	@printf "cargo-sort\n"
 	@printf "cargo-sort\n"
 	cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace fuzz
 	cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace fuzz
 	cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace tools
 	cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace tools
 	cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace --workspace
 	cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace --workspace
+
 .PHONY: check-debian-changelog
 .PHONY: check-debian-changelog
 check-debian-changelog:
 check-debian-changelog:
 	@printf "Check debian/changelog is up-to-date.\n"
 	@printf "Check debian/changelog is up-to-date.\n"

+ 3 - 24
.gitea/workflows/build.yaml

@@ -47,13 +47,6 @@ jobs:
         run: |
         run: |
           apt-get update
           apt-get update
           apt-get install -y libdbus-1-dev pkg-config mandoc libssl-dev make
           apt-get install -y libdbus-1-dev pkg-config mandoc libssl-dev make
-          #- id: cache-rustup
-          #  name: Cache Rust toolchain
-          #  uses: https://github.com/actions/cache@v3
-          #  with:
-          #    path: ~/.rustup
-          #    key: toolchain-${{ matrix.os }}-${{ matrix.rust }}
-          #- if: ${{ steps.cache-rustup.outputs.cache-hit != 'true' }}
       - id: rustup-setup
       - id: rustup-setup
         name: Install rustup and toolchains
         name: Install rustup and toolchains
         shell: bash
         shell: bash
@@ -62,22 +55,9 @@ jobs:
             curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
             curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
             source "${HOME}/.cargo/env"
             source "${HOME}/.cargo/env"
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
+            echo "CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}" >> $GITHUB_ENV
             rustup toolchain install --profile minimal ${{ matrix.rust }} --target ${{ matrix.target }}
             rustup toolchain install --profile minimal ${{ matrix.rust }} --target ${{ matrix.target }}
           fi
           fi
-      - name: Configure cargo data directory
-        # After this point, all cargo registry and crate data is stored in
-        # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files
-        # that are needed during the build process. Additionally, this works
-        # around a bug in the 'cache' action that causes directories outside of
-        # the workspace dir to be saved/restored incorrectly.
-        run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
-          #- id: cache-cargo
-          #  name: Cache cargo configuration and installations
-          #  uses: https://github.com/actions/cache@v3
-          #  with:
-          #    path: ${{ env.CARGO_HOME }}
-          #    key: cargo-${{ matrix.os }}-${{ matrix.rust }}
-          #- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
       - name: Setup Rust target
       - name: Setup Rust target
         run: |
         run: |
           mkdir -p "${{ env.CARGO_HOME }}"
           mkdir -p "${{ env.CARGO_HOME }}"
@@ -85,8 +65,7 @@ jobs:
           [build]
           [build]
           target = "${{ matrix.target }}"
           target = "${{ matrix.target }}"
           EOF
           EOF
-      - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
-        name: Add test dependencies
+      - name: Add test dependencies
         run: |
         run: |
           cargo install --quiet --version 0.9.54 --target "${{ matrix.target }}" cargo-nextest
           cargo install --quiet --version 0.9.54 --target "${{ matrix.target }}" cargo-nextest
       - name: cargo-check
       - name: cargo-check
@@ -100,7 +79,7 @@ jobs:
         run: |
         run: |
           make -f ./.gitea/Makefile.build cargo-test
           make -f ./.gitea/Makefile.build cargo-test
       - name: rustdoc build
       - name: rustdoc build
-        if: success() || failure() # always run even if other steps fail, except when cancelled <https://stackoverflow.com/questions/58858429/how-to-run-a-github-actions-step-even-if-the-previous-step-fails-while-still-f>
+        if: success() || failure()
         run: |
         run: |
           make -f ./.gitea/Makefile.build rustdoc-build
           make -f ./.gitea/Makefile.build rustdoc-build
       - name: rustdoc tests
       - name: rustdoc tests

+ 6 - 24
.gitea/workflows/build_artifacts.yaml

@@ -43,13 +43,6 @@ jobs:
         run: |
         run: |
           apt-get update
           apt-get update
           apt-get install -y libdbus-1-dev pkg-config mandoc libssl-dev
           apt-get install -y libdbus-1-dev pkg-config mandoc libssl-dev
-          #- id: cache-rustup
-          #  name: Cache Rust toolchain
-          #  uses: https://github.com/actions/cache@v3
-          #  with:
-          #    path: ~/.rustup
-          #    key: toolchain-${{ matrix.os }}-${{ matrix.rust }}
-          #- if: ${{ steps.cache-rustup.outputs.cache-hit != 'true' }}
       - id: rustup-setup
       - id: rustup-setup
         name: Install rustup and toolchains
         name: Install rustup and toolchains
         shell: bash
         shell: bash
@@ -58,22 +51,9 @@ jobs:
             curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
             curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
             source "${HOME}/.cargo/env"
             source "${HOME}/.cargo/env"
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
+            echo "CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}" >> $GITHUB_ENV
             rustup toolchain install --profile minimal ${{ matrix.rust }} --target ${{ matrix.target }}
             rustup toolchain install --profile minimal ${{ matrix.rust }} --target ${{ matrix.target }}
           fi
           fi
-      - name: Configure cargo data directory
-        # After this point, all cargo registry and crate data is stored in
-        # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files
-        # that are needed during the build process. Additionally, this works
-        # around a bug in the 'cache' action that causes directories outside of
-        # the workspace dir to be saved/restored incorrectly.
-        run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
-          #- id: cache-cargo
-          #  name: Cache cargo configuration and installations
-          #  uses: https://github.com/actions/cache@v3
-          #  with:
-          #    path: ${{ env.CARGO_HOME }}
-          #    key: cargo-${{ matrix.os }}-${{ matrix.rust }}
-          #- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
       - name: Setup Rust target
       - name: Setup Rust target
         run: |
         run: |
           mkdir -p "${{ env.CARGO_HOME }}"
           mkdir -p "${{ env.CARGO_HOME }}"
@@ -83,15 +63,17 @@ jobs:
           EOF
           EOF
       - name: Build binary
       - name: Build binary
         run: |
         run: |
+          VERSION=$(grep -m1 version meli/Cargo.toml | head -n1 | cut -d'"' -f 2 | head -n1)
+          echo "VERSION=${VERSION}" >> $GITHUB_ENV
           make
           make
           mkdir artifacts
           mkdir artifacts
           mv target/*/release/* target/ || true
           mv target/*/release/* target/ || true
           mv target/release/* target/ || true
           mv target/release/* target/ || true
-          mv target/meli  artifacts/
+          mv target/meli  artifacts/meli-${VERSION}-${{ matrix.target }}
       - name: Upload Artifacts
       - name: Upload Artifacts
         uses: actions/upload-artifact@v3
         uses: actions/upload-artifact@v3
         with:
         with:
-          name: ${{ matrix.artifact_name }}
-          path: artifacts/meli
+          name: ${{ matrix.artifact_name }}-${{ env.VERSION }}
+          path: artifacts/meli-${{ env.VERSION }}-${{ matrix.target }}
           if-no-files-found: error
           if-no-files-found: error
           retention-days: 30
           retention-days: 30

+ 1 - 1
.gitea/workflows/build_debian_package.yaml

@@ -16,7 +16,7 @@ on:
       - v*
       - v*
 
 
 jobs:
 jobs:
-  build:
+  build-debian:
     name: Create debian package
     name: Create debian package
     runs-on: ${{ matrix.os }}
     runs-on: ${{ matrix.os }}
     strategy:
     strategy:

+ 23 - 26
.gitea/workflows/lints.yaml

@@ -22,7 +22,7 @@ on:
       - 'Cargo.lock'
       - 'Cargo.lock'
 
 
 jobs:
 jobs:
-  test:
+  lints:
     name: Run lints
     name: Run lints
     runs-on: ${{ matrix.os }}
     runs-on: ${{ matrix.os }}
     strategy:
     strategy:
@@ -41,13 +41,10 @@ jobs:
         run: |
         run: |
           apt-get update
           apt-get update
           apt-get install -y libdbus-1-dev pkg-config mandoc libssl-dev
           apt-get install -y libdbus-1-dev pkg-config mandoc libssl-dev
-          #- id: cache-rustup
-          #  name: Cache Rust toolchain
-          #  uses: https://github.com/actions/cache@v3
-          #  with:
-          #    path: ~/.rustup
-          #    key: toolchain-${{ matrix.os }}-${{ matrix.rust }}
-          #- if: ${{ steps.cache-rustup.outputs.cache-hit != 'true' }}
+      - name: Find meli MSRV from meli/Cargo.toml.
+        run: |
+          echo MELI_MSRV=$(grep -m1 rust-version meli/Cargo.toml | head -n1 | cut -d'"' -f 2 | head -n1) >> $GITHUB_ENV
+          printf "Rust MSRV is %s\n" $(grep -m1 rust-version meli/Cargo.toml | head -n1 | cut -d'"' -f 2 | head -n1)
       - id: rustup-setup
       - id: rustup-setup
         name: Install Rustup and toolchains
         name: Install Rustup and toolchains
         shell: bash
         shell: bash
@@ -56,23 +53,13 @@ jobs:
             curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
             curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
             source "${HOME}/.cargo/env"
             source "${HOME}/.cargo/env"
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
-            rustup toolchain install --profile minimal --component clippy,rustfmt --target ${{ matrix.target }} -- "${{ matrix.rust }}"
+            echo "CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}" >> $GITHUB_ENV
+            rustup toolchain install --profile minimal --component "rustfmt" --target "${{ matrix.target }}" -- "${{ env.MELI_MSRV }}"
+            rustup component add rustfmt --toolchain ${{ env.MELI_MSRV }}-${{ matrix.target }}
+            rustup toolchain install --profile minimal --component clippy,rustfmt --target "${{ matrix.target }}" -- "${{ matrix.rust }}"
+            rustup component add rustfmt --toolchain ${{ matrix.rust }}-${{ matrix.target }}
             rustup default ${{ matrix.rust }}
             rustup default ${{ matrix.rust }}
           fi
           fi
-      - name: Configure cargo data directory
-        # After this point, all cargo registry and crate data is stored in
-        # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files
-        # that are needed during the build process. Additionally, this works
-        # around a bug in the 'cache' action that causes directories outside of
-        # the workspace dir to be saved/restored incorrectly.
-        run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
-          #- id: cache-cargo
-          #  name: Cache cargo configuration and installations
-          #  uses: https://github.com/actions/cache@v3
-          #  with:
-          #    path: ${{ env.CARGO_HOME }}
-          #    key: cargo-${{ matrix.os }}-${{ matrix.rust }}
-          #- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
       - name: Setup Rust target
       - name: Setup Rust target
         run: |
         run: |
           mkdir -p "${{ env.CARGO_HOME }}"
           mkdir -p "${{ env.CARGO_HOME }}"
@@ -80,29 +67,39 @@ jobs:
           [build]
           [build]
           target = "${{ matrix.target }}"
           target = "${{ matrix.target }}"
           EOF
           EOF
-      - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
-        name: Add lint dependencies
+      - name: Add lint dependencies
+        shell: bash
         run: |
         run: |
-          cargo install --quiet --version 1.0.9 --target "${{ matrix.target }}" cargo-sort
+          cargo install --version 0.15.1 --target "${{ matrix.target }}" cargo-msrv
           # "This package is currently implemented using rust-analyzer internals, so cannot be published on crates.io."
           # "This package is currently implemented using rust-analyzer internals, so cannot be published on crates.io."
           RUSTFLAGS="" cargo install --locked --target "${{ matrix.target }}" --git https://github.com/dcchut/cargo-derivefmt --rev 95da8eee343de4adb25850893873b979258aed7f --bin cargo-derivefmt
           RUSTFLAGS="" cargo install --locked --target "${{ matrix.target }}" --git https://github.com/dcchut/cargo-derivefmt --rev 95da8eee343de4adb25850893873b979258aed7f --bin cargo-derivefmt
+      - name: cargo-msrv verify melib MSRV
+        if: success() || failure()
+        run: |
+          source "${HOME}/.cargo/env"
+          make -f ./.gitea/Makefile.lint cargo-msrv
       - name: rustfmt
       - name: rustfmt
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |
+          source "${HOME}/.cargo/env"
           make -f .gitea/Makefile.lint rustfmt
           make -f .gitea/Makefile.lint rustfmt
       - name: clippy
       - name: clippy
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |
+          source "${HOME}/.cargo/env"
           make -f .gitea/Makefile.lint clippy
           make -f .gitea/Makefile.lint clippy
       - name: cargo-derivefmt melib
       - name: cargo-derivefmt melib
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |
+          source "${HOME}/.cargo/env"
           make -f .gitea/Makefile.lint cargo-derivefmt-melib
           make -f .gitea/Makefile.lint cargo-derivefmt-melib
       - name: cargo-derivefmt meli
       - name: cargo-derivefmt meli
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |
+          source "${HOME}/.cargo/env"
           make -f .gitea/Makefile.lint cargo-derivefmt-meli
           make -f .gitea/Makefile.lint cargo-derivefmt-meli
       - name: cargo-derivefmt tools
       - name: cargo-derivefmt tools
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |
+          source "${HOME}/.cargo/env"
           make -f .gitea/Makefile.lint cargo-derivefmt-tools
           make -f .gitea/Makefile.lint cargo-derivefmt-tools

+ 1 - 12
.gitea/workflows/manifest_lints.yaml

@@ -42,8 +42,6 @@ jobs:
         run: |
         run: |
           apt-get update
           apt-get update
           apt-get install -y mandoc
           apt-get install -y mandoc
-      - name: Find meli MSRV from meli/Cargo.toml.
-        run: echo MELI_MSRV=$(grep -m1 rust-version meli/Cargo.toml | head -n1 | cut -d'"' -f 2 | head -n1) >> $GITHUB_ENV
       - id: rustup-setup
       - id: rustup-setup
         name: Install Rustup and toolchains
         name: Install Rustup and toolchains
         shell: bash
         shell: bash
@@ -53,8 +51,6 @@ jobs:
             source "${HOME}/.cargo/env"
             source "${HOME}/.cargo/env"
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
             echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
             echo "CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}" >> $GITHUB_ENV
             echo "CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}" >> $GITHUB_ENV
-            rustup toolchain install --profile minimal --component "rustfmt" --target "${{ matrix.target }}" -- "${{ env.MELI_MSRV }}"
-            rustup component add rustfmt --toolchain ${{ env.MELI_MSRV }}-${{ matrix.target }}
             rustup toolchain install --profile minimal --component "rustfmt" --target "${{ matrix.target }}" -- "${{ matrix.rust }}"
             rustup toolchain install --profile minimal --component "rustfmt" --target "${{ matrix.target }}" -- "${{ matrix.rust }}"
             rustup component add rustfmt --toolchain ${{ matrix.rust }}-${{ matrix.target }}
             rustup component add rustfmt --toolchain ${{ matrix.rust }}-${{ matrix.target }}
             rustup default ${{ matrix.rust }}
             rustup default ${{ matrix.rust }}
@@ -66,17 +62,10 @@ jobs:
           [build]
           [build]
           target = "${{ matrix.target }}"
           target = "${{ matrix.target }}"
           EOF
           EOF
-      - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
-        name: Add manifest lint dependencies
+      - name: Add manifest lint dependencies
         run: |
         run: |
           source "${HOME}/.cargo/env"
           source "${HOME}/.cargo/env"
           cargo install --quiet --version 1.0.9 --target "${{ matrix.target }}" cargo-sort
           cargo install --quiet --version 1.0.9 --target "${{ matrix.target }}" cargo-sort
-          cargo install --quiet --version 0.15.1 --target "${{ matrix.target }}" cargo-msrv
-      - name: cargo-msrv verify melib MSRV
-        if: success() || failure()
-        run: |
-          source "${HOME}/.cargo/env"
-          make -f ./.gitea/Makefile.manifest-lint cargo-msrv
       - name: cargo-sort
       - name: cargo-sort
         if: success() || failure()
         if: success() || failure()
         run: |
         run: |