-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4fbb9e
commit b4cddba
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: header | ||
on: [push] | ||
jobs: | ||
check-header: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: git clone | ||
uses: actions/checkout@v4 | ||
|
||
- name: set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: check header in .py files | ||
run: | | ||
python .nextmv/check_header.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Description: This script checks if the header is present in all go files. | ||
import glob | ||
import sys | ||
|
||
HEADER = "// © 2019-present nextmv.io inc" | ||
|
||
# List all go files in all subdirectories | ||
go_files = glob.glob("**/*.go", recursive=True) | ||
|
||
# Check if the header is the first line of each file | ||
missing = [] | ||
checked = 0 | ||
for file in go_files: | ||
with open(file, "r") as f: | ||
first_line = f.readline().strip() | ||
if first_line != HEADER: | ||
missing.append(file) | ||
checked += 1 | ||
|
||
# Print the results | ||
if missing: | ||
print(f"Missing header in {len(missing)} of {checked} files:") | ||
for file in missing: | ||
print(f" {file}") | ||
sys.exit(1) | ||
else: | ||
print(f"Header is present in all {checked} files") |