Skip to content

Commit

Permalink
Add code checks to CI and do_checks script
Browse files Browse the repository at this point in the history
  • Loading branch information
TheQuantumPhysicist committed Apr 18, 2024
1 parent 4c47018 commit e273303
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 6 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Static code checks

on:
push:
branches:
- "**" # target all branches
pull_request:
branches:
- master

env:
CARGO_TERM_COLOR: always
RUST_LOG: debug
RUST_BACKTRACE: full

jobs:
static_checks_ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive

- name: Update local dependency repositories
run: sudo apt-get update
- name: Install dependencies
run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml

- name: Install rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version-extractor/rust-version-extractor.py)
- name: Install rust clippy
run: rustup component add clippy
- name: Install cargo-deny
run: cargo install cargo-deny --locked
- name: Run checks
run: ./do_checks.sh

static_checks_windows:
runs-on: windows-latest
steps:
# This prevents git from changing line-endings to crlf, which messes cargo fmt checks
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install python toml package
run: python3 -m pip install toml
- name: Install rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version-extractor/rust-version-extractor.py)
- name: Install rust clippy
run: rustup component add clippy
- name: Install cargo-deny
run: cargo install cargo-deny --locked
- name: Run checks
shell: bash
run: ./do_checks.sh

static_checks_macos:
runs-on: macos-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install python toml package
run: python3 -m pip install toml
- name: Install rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version-extractor/rust-version-extractor.py)
- name: Install rust clippy
run: rustup component add clippy
- name: Install cargo-deny
run: cargo install cargo-deny --locked
- name: Run checks
run: bash ./do_checks.sh
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[sources.allow-org]
github = [
"mintlayer", # allow any code from mintlayer's github
]

[licenses]
#we reject code without a license
confidence-threshold = 0.92
allow = [
"Apache-2.0",
"MIT",
"Unicode-DFS-2016",
] # deny a license not in this set of licenses

[[licenses.clarify]]
name = "ring"
expression = "LicenseRef-ring"
license-files = [
{ path = "LICENSE", hash = 0xbd0eed23 },
]

[[licenses.clarify]]
name = "webpki"
expression = "LicenseRef-webpki"
license-files = [
{ path = "LICENSE", hash = 0x001c7e6c },
]

[[licenses.clarify]]
name = "rustls-webpki"
expression = "LicenseRef-webpki"
license-files = [
{ path = "LICENSE", hash = 0x001c7e6c },
]

[advisories]
db-path = "~/.cargo/advisory-dbs"
db-urls = [ "https://github.com/RustSec/advisory-db" ]
yanked = "warn"
ignore = []
14 changes: 14 additions & 0 deletions do_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
PYTHON=$(which python || which python3)

cargo fmt --check -- --config newline_style=Unix

# Install cargo deny first with: cargo install cargo-deny
cargo deny check --hide-inclusion-graph

# Checks enabled everywhere, including tests, benchmarks
cargo clippy

0 comments on commit e273303

Please sign in to comment.