Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/scripts/check-license.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import sys
from pathlib import Path

REQUIRED_LICENSE = [
"#",
"# This program is free software: you can redistribute it and/or modify",
"# it under the terms of the GNU Affero General Public License as published",
"# by the Free Software Foundation, either version 3 of the License, or",
"# (at your option) any later version.",
"#",
"# This program is distributed in the hope that it will be useful,",
"# but WITHOUT ANY WARRANTY; without even the implied warranty of",
"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
"# GNU Affero General Public License for more details.",
"#",
"# You should have received a copy of the GNU Affero General Public License",
"# along with this program. If not, see <https://www.gnu.org/licenses/>."
]

SOURCE_EXTS = {".py", ".js", ".ts", ".java", ".c", ".cpp", ".go", ".rs"}

IGNORE_DIRS = {
"docs",
".github"
}
IGNORE_FILES = {
"LICENSE",
"mkdocs.yml",
".readthedocs.yml",
".gitignore"

}

def check_file(path):
try:
with open(path, "r", encoding="utf-8") as f:
lines = [line.rstrip("\n") for line in f.readlines()]
except UnicodeDecodeError:
return True
if len(lines) < len(REQUIRED_LICENSE) + 2:
return False

return lines[2:2+len(REQUIRED_LICENSE)] == REQUIRED_LICENSE

def main():
failed_files = []
for file_path in Path(".").rglob("*"):
if (
file_path.is_file()
and file_path.suffix in SOURCE_EXTS
and not any(part in IGNORE_DIRS for part in file_path.parts)
and file_path.name not in IGNORE_FILES
):
if not check_file(file_path):
failed_files.append(str(file_path))

if failed_files:
print("License header check failed for these files:")
for f in failed_files:
print(f" - {f}")
sys.exit(1)

if __name__ == "__main__":
main()
22 changes: 22 additions & 0 deletions .github/workflows/check-license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check License
permissions:
contents: read

on:
pull_request:
branches: [ main, dev, testing ]

jobs:
license-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Run license check
run: python .github/scripts/check-license.py
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ A Flask-based webapp for (book) library management, with reserves, loans, renewa

Can run on a locally hosted server.

## Wiki
[Home](https://github.com/The-CS-Nerds/Library-System/wiki)
[Installation](https://github.com/The-CS-Nerds/Library-System/wiki/Installation)
## Documentation:

See our [**read the docs page**](https://library-system.readthedocs.io/en/latest/)

## Versions
Currently in development.
Expand Down
2 changes: 0 additions & 2 deletions Tech-Stack.md

This file was deleted.

1 change: 0 additions & 1 deletion secrets/casbin_login_pass.txt

This file was deleted.

1 change: 0 additions & 1 deletion secrets/db_pass.txt

This file was deleted.