Skip to content

C++ numbers

C++ numbers #215

Workflow file for this run

#
# .github/workflows/rust.yml
#
---
name: Rust Workflow
on: # yamllint disable-line rule:truthy
pull_request:
jobs:
stage1:
name: Change Check
runs-on: 'ubuntu-latest'
outputs:
docs_changed: ${{ steps.check_file_changed.outputs.docs_changed }}
steps:
- name: Checkout Repo
id: checkout-repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
submodules: recursive
- name: Get Change List
id: check_file_changed
run: |
# Diff HEAD with the previous commit then output to stdout.
printf "=== Which files changed? ===\n"
GIT_DIFF="$(git diff --name-only HEAD^ HEAD)"
printf "%s\n" "${GIT_DIFF}"
printf "\n"
# Check if the files are present in the changed file list (added, modified, deleted) then output to stdout.
HAS_DIFF=false
printf "=== Which Rust files changed? ===\n"
if printf "%s\n" "${GIT_DIFF}" | grep -E '^(.*[.]rs|.*/Cargo[.]toml|.github/workflows/rust.yml)$'; then
HAS_DIFF=true
fi
printf "\n"
# Did Golang files change?
printf "=== Did Golang files change? ===\n"
printf "%s\n" "${HAS_DIFF}"
printf "\n"
# Set the output named "docs_changed"
printf "%s=%s\n" "docs_changed" "${HAS_DIFF}" >> "${GITHUB_OUTPUT}"
stage2:
name: Rust Checks
strategy:
matrix:
rust-version: ["stable"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
exclude:
- os: "macos-latest"
rust-version: "stable"
- os: "windows-latest"
rust-version: "stable"
runs-on: "${{ matrix.os }}"
needs: [stage1]
if: needs.stage1.outputs.docs_changed == 'True'
steps:
- name: Checkout Repo
id: checkout-repo
uses: actions/checkout@v3
- name: Set up Rust Toolchain ${{ matrix.rust-version }}
id: setup-rust-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
- name: Set up Rust Cargo ${{ matrix.rust-version }}
id: setup-rust-cargo
uses: actions-rs/cargo@v1
with:
command: version
args: --verbose
- name: Show Rust version
id: rust-version
run: |
rustc --version
printf "\n"
cargo version
- name: Install Rust Tools
id: install-rust-tools
run: |
sudo tee -a /etc/apt/sources.list <<EOF
deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main
deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy main
deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main
deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main
deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main
deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main
EOF
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt update
sudo apt install -y clang-14 lldb-14 lld-14
# sudo apt install -y libllvm-14-ocaml-dev libllvm14 llvm-14 llvm-14-dev llvm-14-doc llvm-14-examples llvm-14-runtime
sudo apt install -y libssl-dev
sudo apt install -y lcov
sudo apt install -y make
rustup component add clippy
cargo install grcov
cargo install cargo-kcov
cargo install cargo-tarpaulin
- name: CD to Rust Dir
id: cd-to-rust-dir
run: |
pwd
ls
cd ./rust
pwd
ls
- name: Analysing the code with cargo check
id: cargo-check
run: |
cd ./rust
./for_each cargo check --release
- name: Analysing the code with cargo clippy
id: cargo-clippy
run: |
cd ./rust
./for_each cargo clippy --release
- name: Testing with cargo tarpaulin
id: cargo-tarpaulin
run: |
cd ./rust
# don't use --verbose, it exposes environment variables
# ./for_each cargo tarpaulin --release --timeout=300 --bins
./for_each cargo tarpaulin --release --timeout=300
- name: Clean up before test run with llvm coverage
id: cargo-test-clean-up
run: |
cd ./rust
./for_each cargo clean
find . -type f -name '*.profraw' -delete -print
find . -type f -name '*.profdata' -delete -print
- name: Testing with cargo test coverage
id: cargo-test-coverage
run: |
cd ./rust
export RUSTFLAGS="-C instrument-coverage"
export RUSTDOCFLAGS="-C instrument-coverage"
# ./for_each cargo test --release
./for_each cargo test
printf "#!/bin/bash\n\n" > ./llvm-cov-14-merge
echo 'llvm-profdata-14 merge -sparse default_*.profraw -o json5format.profdata' >> ./llvm-cov-14-merge
chmod -v a+x ./llvm-cov-14-merge
./for_each ../llvm-cov-14-merge
# shellcheck disable=SC2046
printf "#!/bin/bash\n\n" > ./llvm-cov-14-report
# shellcheck disable=SC2016
echo 'llvm-cov-14 report $(for file in $(cargo test --tests --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - ); do printf "%s %s " -object "${file}"; done) --instr-profile=json5format.profdata --summary-only' >> ./llvm-cov-14-report
chmod -v a+x ./llvm-cov-14-report
./for_each ../llvm-cov-14-report
unset RUSTFLAGS
unset RUSTDOCFLAGS
- name: Testing with cargo audit
id: cargo-audit
run: |
cd ./rust
./for_each cargo audit