Skip to content

Commit ded0756

Browse files
authored
ci: add github CI pipeline with lint, build and test steps (OpenPRoT#13)
This CI is limited to the main branch and PRs. Does not run on draft PRs. Solves OpenPRoT#2 --------- Signed-off-by: Christian Grönke <[email protected]>
1 parent b04c480 commit ded0756

File tree

4 files changed

+117
-1
lines changed

4 files changed

+117
-1
lines changed

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build and Test
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
push:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
12+
pull-requests: read
13+
14+
jobs:
15+
lint:
16+
name: Rustfmt + Clippy
17+
runs-on: ubuntu-latest
18+
# Skip for draft PRs, run for pushes and non-draft PRs
19+
if: github.event.pull_request.draft == false || github.event_name != 'pull_request'
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 1
25+
26+
- name: Install Rust (stable) with components
27+
uses: dtolnay/rust-toolchain@stable
28+
with:
29+
components: clippy, rustfmt
30+
31+
- name: Cache cargo registry and build
32+
uses: Swatinem/rust-cache@v2
33+
34+
- name: rustfmt check
35+
run: cargo fmt --all -- --check
36+
37+
- name: clippy (deny warnings)
38+
run: |
39+
cargo clippy --all-targets --all-features -- --deny warnings
40+
41+
build:
42+
name: Cargo Build
43+
runs-on: ubuntu-latest
44+
needs: lint
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 1
50+
51+
- name: Install Rust (stable)
52+
uses: dtolnay/rust-toolchain@stable
53+
54+
- name: Cache cargo registry and build
55+
uses: Swatinem/rust-cache@v2
56+
57+
- name: Build
58+
run: |
59+
set -e
60+
cargo build --workspace --all-targets --verbose
61+
62+
test:
63+
name: Cargo Test
64+
runs-on: ubuntu-latest
65+
needs: build
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 1
71+
72+
- name: Install Rust (stable)
73+
uses: dtolnay/rust-toolchain@stable
74+
75+
- name: Cache cargo registry and build
76+
uses: Swatinem/rust-cache@v2
77+
78+
- name: Run tests
79+
run: |
80+
set -e
81+
cargo test --workspace --all-features --verbose

.github/workflows/license.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: License Check
2+
3+
on: pull_request
4+
5+
jobs:
6+
license:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: License Eye Header
11+
uses: apache/[email protected]

.licenserc.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
header:
2+
license:
3+
spdx-id: Apache-2.0
4+
# No copyright owner until this has been clarified
5+
# copyright-owner: OpenPRoT a Series of LF Projects, LLC
6+
copyright-year: 2025
7+
software-name: mctp-lib
8+
9+
paths:
10+
- '**/*.rs'
11+
12+
comment: on-failure

src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
// Licensed under the Apache-2.0 license
1+
// Copyright 2025
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
214

315
//! This crate provides a platform-agnostic MCTP stack.
416
//!

0 commit comments

Comments
 (0)