Skip to content

Commit 01c07d5

Browse files
author
CalorieApp Maintainer
committed
chore: repo hardening — add CodeQL, pre-commit docs, pip-tools; finalize structure and docs
1 parent 0638953 commit 01c07d5

167 files changed

Lines changed: 21976 additions & 5723 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4
10+
11+
[*.kv]
12+
indent_size = 4
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build-test:
19+
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-latest, windows-latest]
25+
python-version: ["3.11", "3.12"]
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
cache: 'pip'
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install -r requirements.txt
41+
42+
- name: Lint (flake8)
43+
run: |
44+
python -m flake8 src tests
45+
46+
- name: Format check (black)
47+
run: |
48+
python -m black --check src tests
49+
50+
- name: Run tests (pytest)
51+
run: |
52+
python -m pytest -q --disable-warnings --maxfail=1 --cov=src --cov-report=xml --cov-report=term-missing
53+
54+
- name: Upload coverage to Codecov (public repos only)
55+
uses: codecov/codecov-action@v4
56+
with:
57+
files: coverage.xml
58+
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
59+
fail_ci_if_error: true
60+
continue-on-error: true
61+
62+
- name: Upload coverage report
63+
if: always()
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: coverage-${{ matrix.python-version }}
67+
path: ./coverage.xml
68+
if-no-files-found: ignore
69+
70+
summary:
71+
name: CI Summary
72+
runs-on: ubuntu-latest
73+
needs: build-test
74+
if: always()
75+
steps:
76+
- name: Generate summary
77+
run: |
78+
echo "All matrix jobs finished: ${{ needs.build-test.result }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/codeql.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 7 * * 1' # Every Monday at 07:00 UTC
10+
11+
permissions:
12+
contents: read
13+
security-events: write
14+
15+
jobs:
16+
analyze:
17+
name: Analyze (Python)
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 60
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ 'python' ]
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Initialize CodeQL
31+
uses: github/codeql-action/init@v3
32+
with:
33+
languages: ${{ matrix.language }}
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: '3.12'
39+
40+
- name: Install dependencies (optional)
41+
run: |
42+
python -m pip install --upgrade pip
43+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
44+
45+
- name: Autobuild
46+
uses: github/codeql-action/autobuild@v3
47+
48+
- name: Perform CodeQL Analysis
49+
uses: github/codeql-action/analyze@v3
50+
with:
51+
category: '/language:${{ matrix.language }}'

.github/workflows/kv-sanity.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: KV Sanity Check
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/core/kv/**/*.kv'
7+
- 'scripts/kv_sanity_check.py'
8+
- 'requirements.txt'
9+
pull_request:
10+
paths:
11+
- 'src/core/kv/**/*.kv'
12+
- 'scripts/kv_sanity_check.py'
13+
- 'requirements.txt'
14+
15+
jobs:
16+
kv-check-windows:
17+
runs-on: windows-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -r requirements.txt
31+
32+
- name: Run KV sanity check
33+
run: |
34+
python -u scripts/kv_sanity_check.py

.github/workflows/lint.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
lint:
10+
name: Lint (flake8, black --check, isort --check)
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest]
15+
python-version: ['3.12']
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install tools
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install flake8 black isort
30+
31+
- name: Black check
32+
run: |
33+
python -m black --check .
34+
35+
- name: Isort check
36+
run: |
37+
python -m isort --check-only .
38+
39+
- name: Flake8
40+
run: |
41+
python -m flake8 src tests

.github/workflows/ux_tour.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: UX Tour Tests
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
ux-tour:
12+
runs-on: windows-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements.txt
26+
27+
- name: Run UX Tour
28+
run: python scripts/ux_tour.py
29+
env:
30+
OFFLINE_MODE: '0'
31+
32+
- name: Upload test report
33+
if: always()
34+
uses: actions/upload-artifact@v3
35+
with:
36+
name: ux-tour-report
37+
path: docs/ui_tour/**/test_report.txt
38+
39+
- name: Upload screenshots
40+
if: always()
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: ux-tour-screenshots
44+
path: docs/ui_tour/**/*.png
45+
46+
- name: Check test results
47+
run: |
48+
$report = Get-Content -Path (Get-ChildItem -Path docs/ui_tour -Recurse -Filter test_report.txt | Select-Object -Last 1).FullName -Raw
49+
if ($report -match "Failed: (\d+)") {
50+
$failed = [int]$matches[1]
51+
if ($failed -gt 0) {
52+
Write-Error "UX Tour had $failed failing tests"
53+
exit 1
54+
}
55+
}
56+
Write-Output "All UX Tour tests passed!"

0 commit comments

Comments
 (0)