Skip to content

Commit 1b0ac93

Browse files
committed
chore
1 parent 084fef2 commit 1b0ac93

11 files changed

Lines changed: 266 additions & 228 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ============================================================
2+
# .editorconfig (Standardize across editors and IDEs)
3+
# ============================================================
14
# REQ.UNIVERSAL: All professional GitHub project repositories MUST include .editorconfig.
25
# WHY: Establish a cross-editor baseline so diffs stay clean and formatting is consistent.
36
# ALT: Repository may omit .editorconfig ONLY if formatting is enforced equivalently by CI and formatter tooling.

.gitattributes

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
# WHY-FILE: Normalize line endings and GitHub language classification
2-
# to ensure cross-platform consistency and predictable CI behavior.
1+
# ============================================================
2+
# .gitattributes (Keep files consistent across operating systems)
3+
# ============================================================
34

4-
# === Core: Text normalization ===
5+
# REQ.UNIVERSAL: All professional GitHub project repositories MUST include .gitattributes.
6+
# WHY: Ensure consistent line endings, diff behavior, and file classification
7+
# across Windows, macOS, and Linux environments.
8+
# ALT: Repository may omit .gitattributes ONLY if equivalent normalization is
9+
# enforced reliably by tooling and CI (rare and fragile).
10+
# CUSTOM: Update file-type rules only when introducing new languages,
11+
# binary artifacts, or documentation formats.
12+
# NOTE: Rules are ordered by impact and generality, not alphabetically.
13+
# Git attributes are documented at https://git-scm.com/docs/gitattributes
14+
15+
# === Core defaults (always apply) ===
16+
17+
# WHY: Auto-detect text files and normalize line endings to avoid cross-platform drift.
518
* text=auto
619

720
# WHY-SECTION: Explicit EOL rules avoid platform-specific diffs and tool failures.

.github/dependabot.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1+
# ============================================================
2+
# .github/dependabot.yml (Check for GitHub Actions updates)
3+
# ============================================================
4+
# SOURCE: https://github.com/denisecase/templates
5+
#
16
# REQ.PROJECT: This repository SHOULD track GitHub Actions updates automatically.
2-
# WHY: GitHub Actions are executable dependencies and may receive security or behavior updates.
3-
# OBS: This repository has no language-level dependencies (Python, JS, Rust, etc.).
4-
# OBS: GitHub Actions are the only dependency class currently in scope.
7+
# WHY-FILE: GitHub Actions are executable dependencies and may receive security or behavior updates.
8+
# OBS: Language-level dependencies (e.g., Python packages) are upgraded manually.
9+
# OBS: GitHub Actions are the only dependency class automated here.
510
# ALT: Dependabot could be omitted if workflows are pinned and reviewed manually.
611
# CUSTOM: Update interval if CI cadence or security posture changes.
712

8-
version: 2
13+
# NOTE: This file automatically updates the versions used in Actions workflows.
14+
# You don't need to modify this file.
15+
# To disable: Delete this file or set enabled: false below.
16+
# enabled: false # Uncomment to disable Dependabot
917

10-
updates:
11-
- package-ecosystem: "github-actions"
12-
directory: "/"
18+
version: 2 # Dependabot configuration version
1319

14-
# WHY: Monthly cadence balances stability with security updates.
15-
# ALT: Use "weekly" for higher-security environments.
20+
updates:
21+
- package-ecosystem: "github-actions" # Dependency type
22+
directory: "/" # Location of GitHub Actions workflows
1623
schedule:
17-
interval: "monthly"
18-
19-
# WHY: Clear commit prefix simplifies changelog review and filtering.
24+
interval: "monthly" # ALT: Use "weekly" for higher security when needed
2025
commit-message:
21-
prefix: "(deps)"
26+
prefix: "(deps)" # WHY: enable filtering by commit type

.github/workflows/ci-hygiene.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/ci-md.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# ============================================================
2+
# .github/workflows/ci-md.yml (Continuous Integration)
3+
# ============================================================
4+
# SOURCE: https://github.com/denisecase/templates
5+
#
6+
# WHY-FILE: Minimal checks for repositories where hygiene is the primary gate.
7+
# OBS: CI does not introduce additional style rules beyond repo configuration.
8+
# NOTE: This workflow intentionally avoids requiring Python or pre-commit for contributors.
9+
10+
name: CI Hygiene (Markdown and YAML)
11+
12+
# WHY: Validate repo contents on pushes to main branch and pull requests.
13+
14+
on:
15+
push:
16+
branches: [main] # WHY: Run when pushing to main branch.
17+
pull_request:
18+
branches: [main] # WHY: Run on pull requests targeting main branch.
19+
workflow_dispatch: # WHY: Allow manual triggering from Actions tab.
20+
21+
permissions: # WHY: Use least privileges required.
22+
contents: read
23+
24+
jobs:
25+
ci:
26+
name: Repository checks (pre-commit)
27+
runs-on: ubuntu-latest # WHY: Linux environment matches most production deployments
28+
timeout-minutes: 10 # WHY: Prevent hanging jobs. If over, it is likely stuck.
29+
30+
steps:
31+
# ============================================================
32+
# ASSEMBLE: Get code
33+
# ============================================================
34+
35+
- name: A1) Checkout repository code
36+
# WHY: Needed to access files for checks.
37+
uses: actions/checkout@v6
38+
39+
# ============================================================
40+
# BASIC CHECKS: Run pre-commit checks
41+
# ============================================================
42+
43+
- name: B1) Lint Markdown
44+
# WHY: Enforce Markdown rules consistently (repo-config driven).
45+
uses: DavidAnson/markdownlint-cli2-action@v22
46+
with:
47+
globs: |
48+
**/*.md
49+
50+
51+
- name: B2) Lint YAML (uses .yamllint.yml)
52+
# WHY: Validate YAML correctness using repo-defined yamllint.yml rules.
53+
# OBS: Ensures GitHub Actions YAML and other YAML files remain valid.
54+
uses: ibiqlik/action-yamllint@v3
55+
with:
56+
config_file: yamllint.yml # WHY: Use repo policy; avoid drifting defaults.
57+
file_or_dir: . # WHY: Lint YAML across the repository.
58+
no_warnings: true # WHY: CI output should be actionable.
59+
60+
- name: B3) Detect CITATION.cff
61+
# WHY: Verify presence of CITATION.cff for conditional validation.
62+
id: detect_citation
63+
shell: bash
64+
run: |
65+
if [ -f "CITATION.cff" ]; then
66+
echo "present=true" >> "$GITHUB_OUTPUT"
67+
else
68+
echo "present=false" >> "$GITHUB_OUTPUT"
69+
fi
70+
71+
- name: B4) Validate CITATION.cff (if present)
72+
# WHY: Ensure CITATION.cff is well-formed without making it mandatory.
73+
if: ${{ steps.detect_citation.outputs.present == 'true' }}
74+
uses: dieghernan/cff-validator@v4

.github/workflows/links.yml

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# ============================================================
2+
# .github/workflows/links.yml (Lychee Link Checker)
3+
# ============================================================
4+
# SOURCE: https://github.com/denisecase/templates
5+
#
16
# WHY-FILE: Automated link checking.
27
# OBS: Behavior is configured in lychee.toml in this repository.
38
# OBS: Runs on pull requests and monthly on schedule; manual trigger always available.
@@ -6,9 +11,7 @@ name: Check Links
611

712
on:
813
workflow_dispatch: # WHY: Manual trigger - always available
9-
1014
pull_request: # WHY: Validates PR links before merge
11-
1215
schedule:
1316
- cron: "0 6 1 * *" # WHY: Runs monthly (1st of month)
1417

@@ -17,22 +20,33 @@ concurrency:
1720
group: link-check-${{ github.ref }}
1821
cancel-in-progress: true
1922

23+
permissions:
24+
contents: read # WHY: Needed to checkout code.
25+
issues: write # WHY: Needed to create issue on scheduled failures.
26+
pull-requests: write # WHY: Needed to comment on PR if links broken.
27+
28+
env:
29+
PYTHONUNBUFFERED: "1" # WHY: Real-time logging.
30+
PYTHONIOENCODING: "utf-8" # WHY: Ensure UTF-8 encoding for international characters.
31+
REPORT_FAILURES: "true" # WHY: Enable PR comments and scheduled issues for link failures.
32+
2033
jobs:
2134
lychee:
22-
runs-on: ubuntu-latest
23-
24-
permissions:
25-
contents: read
26-
issues: write
27-
pull-requests: write
35+
name: Link checks
36+
runs-on: ubuntu-latest # WHY: Linux environment matches most production deployments
37+
timeout-minutes: 20 # WHY: Prevent hanging jobs. If over time, likely stuck.
2838

2939
steps:
3040
- name: 1) Checkout repository code
31-
uses: actions/checkout@v6 # OBS: v6 current as of Dec 2025
41+
uses: actions/checkout@v6
3242

3343
- name: 2) Check links with Lychee
34-
uses: lycheeverse/lychee-action@v2
44+
id: lychee
45+
uses: lycheeverse/lychee-action@v2.7.0
3546
with:
47+
# WHY: Do not hard-fail this step; always run reporting steps.
48+
# Instead, fail the job explicitly at the end if exit_code != 0.
49+
fail: false
3650
args: >
3751
--config lychee.toml
3852
--user-agent "${{ github.repository }}/lychee"
@@ -42,12 +56,11 @@ jobs:
4256
'./**/*.tex'
4357
'./**/*.yml'
4458
'./**/*.yaml'
45-
lycheeVersion: latest # OBS: Always use latest lychee release
4659
env:
4760
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4861

4962
- name: 3) Comment on PR if links broken
50-
if: failure() && github.event_name == 'pull_request'
63+
if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'pull_request' && env.REPORT_FAILURES == 'true'
5164
uses: actions/github-script@v8
5265
with:
5366
script: |
@@ -65,30 +78,40 @@ jobs:
6578
body: comment,
6679
});
6780
68-
- name: 4) Create issue for scheduled failures # WHY: Track broken links found during scheduled checks
81+
- name: 4) Create issue for scheduled failures
82+
# WHY: Track broken links found during scheduled checks
6983
# OBS: Only creates issue if none already open with 'broken-links' label
70-
if: failure() && github.event_name == 'schedule'
84+
if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'schedule' && env.REPORT_FAILURES == 'true'
7185
uses: actions/github-script@v8
7286
with:
7387
script: |
88+
const owner = context.repo.owner;
89+
const repo = context.repo.repo;
7490
const date = new Date().toISOString().split("T")[0];
7591
const title = `Link Check Failed - ${date}`;
7692
const runUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`;
7793
const body = `Monthly link check found broken links.\n\nWorkflow logs: ${runUrl}`;
7894
7995
const existing = await github.rest.issues.listForRepo({
80-
owner: context.repo.owner,
81-
repo: context.repo.repo,
96+
owner,
97+
repo,
8298
labels: "broken-links",
8399
state: "open",
100+
per_page: 1,
84101
});
85102
86103
if (existing.data.length === 0) {
87104
await github.rest.issues.create({
88-
owner: context.repo.owner,
89-
repo: context.repo.repo,
105+
owner,
106+
repo,
90107
title,
91108
body,
92109
labels: ["maintenance", "broken-links"],
93110
});
94111
}
112+
113+
- name: 5) Fail job if broken links were found
114+
if: steps.lychee.outputs.exit_code != 0
115+
run: |
116+
echo "Lychee found broken links (exit_code != 0). Failing workflow."
117+
exit 1

0 commit comments

Comments
 (0)