Skip to content

Commit ce56f34

Browse files
committed
ci: add GHA and license linters
1 parent 7dbfa13 commit ce56f34

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

.github/workflows/pr_lint_gha.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: GitHub Actions
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: ["**"]
7+
paths:
8+
- ".github/**.yaml"
9+
- ".github/**.yml"
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
lint:
20+
name: Lint
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v6
24+
25+
- name: Install actionlint
26+
run: bash <(curl -s https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
27+
28+
- name: Run actionlint
29+
run: ./actionlint
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Check License
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: ["**"]
7+
paths:
8+
- "**/Cargo.toml"
9+
- "LICENSE*"
10+
- ".github/workflows/pr_lint_license.yaml"
11+
12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
check-license:
21+
name: Verify License
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v6
25+
26+
- name: Check LICENSE file exists
27+
run: |
28+
if [ ! -f LICENSE ]; then
29+
echo "::error::LICENSE file is missing"
30+
exit 1
31+
fi
32+
echo "License file present"
33+
34+
- name: Check all packages reference LICENSE
35+
run: |
36+
MISSING=$(cargo metadata --format-version 1 --no-deps 2>/dev/null | \
37+
jq -r '.packages[] | select(.license != "LICENSE") | .name')
38+
39+
if [ -n "$MISSING" ]; then
40+
echo "::error::The following packages do not reference 'LICENSE':"
41+
echo "$MISSING"
42+
echo ""
43+
echo "Ensure each Cargo.toml has: license = \"LICENSE\""
44+
exit 1
45+
fi
46+
47+
echo "All packages correctly reference LICENSE file"

0 commit comments

Comments
 (0)