Skip to content

Commit 59c365b

Browse files
committed
Tools
1 parent 7387487 commit 59c365b

18 files changed

+389
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "uv"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/check.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Check and Test Python Project
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["main"]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
check:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v6
24+
with:
25+
persist-credentials: false
26+
fetch-depth: 1 # 0 if you want to push to repo
27+
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v7
30+
with:
31+
enable-cache: true
32+
33+
- name: Python set up
34+
uses: actions/setup-python@v6
35+
with:
36+
python-version-file: ".python-version"
37+
38+
- name: Run pytest unittests
39+
run: |
40+
scripts/copy_test_data.sh
41+
cp .streamlit/secrets-EXAMPLE.toml .streamlit/secrets.toml
42+
uv run --frozen pytest tests/ --cov --cov-report=xml:coverage.xml
43+
44+
- name: Run pre-commit hooks
45+
uses: pre-commit/[email protected]
46+
47+
# for SonarQube coverage report
48+
# - name: SonarQube Scan
49+
# uses: SonarSource/sonarqube-scan-action@v7
50+
# env:
51+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
52+
53+
# - name: Minimize uv cache
54+
# run: uv cache prune --ci

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# python
2+
__pycache__/
3+
.coverage
4+
.DS_Store
5+
.venv/
6+
.pytest_cache/
7+
coverage_report/
8+
9+
# project dirs
10+
cache/
11+
cacheReal/
12+
data/
13+
dataReal/
14+
15+
# files
16+
download.sh
17+
requirements-all.txt
18+
requirements.txt
19+
secrets.toml
20+
src/reports/r99_playground.py

.pre-commit-config.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# install package
2+
# uv add -dev pre-commit
3+
# register as git commit-hook to run automatically
4+
# uv run pre-commit install
5+
# run manually
6+
# uv run pre-commit run --all-files
7+
# update hooks to latest version
8+
# uv run pre-commit autoupdate
9+
10+
default_language_version:
11+
python: python3.11
12+
13+
exclude: |
14+
(?x)^(
15+
\.vscode/.*|
16+
tests/testdata/.*|
17+
src/strava-resources/.*
18+
)$
19+
20+
repos:
21+
- repo: https://github.com/pre-commit/pre-commit-hooks
22+
rev: v6.0.0
23+
hooks:
24+
- id: check-added-large-files
25+
args: ["--maxkb=500"]
26+
- id: check-ast
27+
- id: check-builtin-literals
28+
- id: check-case-conflict
29+
- id: check-docstring-first
30+
- id: check-executables-have-shebangs
31+
# - id: check-illegal-windows-names
32+
- id: check-json
33+
- id: check-merge-conflict
34+
- id: check-shebang-scripts-are-executable
35+
- id: check-symlinks
36+
- id: check-toml
37+
- id: check-vcs-permalinks
38+
- id: check-xml
39+
- id: check-yaml
40+
- id: debug-statements
41+
- id: destroyed-symlinks
42+
# - id: detect-aws-credentials
43+
- id: detect-private-key
44+
# conflict with black below
45+
# - id: double-quote-string-fixer
46+
- id: end-of-file-fixer
47+
# - id: file-contents-sorter
48+
# files: ^(deploy-whitelist.txt|\.gitignore|\.dockerignore)$
49+
- id: fix-byte-order-marker
50+
- id: forbid-new-submodules
51+
# - id: forbid-submodules
52+
- id: mixed-line-ending
53+
args: ["--fix=lf"]
54+
- id: name-tests-test
55+
args: ["--pytest-test-first"]
56+
# - id: no-commit-to-branch
57+
# args: [--branch, staging]
58+
- id: pretty-format-json
59+
args: ["--autofix", "--no-ensure-ascii", "--no-sort-keys"]
60+
- id: requirements-txt-fixer
61+
# - id: sort-simple-yaml
62+
# files: ^config/simple/
63+
- id: trailing-whitespace
64+
65+
# ruff
66+
- repo: https://github.com/astral-sh/ruff-pre-commit
67+
rev: v0.14.14
68+
hooks:
69+
- id: ruff-check
70+
args: [--fix, --exit-non-zero-on-fix]
71+
- id: ruff-format
72+
73+
# security
74+
- repo: https://github.com/gitleaks/gitleaks
75+
rev: v8.30.0
76+
hooks:
77+
- id: gitleaks
78+
79+
# markdown
80+
- repo: https://github.com/igorshubovych/markdownlint-cli
81+
rev: v0.47.0
82+
hooks:
83+
- id: markdownlint
84+
args: ["--disable", "MD013"]
85+
86+
# code spell check via cspell
87+
- repo: https://github.com/streetsidesoftware/cspell-cli
88+
rev: v9.4.0
89+
hooks:
90+
- id: cspell

.sonarcloud.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sonar.organization=entorb
2+
sonar.projectKey=entorb_strava-streamlit
3+
sonar.python.version=3.11

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"python.analysis.extraPaths": [
3+
"${workspaceFolder}/src"
4+
],
5+
"python.testing.pytestEnabled": true,
6+
"python.testing.unittestEnabled": false,
7+
"python.testing.cwd": "${workspaceFolder}/tests",
8+
"python.testing.autoTestDiscoverOnSaveEnabled": true,
9+
"sonarlint.connectedMode.project": {
10+
"connectionId": "entorb",
11+
"projectKey": "entorb_strava-streamlit"
12+
}
13+
}

cspell.config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json
3+
version: "0.2"
4+
useGitignore: true
5+
language: en-US
6+
dictionaryDefinitions:
7+
- name: cspell-words
8+
path: "./cspell-words.txt"
9+
addWords: true
10+
dictionaries:
11+
- cspell-words
12+
ignorePaths:
13+
- ".*"
14+
- "cspell.config.yaml"
15+
- "dist"
16+
- "build"

ruff.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
fix = true # auto-fix findings
2+
line-length = 88 # same as Black
3+
target-version = "py311" # Python 3.11
4+
5+
# extend-exclude = ["src/MyBadFile1.py"]
6+
7+
8+
[lint]
9+
# comment this out to use only default rules (["E4", "E7", "E9", "F"])
10+
select = ["ALL"] # activate all rules
11+
fixable = ["ALL"] # fix for all enabled rules
12+
13+
# add some more rules to include
14+
# extend-select = ["B", "Q", "E", "W"]
15+
16+
# rule not to apply
17+
extend-ignore = [
18+
"COM812", # missing-trailing-comma,
19+
"D200", # fits-on-one-line"
20+
"D203", # incorrect-blank-line-before-class
21+
"D211", # blank-line-before-class
22+
"D212", # multi-line-summary-second-line
23+
"ERA", # commented-out code
24+
"FIX002", # line-contains-todo
25+
"ISC001", # implicit-str-concat
26+
"PGH003", # blanket-type-ignore
27+
"RET504", # unnecessary-assign
28+
"T201", # print
29+
"TD002", # missing-todo-author
30+
"TD003", # missing-todo-link
31+
"S101", # use of asserts
32+
]
33+
34+
35+
[format]
36+
line-ending = "lf" # force lf
37+
preview = false # enable unstable preview style formatting

scripts/config_convert.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Read config.toml, modify and export as config-prod.toml.""" # noqa: INP001
2+
3+
import tomllib
4+
from pathlib import Path
5+
6+
import tomli_w # pip install tomli-w
7+
8+
p_in = Path(__file__).parent.parent / ".streamlit/config.toml"
9+
p_out = p_in.parent / "config-prod.toml"
10+
11+
with p_in.open("rb") as fh:
12+
o = tomllib.load(fh)
13+
14+
o["server"]["fileWatcherType"] = "none"
15+
o["server"]["baseUrlPath"] = "/strava-streamlit"
16+
del o["server"]["address"]
17+
18+
with p_out.open("wb") as fh:
19+
tomli_w.dump(o, fh)

0 commit comments

Comments
 (0)