Skip to content

Add tests and highlight issues with should_panic #2074

Add tests and highlight issues with should_panic

Add tests and highlight issues with should_panic #2074

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
RUST_VERSION_COV: nightly-2024-06-05
REGISTRY: ghcr.io
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
check-scripts:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run shellcheck and shfmt on all scripts
uses: luizm/action-sh-checker@master
env:
SHELLCHECK_OPTS: -e SC3043 # exclude 'local' is undefined
SHFMT_OPTS: -i 4 -ci
with:
sh_checker_comment: false
sh_checker_exclude: "src"
publish-codecov:
name: Check code coverage (branch)
runs-on: ubuntu-latest
permissions: # Write access to push changes to pages
contents: write
steps:
- uses: actions/checkout@v3
- name: Install latest Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION_COV }}
- name: Install cargo-llvm-codecov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Code coverage report
run: cargo +${{ env.RUST_VERSION_COV }} llvm-cov --all-features --lcov --branch --output-path lcov.info
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v3
with:
coverage-files: lcov.info
minimum-coverage: 0 # for now we are not enforcing any minimum coverage.
artifact-name: code-coverage-report
github-token: ${{ secrets.REPO_TOKEN }}
update-comment: true
try-run-fuelup-init:
needs: cancel-previous-runs
if: github.event_name != 'release' || github.event.action != 'published'
name: Try fuelup installation with fuelup-init
strategy:
matrix:
job:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.job.os }}
steps:
- uses: actions/checkout@v3
- name: Attempt to install fuelup through fuelup-init.sh
run: ./fuelup-init.sh
cargo-clippy:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v1
- name: Check Clippy Linter
run: cargo clippy --locked --all-features --all-targets -- -D warnings
cargo-fmt-check:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- name: Check Formatting
run: cargo fmt --all -- --check
cargo-test-workspace:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test --locked --workspace
lint-toml-files:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Cargo.toml linter
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-toml-lint
version: "0.1"
- name: Run Cargo.toml linter
run: git ls-files | grep Cargo.toml$ | xargs --verbose -n 1 cargo-toml-lint
publish-check:
# Only do this job if publishing a release
needs:
[cancel-previous-runs, cargo-clippy, cargo-fmt-check, lint-toml-files]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Verify tag version
run: |
curl -sSLf "https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TOOLING }}
build-release:
name: build fuelup release binaries
runs-on: ${{ matrix.job.os }}
if: github.event_name == 'release' && github.event.action == 'published'
needs: cancel-previous-runs
strategy:
matrix:
job:
- os: ubuntu-latest
platform: linux
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
platform: linux
target: aarch64-unknown-linux-gnu
- os: macos-latest
platform: darwin
target: x86_64-apple-darwin
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.job.target }}
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
key: "${{ matrix.job.target }}"
- name: Use Cross
uses: baptiste0928/cargo-install@v1
with:
crate: cross
cache-key: "${{ matrix.job.target }}"
- name: Build fuelup
run: |
cross build --profile=release --target ${{ matrix.job.target }} -p fuelup
- name: Strip release binary x86_64-linux-gnu
if: matrix.job.target == 'x86_64-unknown-linux-gnu'
run: strip "target/${{ matrix.job.target }}/release/fuelup"
- name: Strip release binary aarch64-linux-gnu
if: matrix.job.target == 'aarch64-unknown-linux-gnu'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main \
aarch64-linux-gnu-strip \
/target/aarch64-unknown-linux-gnu/release/fuelup
- name: Strip release binary mac
if: matrix.job.os == 'macos-latest'
run: strip -x "target/${{ matrix.job.target }}/release/fuelup"
- name: Prep assets
id: prep_assets
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
run: |
# Get tag name
# See: https://git.luolix.topmunity/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
FUELUP_VERSION="${GITHUB_REF#refs/tags/}"
# trim v from tag prefix
FUELUP_VERSION="${FUELUP_VERSION#v}"
echo "version is: $FUELUP_VERSION"
# setup artifact filename
ARTIFACT="fuelup-$FUELUP_VERSION-${{ env.TARGET }}"
ZIP_FILE_NAME="$ARTIFACT.tar.gz"
echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV
# create zip file
mkdir -pv "$ARTIFACT"
cp "target/${{ matrix.job.target }}/release/fuelup" "$ARTIFACT"
tar -czvf $ZIP_FILE_NAME "$ARTIFACT"
- name: Upload release archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ env.ZIP_FILE_NAME }}
asset_name: ${{ env.ZIP_FILE_NAME }}
asset_content_type: application/gzipa
post-release-checks:
name: Do post-release checks
needs: [cancel-previous-runs, build-release]
if: github.event_name == 'release' && github.event.action == 'published'
strategy:
matrix:
job:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.job.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Try fuelup installation with fuelup-init
run: ./fuelup-init.sh