clean up #6717
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint | |
on: | |
push: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
actionlint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Run actionlint | |
uses: devops-actions/[email protected] | |
with: | |
shellcheck_opts: '-e SC2086' | |
rustfmt: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Cache | |
uses: ./.github/actions/cache | |
- name: Install nightly-2024-10-21 toolchain and rustfmt | |
run: rustup install nightly-2024-10-21 && rustup default nightly-2024-10-21 && rustup component add rustfmt | |
- run: cargo fmt --all -- --check | |
clippy: | |
name: "clippy #${{ matrix.platform }} ${{ matrix.rust_version }}" | |
runs-on: ${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
rust_version: ["1.76.0", "stable", "nightly-2024-10-21"] | |
platform: [windows-latest, ubuntu-latest] | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Cache | |
uses: ./.github/actions/cache | |
with: | |
rust_version: ${{ matrix.rust_version }} | |
- name: Install ${{ matrix.rust_version }} toolchain and clippy | |
run: rustup install ${{ matrix.rust_version }} && rustup default ${{ matrix.rust_version }} && rustup component add clippy | |
- name: Install Protoc Binary | |
shell: bash | |
run: chmod +x ./scripts/install-protoc.sh && ./scripts/install-protoc.sh $HOME | |
- name: Run clippy on ${{ matrix.platform }} ${{ matrix.rust_version }} | |
shell: bash | |
run: | | |
# shellcheck disable=SC2046 | |
cargo clippy --workspace --all-targets --all-features -- -D warnings $([ ${{ matrix.rust_version }} = 1.76.0 ] || [ ${{ matrix.rust_version }} = stable ] && echo -Aunknown-lints -Ainvalid_reference_casting -Aclippy::redundant-closure-call) | |
licensecheck: | |
runs-on: ubuntu-latest | |
name: "Presence of licence headers" | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install licensecheck | |
run: sudo apt-get install -y licensecheck | |
- name: Check licenses | |
# Exclude symbolizer-ffi from the checks (mostly imported code) | |
run: '! find . \( -name "*.rs" -o -name "*.c" -o -name "*.sh" \) -not -path "./symbolizer-ffi/*" -not -path "*/tarpc/*" -print0 | xargs -0 licensecheck -c ".*" | grep -v "Apache License 2.0"' | |
# todo: fix upstream warnings; from the readme: | |
# The most common cause of missing licenses seems to be workspaces that | |
# don't include forward their license files. Go to the repo for the | |
# workspace and copy the relevant files from there. | |
# A package license may receive a confidence warning stating that | |
# cargo-bundle-licenses is "unsure" or "semi" confident. This means that | |
# when the found license was compared to a template license it was found to | |
# have diverged in more than a few words. You should verify that the licence | |
# text is in fact correct in these cases. | |
# | |
# If this job fails, you probably need to regenerate the license, e.g. | |
# CARGO_HOME=/tmp/dd-cargo cargo bundle-licenses --format yaml --output LICENSE-3rdparty.yml | |
license-3rdparty: | |
runs-on: ubuntu-latest | |
name: "Valid LICENSE-3rdparty.yml" | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- run: stat LICENSE-3rdparty.yml | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/ | |
~/.cargo/git/db/ | |
~/.cargo/bin/ | |
~/.cargo/.crates.toml | |
# cache key contains current version of cargo-bundle-licenses | |
# when upstream version is updated we can bump the cache key version, | |
# to cache the latest version of the tool | |
key: "v1-2.0.0" | |
# cargo-bundle-licenses v2.0 doesn't understand path differences due to | |
# sparse vs git index, so force git. | |
- run: mkdir -p .cargo && printf "[registries.crates-io]\nprotocol = \"git\"\n" > .cargo/config.toml | |
- run: cargo install cargo-bundle-licenses | |
- name: "Generate new LICENSE-3rdparty.yml and check against the previous" | |
env: | |
CARGO_HOME: "/tmp/dd-cargo" | |
run: | | |
# Run cargo bundle-licenses without directly checking against a previous snapshot | |
cargo bundle-licenses \ | |
--format yaml \ | |
--output /tmp/CI.yaml | |
# Normalize the paths in both files to ignore registry differences | |
sed -E 's/(registry\/src\/)[^\/]+/\1normalized_path/g' /tmp/CI.yaml > /tmp/CI_normalized.yaml | |
sed -E 's/(registry\/src\/)[^\/]+/\1normalized_path/g' LICENSE-3rdparty.yml > /tmp/LICENSE-3rdparty_normalized.yml | |
# Now perform the diff on the normalized files | |
if ! diff /tmp/CI_normalized.yaml /tmp/LICENSE-3rdparty_normalized.yml; then | |
echo "Differences detected." | |
exit 1 | |
fi | |
echo "No differences found." | |
- name: export the generated license file on failure | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: LICENSE-3rdparty.yml | |
path: /tmp/CI.yaml | |
overwrite: true |