CI updates
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by David Peter · parent 35bc1f9 · Browse files · 3 files·+98 added−121 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+98 added−121 removed
- other:+98 added−121 removed
Provenance
- Commit
5439326- Tree
4ebc321- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
35bc1f9
3 files changed+98 added−121 removed
modified:.github/workflows/CICD.yml+97 added-120 removed
1 name: CICD2 3 env:4- MIN_SUPPORTED_RUST_VERSION: "1.67.0"4 CICD_INTERMEDIATES_DIR: "_cicd-intermediates"5+ MSRV_FEATURES: "--all-features"6 7 on:8 workflow_dispatch:9 pull_request:3 unmodified lines13 tags:14 - '*'15 16 jobs:17- code_quality:18- name: Code quality19- runs-on: ubuntu-20.0417+ crate_metadata:18+ name: Extract crate metadata19+ runs-on: ubuntu-latest20 steps:21- - name: Checkout source code22- uses: actions/checkout@v323- - name: Install rust toolchain21+ - uses: actions/checkout@v322+ - name: Extract crate information23+ id: crate_metadata24 run: |25- rm -f "${HOME}/.cargo/bin/"{rustfmt,cargo-fmt}26- rustup set profile minimal27- rustup toolchain install stable -c "clippy,rustfmt"28- rustup default stable29- - name: Rust cache30- uses: Swatinem/rust-cache@v231- - name: Ensure `cargo fmt` has been run32- run: cargo fmt --check33- - name: Ensure MSRV is set in `clippy.toml`34- run: grep "^msrv = \"${{ env.MIN_SUPPORTED_RUST_VERSION }}\"\$" clippy.toml35- - name: Run clippy36- run: cargo clippy --locked --all-targets --all-features25+ echo "name=fd" | tee -a $GITHUB_OUTPUT26+ cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT27+ cargo metadata --no-deps --format-version 1 | jq -r '"maintainer=" + .packages[0].authors[0]' | tee -a $GITHUB_OUTPUT28+ cargo metadata --no-deps --format-version 1 | jq -r '"homepage=" + .packages[0].homepage' | tee -a $GITHUB_OUTPUT29+ cargo metadata --no-deps --format-version 1 | jq -r '"msrv=" + .packages[0].rust_version' | tee -a $GITHUB_OUTPUT30+ outputs:31+ name: ${{ steps.crate_metadata.outputs.name }}32+ version: ${{ steps.crate_metadata.outputs.version }}33+ maintainer: ${{ steps.crate_metadata.outputs.maintainer }}34+ homepage: ${{ steps.crate_metadata.outputs.homepage }}35+ msrv: ${{ steps.crate_metadata.outputs.msrv }}36 37+ ensure_cargo_fmt:38+ name: Ensure 'cargo fmt' has been run39+ runs-on: ubuntu-20.0440+ steps:41+ - uses: dtolnay/rust-toolchain@stable42+ with:43+ components: rustfmt44+ - uses: actions/checkout@v345+ - run: cargo fmt -- --check46+47 min_version:48 name: Minimum supported rust version49 runs-on: ubuntu-20.0450+ needs: crate_metadata51 steps:52 - name: Checkout source code53 uses: actions/checkout@v354 45- - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})46- run: |47- rustup set profile minimal48- rustup toolchain install ${{ env.MIN_SUPPORTED_RUST_VERSION }} -c clippy49- rustup default ${{ env.MIN_SUPPORTED_RUST_VERSION }}50- - name: Rust cache51- uses: Swatinem/rust-cache@v255+ - name: Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }})56+ uses: dtolnay/rust-toolchain@master57+ with:58+ toolchain: ${{ needs.crate_metadata.outputs.msrv }}59+ components: clippy60 - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)53- run: cargo clippy --locked --all-targets --all-features61+ run: cargo clippy --locked --all-targets ${{ env.MSRV_FEATURES }}62 - name: Run tests55- run: cargo test --locked63+ run: cargo test --locked ${{ env.MSRV_FEATURES }}64 65 build:58- name: ${{ matrix.job.os }} (${{ matrix.job.target }})66+ name: ${{ matrix.job.target }} (${{ matrix.job.os }})67 runs-on: ${{ matrix.job.os }}68+ needs: crate_metadata69 strategy:70 fail-fast: false71 matrix:72 job:64- - { os: ubuntu-20.04, target: arm-unknown-linux-gnueabihf , use-cross: true }65- - { os: ubuntu-20.04, target: arm-unknown-linux-musleabihf, use-cross: true }66- - { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu , use-cross: true }67- - { os: ubuntu-20.04, target: i686-unknown-linux-gnu , use-cross: true }68- - { os: ubuntu-20.04, target: i686-unknown-linux-musl , use-cross: true }69- - { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu , use-cross: true }70- - { os: ubuntu-20.04, target: x86_64-unknown-linux-musl , use-cross: true }71- - { os: macos-12 , target: x86_64-apple-darwin }72- # - { os: windows-2019, target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found73- - { os: windows-2019, target: i686-pc-windows-msvc }74- - { os: windows-2019, target: x86_64-pc-windows-gnu }75- - { os: windows-2019, target: x86_64-pc-windows-msvc }73+ - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }74+ - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true }75+ - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true }76+ - { target: i686-pc-windows-msvc , os: windows-2019 }77+ - { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }78+ - { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }79+ - { target: x86_64-apple-darwin , os: macos-12 }80+ - { target: x86_64-pc-windows-gnu , os: windows-2019 }81+ - { target: x86_64-pc-windows-msvc , os: windows-2019 }82+ - { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }83+ - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }84+ env:85+ BUILD_CMD: cargo86 steps:87 - name: Checkout source code88 uses: actions/checkout@v389 4 unmodified lines94 arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;95 aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;96 esac97 88- - name: Extract crate information89- shell: bash90- run: |91- echo "PROJECT_NAME=fd" >> $GITHUB_ENV92- echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV93- echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV94- echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV95-98 - name: Install Rust toolchain97- run: |98- rustup set profile minimal99- rustup toolchain install stable100- rustup override set stable101- rustup target add ${{ matrix.job.target }}99+ uses: dtolnay/rust-toolchain@stable100+ with:101+ targets: ${{ matrix.job.target }}102 103+ - name: Install cross104+ if: matrix.job.use-cross105+ uses: taiki-e/install-action@v2106+ with:107+ tool: cross108+109+ - name: Overwrite build command env variable110+ if: matrix.job.use-cross111+ shell: bash112+ run: echo "BUILD_CMD=cross" >> $GITHUB_ENV113+114 - name: Show version information (Rust, cargo, GCC)115 shell: bash116 run: |117 gcc --version || true2 unmodified lines120 rustup default121 cargo -V122 rustc -V123 113- - name: Set cargo cmd124+ - name: Build125 shell: bash115- run: echo "CARGO_CMD=cargo" >> $GITHUB_ENV126+ run: $BUILD_CMD build --locked --release --target=${{ matrix.job.target }}127 117- - name: Set cargo cmd to cross128+ - name: Set binary name & path129+ id: bin130 shell: bash119- if: ${{ matrix.job.use-cross == true }}120- run: echo "CARGO_CMD=cross" >> $GITHUB_ENV121-122- - name: Rust cache123- uses: Swatinem/rust-cache@v2124- with:125- key: ${{ matrix.job.os }}-${{ matrix.job.target }}126-127- - name: Install cross128- if: ${{ matrix.job.use-cross == true }}129- run: cargo install cross130-131- - name: Build132- run: ${{ env.CARGO_CMD }} build --locked --release --target=${{ matrix.job.target }}133-134- - name: Strip debug information from executable135- id: strip136- shell: bash131 run: |132 # Figure out suffix of binary133 EXE_suffix=""134 case ${{ matrix.job.target }} in135 *-pc-windows-*) EXE_suffix=".exe" ;;136 esac;137 144- # Figure out what strip tool to use if any145- STRIP="strip"146- case ${{ matrix.job.target }} in147- arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;148- aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;149- *-pc-windows-msvc) STRIP="" ;;150- esac;151-138 # Setup paths153- BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/"154- mkdir -p "${BIN_DIR}"155- BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}"156- BIN_PATH="${BIN_DIR}/${BIN_NAME}"139+ BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}"140+ BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"141 158- # Copy the release build binary to the result location159- cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}"160-161- # Also strip if possible162- if [ -n "${STRIP}" ]; then163- "${STRIP}" "${BIN_PATH}"164- fi165-166- # Let subsequent steps know where to find the (stripped) bin142+ # Let subsequent steps know where to find the binary143 echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT144 echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT145 146 - name: Set testing options1 unmodified line148 shell: bash149 run: |150 # test only library unit tests and binary for arm-type targets151 unset CARGO_TEST_OPTIONS176- unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;152+ unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--bin ${{ needs.crate_metadata.outputs.name }}" ;; esac;153 echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT154 155 - name: Run tests156+ shell: bash180- run: ${{ env.CARGO_CMD }} test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}157+ run: $BUILD_CMD test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}158 159 - name: Generate completions160 id: completions161 shell: bash3 unmodified lines165 id: package166 shell: bash167 run: |168 PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;192- PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }}169+ PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.target }}170 PKG_NAME=${PKG_BASENAME}${PKG_suffix}171 echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT172 173 PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"174 ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"175 mkdir -p "${ARCHIVE_DIR}"176 177 # Binary201- cp "${{ steps.strip.outputs.BIN_PATH }}" "$ARCHIVE_DIR"178+ cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR"179 203- # Man page204- cp 'doc/${{ env.PROJECT_NAME }}.1' "$ARCHIVE_DIR"205-180 # README, LICENSE and CHANGELOG files181 cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"182 183+ # Man page184+ cp 'doc/${{ needs.crate_metadata.outputs.name }}.1' "$ARCHIVE_DIR"185+186 # Autocompletion files187 cp -r autocomplete "${ARCHIVE_DIR}"188 189 # base compressed package16 unmodified lines206 DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package"207 DPKG_DIR="${DPKG_STAGING}/dpkg"208 mkdir -p "${DPKG_DIR}"209 233- DPKG_BASENAME=${PROJECT_NAME}234- DPKG_CONFLICTS=${PROJECT_NAME}-musl235- case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${PROJECT_NAME}-musl ; DPKG_CONFLICTS=${PROJECT_NAME} ;; esac;236- DPKG_VERSION=${PROJECT_VERSION}210+ DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}211+ DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }}-musl212+ case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac;213+ DPKG_VERSION=${{ needs.crate_metadata.outputs.version }}214 215 unset DPKG_ARCH216 case ${{ matrix.job.target }} in217 aarch64-*-linux-*) DPKG_ARCH=arm64 ;;6 unmodified lines224 DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb"225 echo "DPKG_NAME=${DPKG_NAME}" >> $GITHUB_OUTPUT226 227 # Binary251- install -Dm755 "${{ steps.strip.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.strip.outputs.BIN_NAME }}"228+ install -Dm755 "${{ steps.bin.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.bin.outputs.BIN_NAME }}"229 230 # Man page254- install -Dm644 'doc/${{ env.PROJECT_NAME }}.1' "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"255- gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"231+ install -Dm644 'doc/${{ needs.crate_metadata.outputs.name }}.1' "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1"232+ gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1"233 234 # Autocompletion files258- install -Dm644 'autocomplete/fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/${{ env.PROJECT_NAME }}"259- install -Dm644 'autocomplete/fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ env.PROJECT_NAME }}.fish"260- install -Dm644 'autocomplete/_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ env.PROJECT_NAME }}"235+ install -Dm644 'autocomplete/fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/${{ needs.crate_metadata.outputs.name }}"236+ install -Dm644 'autocomplete/fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ needs.crate_metadata.outputs.name }}.fish"237+ install -Dm644 'autocomplete/_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ needs.crate_metadata.outputs.name }}"238 239 # README and LICENSE240 install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md"241 install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT"2 unmodified lines244 gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"245 246 cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" <<EOF247 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/271- Upstream-Name: ${{ env.PROJECT_NAME }}272- Source: ${{ env.PROJECT_HOMEPAGE }}248+ Upstream-Name: ${{ needs.crate_metadata.outputs.name }}249+ Source: ${{ needs.crate_metadata.outputs.homepage }}250 251 Files: *275- Copyright: ${{ env.PROJECT_MAINTAINER }}276- Copyright: $COPYRIGHT_YEARS ${{ env.PROJECT_MAINTAINER }}252+ Copyright: ${{ needs.crate_metadata.outputs.maintainer }}253+ Copyright: $COPYRIGHT_YEARS ${{ needs.crate_metadata.outputs.maintainer }}254 License: Apache-2.0 or MIT255 256 License: Apache-2.0257 On Debian systems, the complete text of the Apache-2.0 can be found in the32 unmodified lines290 Package: ${DPKG_BASENAME}291 Version: ${DPKG_VERSION}292 Section: utils293 Priority: optional317- Maintainer: ${{ env.PROJECT_MAINTAINER }}318- Homepage: ${{ env.PROJECT_HOMEPAGE }}294+ Maintainer: ${{ needs.crate_metadata.outputs.maintainer }}295+ Homepage: ${{ needs.crate_metadata.outputs.homepage }}296 Architecture: ${DPKG_ARCH}320- Provides: ${{ env.PROJECT_NAME }}297+ Provides: ${{ needs.crate_metadata.outputs.name }}298 Conflicts: ${DPKG_CONFLICTS}299 Description: simple, fast and user-friendly alternative to find300 fd is a program to find entries in your filesystem.301 It is a simple, fast and user-friendly alternative to find.39 unmodified linesmodified:Cargo.toml+1 added
85 unmodified lines8687888990919293943 unmodified lines85 unmodified linestest-case = "2.2"
[profile.release]lto = truestrip = truecodegen-units = 1
[features]use-jemalloc = ["jemallocator"]3 unmodified linesdeleted:clippy.toml-1 removed
1msrv = "1.67.0"