-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from jamescurtin/add-test-and-lint
Add test and lint framework
- Loading branch information
Showing
53 changed files
with
15,515 additions
and
8,464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#! /usr/bin/env bash | ||
set -euo pipefail | ||
|
||
RUFF_MODE='' | ||
RUFF_FLAGS='' | ||
|
||
usage() { | ||
cat << EOF >&2 | ||
Usage: $0 [OPTIONS] | ||
Options: | ||
--ci Run in CI mode: run all tests, lints, and formatting. | ||
Fail if changes are required | ||
-f, --format Format the code | ||
-F, --format-check Run the formatter and fail if changes would be made | ||
-h, --help Show this message and exit | ||
EOF | ||
} | ||
|
||
process_args() { | ||
while test $# -gt 0 | ||
do | ||
case "$1" in | ||
--ci) IS_CI='true' | ||
;; | ||
--format | -f) RUFF_MODE='format' | ||
;; | ||
--format-check | -F) RUFF_MODE='format' | ||
RUFF_FLAGS='--check' | ||
;; | ||
--help | -h) usage; | ||
exit 0 | ||
;; | ||
*) usage; | ||
exit 1; | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
process_args "$@" | ||
|
||
if [ -z ${IS_CI+x} ]; then | ||
eval "ruff ${RUFF_MODE} /home/app/web ${RUFF_FLAGS}" | ||
else | ||
ruff format /home/app/web --check | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! /usr/bin/env bash | ||
set -euo pipefail | ||
|
||
UPGRADE_DEPS='' | ||
|
||
usage() { | ||
cat << EOF >&2 | ||
Usage: $0 [OPTIONS] | ||
Options: | ||
-u, --upgrade Upgrade all dependencies to the latest version | ||
DEFAULT: Without setting this flag, only new dependencies are added | ||
-h, --help Show this message and exit | ||
EOF | ||
} | ||
|
||
process_args() { | ||
while test $# -gt 0 | ||
do | ||
case "$1" in | ||
--upgrade | -u) UPGRADE_DEPS='--upgrade' | ||
;; | ||
--help | -h) usage; | ||
exit 0 | ||
;; | ||
*) usage; | ||
exit 1; | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
process_args "$@" | ||
|
||
docker compose up -d | ||
|
||
eval "docker exec django pip-compile ./requirements.in ${UPGRADE_DEPS}" | ||
eval "docker exec django pip-compile ./requirements-test.in ${UPGRADE_DEPS}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Test | ||
on: | ||
push: | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: ./.github/scripts/prepare-ci.sh | ||
- run: docker compose run --rm test --ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
{ | ||
"editor.defaultFormatter": "charliermarsh.ruff", | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": true, | ||
"files.insertFinalNewline": true, | ||
"files.trimFinalNewlines": true, | ||
"files.trimTrailingWhitespace": true, | ||
"python.linting.pylintEnabled": false, | ||
"python.linting.banditEnabled": true, | ||
"python.linting.enabled": true | ||
} | ||
"python.linting.enabled": true, | ||
"ruff.enable": true, | ||
"ruff.codeAction.fixViolation": { | ||
"enable": true | ||
}, | ||
"ruff.lint.enable": true, | ||
"ruff.lint.run": "onType", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.