Skip to content

Commit 0b694db

Browse files
feat(ci): ensures license headers are added (#90)
Since the `make add-license` target is not part of the default Makefile target, there's no guarantee it will be run before a PR is opened or updated. To address this, a CI build job ensures licenses are present where needed. The `linters/check-license` GitHub job verifies that every relevant file includes the required license headers. Otherwise job fails and lists files both in the logs of the job as well as in the summary.
1 parent 89438a2 commit 0b694db

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/workflows/linters.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: linters
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
jobs:
7+
check-license:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Check licenses
12+
run: |
13+
make add-license
14+
clean=$(git status --porcelain --untracked-files=no | awk '{print $NF}')
15+
if [[ -n "${clean}" ]]; then
16+
files=$(printf "%s\n" "${clean}" | sed 's/^/- /')
17+
{
18+
echo "### :warning: Files Without License Found"
19+
echo "Run `make add-license` and update your PR."
20+
echo ""
21+
echo "${files}"
22+
echo ""
23+
} >> $GITHUB_STEP_SUMMARY
24+
exit 1
25+
fi

0 commit comments

Comments
 (0)