-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjustfile
72 lines (55 loc) · 2.01 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
FRR_LATEST_MAJOR_VERSION := "10.1.0"
default: check-lockfile lint type-check test
# Check if the lockfile is up to date
check-lockfile:
uv lock --locked
# Lint code and check formatting
lint +dirs="src tests": lint-justfile
uv run ruff check {{ dirs }}
uv run ruff format --check {{ dirs }}
lint-justfile:
just --check --fmt --unstable
# Validate static types using mypy
type-check +dirs="src":
uv run mypy {{ dirs }}
# Run tests using pytest
test $COV=env("CI", "false") $FRR_VERSION=FRR_LATEST_MAJOR_VERSION:
#!/usr/bin/env bash
set -euxo pipefail
args=()
( $COV == "true" ) && args+=( "--cov" )
uv run pytest tests ${args[@]}
if [ $COV = "true" ]; then
uv run coverage xml
fi
# Build sdist and wheel
build:
#!/usr/bin/env bash
set -euxo pipefail
# Validate version in pyproject.toml matches that of the git tag if running in CI
if [ ! -z ${CI+x} ]; then
PROJECT_VERSION="$(grep -Po '(?<=^version = ").*(?=")' pyproject.toml)"
GIT_TAG="$(git describe --exact-match --tags)"
if [ ! $PROJECT_VERSION == ${GIT_TAG:1} ]; then
echo Project version $PROJECT_VERSION does not match git tag $GIT_TAG
exit 1
fi
fi
uv build
# Bump our version
bump-version $VERSION: (_validate_semver VERSION)
#!/usr/bin/env bash
set -euxo pipefail
test -z "$(git status --porcelain)" || (echo "The working directory is not clean"; exit 1)
sed -i 's/^version = .*/version = "'$VERSION'"/g' pyproject.toml
uv lock --offline
git add pyproject.toml *.lock
git commit -m "Bump version to v{{ VERSION }}"
# Validate a version against SemVer
_validate_semver version:
#!/usr/bin/env bash
set -euxo pipefail
if [[ ! "{{ version }}" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
echo Invalid SemVer {{ version }}
exit 1
fi