Skip to content

Commit fe2929c

Browse files
committed
I added a linter workflow to the sdk-rust project. It uses different actions to download the dependencies and dev-tools, one actin for caching. All those actions are organized in steps wherea the last one run the different jobs using a Makefile.
Feat/add linter ci check #2 (#7) * added apache 2.0 license to all crates * semgrep and dprint for code formatting * cargo-deny for managing crates licenses Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Rename cargo.toml to Cargo.toml Signed-off-by: Andrea Frittoli <andrea.frittoli@gmail.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> Add checkout step to the commit lint Signed-off-by: Andrea Frittoli <andrea.frittoli@gmail.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> fixed commit Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> completed rust cache Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> clippy Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> get rid of Makefile for the moment Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> removed unmaintained action Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> removed cache step for the moment Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> review some steps Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> changed makefile with jusfile, enabled register and added development tools Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> formated files Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> added allowed licenses Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> added more files to lint in dprint and refactored cache Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> makefile Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> changed unaccepted actions Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> changed unaccepted actions Signed-off-by: Hergy Fongue <hergy.fongue@ext.markant.com> Signed-off-by: rjtch <tchuinkoufongue@gmail.com> added taiki-e/install-action@v2 instead of taiki-e/install-action@protoc Signed-off-by: rjtch <tchuinkoufongue@gmail.com> Rename cargo.toml to Cargo.toml Signed-off-by: Andrea Frittoli <andrea.frittoli@gmail.com> Add checkout step to the commit lint Signed-off-by: Andrea Frittoli <andrea.frittoli@gmail.com> remove unnecessary parameter Signed-off-by: rjtch <tchuinkoufongue@gmail.com>
1 parent 8a78246 commit fe2929c

File tree

20 files changed

+177
-18
lines changed

20 files changed

+177
-18
lines changed

.github/workflows/linter.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: linter
2+
3+
permissions:
4+
contents: read
5+
# To report GitHub Actions status checks
6+
statuses: write
7+
8+
on:
9+
push:
10+
branches: [ "main" ]
11+
pull_request:
12+
branches: [ "main" ]
13+
workflow_dispatch:
14+
inputs:
15+
commit_sha:
16+
description: Git commit sha, on which, to run this workflow
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
lint_commits:
24+
name: Lint Commit Messages
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
- name: Check Commit Lint
30+
uses: wagoid/commitlint-github-action@v5.4.5
31+
32+
lint_check:
33+
name: Rust - lint_${{ matrix.lint_projects }}
34+
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
lint_projects:
39+
- cargo_fmt_check
40+
- cargo_toml_fmt_files
41+
- cargo_toml_check_files
42+
- cargo_clippy
43+
- cargo_deny
44+
steps:
45+
- name: Run the checkout command
46+
uses: actions/checkout@v4
47+
- name: Install rust toolchain
48+
uses: actions-rust-lang/setup-rust-toolchain@v1
49+
with:
50+
toolchain: nightly
51+
components: clippy, rustfmt
52+
- name: Install development tools
53+
uses: taiki-e/install-action@v2
54+
with:
55+
tool: cargo-deny, dprint
56+
- name: Rust Cache
57+
uses: actions/cache@v3
58+
continue-on-error: false
59+
with:
60+
path: |
61+
~/.cargo/bin
62+
~/.cargo/registry
63+
~/.cargo/git/db/
64+
key: ${{ runner.os }}-sdk-rust-${{ hashFiles('**/Cargo.lock') }}
65+
restore-keys: |
66+
${{ runner.os }}-sdk-rust-
67+
- name: Check cargo version
68+
run: cargo --version
69+
- name: Run lint ${{ matrix.lint_projects }}
70+
run: make -f Makefile lint_${{ matrix.lint_projects }}

Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[workspace]
2+
members = [
3+
"bindings",
4+
"factory",
5+
"types",
6+
"zz_artifact",
7+
"zz_branch",
8+
"zz_build",
9+
"zz_change",
10+
"zz_environment",
11+
"zz_incident",
12+
"zz_pipeline",
13+
"zz_repository",
14+
"zz_service",
15+
"zz_task",
16+
]

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
lint: lint_cargo_fmt_check lint_cargo_deny lint_cargo_clippy
2+
3+
lint_cargo_fmt_check:
4+
cargo fmt --all -- --check
5+
6+
lint_cargo_deny:
7+
cargo deny --all-features \
8+
check licenses advisories \
9+
--config=tools/cargo-deny/deny.toml
10+
11+
lint_cargo_clippy:
12+
cargo clippy --no-deps --all-targets -- -D warnings
13+
14+
lint_cargo_toml_fmt_files:
15+
dprint fmt --config=tools/dprint/dprint.json
16+
17+
lint_cargo_toml_check_files:
18+
dprint check --config=tools/dprint/dprint.json
19+
20+
clean:
21+
cargo clean
22+
23+
.PHONY:
24+
check \
25+
lint lint_cargo_fmt_check lint_cargo_deny lint_cargo_clippy lint_cargo_toml_files lint_cargo_readme lint_cargo_readme_% lint_cargo_toml_files \
26+
clean clean_% very_clean format

bindings/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "bindings"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

cargo.toml

Lines changed: 0 additions & 17 deletions
This file was deleted.

factory/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "factory"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

tools/cargo-deny/deny.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# cargo-deny is a cargo plugin that lets you lint your project's dependency graph
2+
# to ensure all your dependencies conform to your expectations and requirements.
3+
[bans]
4+
multiple-versions = "deny"
5+
# Dependencies cannot be specified with the "*" version.
6+
wildcards = "deny"
7+
8+
[licenses]
9+
unlicensed = "deny"
10+
copyleft = "deny"
11+
confidence-threshold = 0.95
12+
allow = [
13+
"Apache-2.0",
14+
"MIT",
15+
"BSD-2-Clause",
16+
]
17+
exceptions = []
18+
19+
[advisories]
20+
unmaintained = "deny"
21+
vulnerability = "deny"
22+
yanked = "warn"
23+
# Users who require or prefer Git to use SSH cloning instead of HTTPS,
24+
# such as implemented via "insteadOf" rules in Git config, can still
25+
# successfully fetch advisories with this enabled.
26+
#
27+
# See also:
28+
# https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
29+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html#the-git-fetch-with-cli-field-optional
30+
# https://github.com/EmbarkStudios/cargo-deny/pull/420
31+
git-fetch-with-cli = true

tools/dprint/dprint.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"includes": [
3+
"**/*.toml",
4+
"**/*.yaml",
5+
"**/*.rs"
6+
],
7+
"plugins": [
8+
"https://plugins.dprint.dev/toml-0.5.4.wasm"
9+
]
10+
}

types/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "types"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "MIT"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]

types/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

zz_artifact/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_artifact"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_branch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "zz_branch"
33
version = "0.1.0"
44
edition = "2021"
5-
5+
license = "MIT"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]

zz_build/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_build"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_change/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_change"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_environment/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_environment"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_incident/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_incident"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_pipeline/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_pipeline"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_repository/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_repository"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_service/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_service"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

zz_task/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zz_task"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

0 commit comments

Comments
 (0)