Skip to content

Commit fe342ce

Browse files
authored
chore(ci): add PR lint workflow and SPDX header pre-commit hook (#60)
Add pr-lint.yml to enforce conventional commit PR titles and run check-license-headers.sh on all tracked Rust, shell, and Dockerfile sources. Add scripts/check-license-headers.sh and opt-in .githooks/pre-commit (cargo fmt + staged header check). Apply AMD Apache-2.0 SPDX headers across the codebase so the new checks pass.
1 parent 971b7e6 commit fe342ce

44 files changed

Lines changed: 248 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.githooks/pre-commit

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Pre-commit checks:
4+
# 1. cargo fmt --check
5+
# 2. SPDX license headers on staged source files
6+
#
7+
# Bypass with: git commit --no-verify
8+
9+
if command -v cargo >/dev/null 2>&1; then
10+
if ! cargo fmt --all --check 2>/dev/null; then
11+
echo "pre-commit: cargo fmt found unformatted code."
12+
echo ""
13+
echo " Run: cargo fmt --all"
14+
echo " Bypass with: git commit --no-verify"
15+
exit 1
16+
fi
17+
fi
18+
19+
# Check SPDX license headers on staged source files
20+
mapfile -t staged < <(
21+
git diff --cached --name-only --diff-filter=d -- '*.rs' '*.proto' '*.py' '*.sh' '**/Dockerfile*'
22+
)
23+
24+
if [ ${#staged[@]} -gt 0 ]; then
25+
REPO_ROOT="$(git rev-parse --show-toplevel)"
26+
"$REPO_ROOT/scripts/check-license-headers.sh" "${staged[@]}" || exit 1
27+
fi

.github/workflows/pr-lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: PR Lint
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
validate-pr-title:
12+
runs-on: ubuntu-latest
13+
env:
14+
PATTERN: "^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\\([a-zA-Z0-9_-]+\\))?!?: .+$"
15+
16+
steps:
17+
- name: Validate PR title
18+
env:
19+
PR_TITLE: ${{ github.event.pull_request.title }}
20+
run: |
21+
echo "Checking PR title: '$PR_TITLE'"
22+
if ! echo "$PR_TITLE" | grep -Eq "$PATTERN"; then
23+
echo "FAIL: PR title does not match conventional commits format."
24+
echo "Expected: type(scope): description (e.g. 'feat(spur-cloud-api): add session API')"
25+
echo "Valid types: feat fix docs style refactor perf test build ci chore revert"
26+
exit 1
27+
fi
28+
echo "PASS: PR title is valid."
29+
30+
license-headers:
31+
name: SPDX License Headers
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Check SPDX license headers
37+
run: ./scripts/check-license-headers.sh

crates/spur-cloud-api/src/auth/github.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use axum::{
25
extract::{Query, State},
36
http::StatusCode,

crates/spur-cloud-api/src/auth/jwt.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use chrono::{Duration, Utc};
25
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
36
use serde::{Deserialize, Serialize};

crates/spur-cloud-api/src/auth/middleware.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use axum::{
25
extract::{Request, State},
36
http::StatusCode,

crates/spur-cloud-api/src/auth/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
pub mod github;
25
pub mod jwt;
36
pub mod middleware;

crates/spur-cloud-api/src/auth/oidc_common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use axum::http::HeaderMap;
25
use serde::Deserialize;
36
use tracing::debug;

crates/spur-cloud-api/src/auth/okta.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use axum::{
25
extract::{Query, State},
36
http::StatusCode,

crates/spur-cloud-api/src/auth/principal.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use uuid::Uuid;
25

36
/// Authenticated caller normalized at the application boundary.

crates/spur-cloud-api/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use serde::Deserialize;
25

36
#[derive(Debug, Clone, Deserialize, Default, PartialEq)]

0 commit comments

Comments
 (0)