Skip to content

Commit

Permalink
Adding header check action
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed Mar 5, 2024
1 parent a4fbb9e commit b4cddba
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/header.yml
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
27 changes: 27 additions & 0 deletions .nextmv/check_header.py
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")

0 comments on commit b4cddba

Please sign in to comment.