Skip to content

Commit d457731

Browse files
committed
chore: project setup with pre-commit settings, .gitignore and renovate config
1 parent b6b5512 commit d457731

8 files changed

Lines changed: 156 additions & 0 deletions

File tree

.envrc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# code: language=shellscript insertSpaces=true tabSize=2
2+
# shellcheck disable=SC2148
3+
4+
dotenv_if_exists
5+
6+
if test -z "${PYTHON_VERSION:-}" && test -f "${PWD}/.python-version"; then
7+
PYTHON_VERSION=$(head -n 1 "${PWD}/.python-version")
8+
fi
9+
10+
if test -z "${PYTHON_VERSION:-}"; then
11+
PYTHON_VERSION=$(semver_search /usr/lib python 3)
12+
fi
13+
14+
if test -z "${PYTHON_VERSION:-}"; then
15+
echo "-> No Python version found. Please create a .python-version file or set PYTHON_VERSION in your environment." >&2
16+
exit 1
17+
fi
18+
19+
export VIRTUAL_ENV="${PWD}/.venv"
20+
layout python "python${PYTHON_VERSION}"
21+
22+
echo '*' > "${PWD}/.venv/.gitignore"
23+
24+
if ! test -f "${PWD}/.venv/.pip-updated"; then
25+
pip install --upgrade pip
26+
touch "${PWD}/.venv/.pip-updated"
27+
fi
28+
29+
if test -z "${PYTHON_NO_INSTALL_REQUIREMENTS:-}"; then
30+
all_req_files=("${PWD}"/requirements*.txt)
31+
if [[ ${#all_req_files[@]} -gt 0 ]]; then
32+
33+
install_needed=0
34+
35+
for req_file in "${all_req_files[@]}"; do
36+
watch_file "$req_file"
37+
38+
venv_file="${PWD}/.venv/.$(basename "$req_file")"
39+
if ! test -f "$venv_file" || test "$venv_file" -ot "$req_file"; then
40+
install_needed=1
41+
fi
42+
done
43+
44+
if [[ "$install_needed" -eq 1 ]]; then
45+
pip_install_args=()
46+
for req_file in "${all_req_files[@]}"; do
47+
pip_install_args+=("-r" "$req_file")
48+
done
49+
50+
if pip install -U "${pip_install_args[@]}"; then
51+
for req_file in "${all_req_files[@]}"; do
52+
venv_file="${PWD}/.venv/.$(basename "$req_file")"
53+
touch "$venv_file"
54+
done
55+
else
56+
echo "-> pip install command failed. Tracking files remain untouched." >&2
57+
exit 1
58+
fi
59+
fi
60+
fi
61+
fi
62+
63+
if test -f "${PWD}/.pre-commit-config.yaml" && ! test -f "${PWD}/.venv/.pre-commit-installed"; then
64+
if test -z "$(pip list 2>/dev/null | grep -oE 'pre[-_]commit')"; then
65+
pip install pre-commit
66+
fi
67+
pre-commit install
68+
touch "${PWD}/.venv/.pre-commit-installed"
69+
fi

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/.env*
2+
!.envrc
3+
**/.venv
4+
**/venv

.markdownlint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
MD013: false

.pre-commit-config.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-added-large-files
7+
- id: fix-byte-order-marker
8+
- id: check-case-conflict
9+
- id: check-json
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
- id: mixed-line-ending
13+
- id: check-merge-conflict
14+
15+
- repo: https://github.com/adrienverge/yamllint.git
16+
rev: v1.29.0
17+
hooks:
18+
- id: yamllint
19+
20+
- repo: https://github.com/hadolint/hadolint
21+
rev: v2.12.0
22+
hooks:
23+
- id: hadolint-docker
24+
files: ^Dockerfile
25+
26+
- repo: https://github.com/DavidAnson/markdownlint-cli2
27+
rev: v0.13.0
28+
hooks:
29+
- id: markdownlint-cli2-docker
30+
31+
- repo: https://github.com/rhysd/actionlint
32+
rev: v1.7.1
33+
hooks:
34+
- id: actionlint-docker
35+
36+
- repo: https://github.com/crate-ci/typos
37+
rev: v1.31.0
38+
hooks:
39+
- id: typos

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

.typos.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# For more information on how to configure typos, see:
2+
# - https://github.com/crate-ci/typos/blob/master/docs/reference.md
3+
# - https://github.com/crate-ci/typos/blob/master/README.md#false-positives
4+
5+
[files]
6+
# By default, typos will not check files that are ignored by git.
7+
# You can override this behavior here.
8+
# For example, to check all files, you would set:
9+
# ignore-vcs = false
10+
extend-exclude = [
11+
"**/.envrc",
12+
]
13+
14+
[default]
15+
# This section contains the default configuration for all file types.
16+
# You can override these settings for specific file types below.
17+
18+
# A list of words that should be considered correct.
19+
# This is useful for words that are specific to your project.
20+
# For example:
21+
# extend-words = {
22+
# "myawesomeword" = "myawesomeword",
23+
# "another" = "another",
24+
# }
25+
26+
# A list of regular expressions that should be ignored.
27+
# This is useful for things like URLs, or other patterns that
28+
# are not words.
29+
# For example, to ignore all URLs:
30+
# extend-ignore-re = [
31+
# "https?://[^`\\s]+",
32+
# ]

.yamllint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
rules:
3+
line-length: disable

renovate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended"
5+
]
6+
}

0 commit comments

Comments
 (0)