-
Notifications
You must be signed in to change notification settings - Fork 24
/
Taskfile.yml
135 lines (109 loc) · 5.39 KB
/
Taskfile.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
version: '3'
tasks:
######################################################
### Development Tools: Local Application Launchers ###
######################################################
launch-debug-dashboard:
desc: Start a local debugging dashboard in the browser.
cmds:
# Using PYTHONPATH to allow Streamlit to monitor file changes. Learn more: https://docs.streamlit.io/knowledge-base/using-streamlit/streamlit-watch-changes-other-modules-importing-app
- export PYTHONPATH=$PYTHONPATH:$(pwd)/sec_ai ENVIRONMENT=dev && poetry run streamlit run dev_utils/debug_dashboard/app.py --server.runOnSave=true
monitor-unit-tests:
desc: "Run unit tests and rerun them immediately upon file modification."
cmds:
# Recommended coverage viewer in VSCode: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
# Note: also update .codecov.yml when changing the target coverage.
- poetry run ptw -- -- -s --cov --cov-report=lcov:lcov.info --cov-report=term:skip-covered --cov-fail-under=90 {{.CLI_ARGS}} tests/unit/
launch-docs:
desc: Start a local server to preview and automatically rebuild documentation upon file modification.
cmds:
- poetry run sphinx-autobuild docs/source docs/build/html
########################################
### Automated Code Testing Pipelines ###
########################################
pre-commit-checks:
desc: Execute all pre-commit checks before committing code. Run "pre-commit install" to have it run automatically during every commit.
cmds:
- task: unit-tests
- task: lint
pre-push-preparation:
desc: Execute this task before pushing to remote or creating a Pull Request to ensure code quality and consistency.
cmds:
- task: ensure-clean-working-tree
- task: lint
- task: update-dependencies
- task: update-notebook-outputs
- git add -u
- git commit --amend --no-edit
- task: ensure-clean-working-tree
- task: ci-checks
- task: ensure-clean-working-tree
ci-checks:
desc: Execute all checks required for Continuous Integration. Useful for troubleshooting issues in the CI/CD pipeline.
cmds:
- task: unit-tests
- task: lint-without-autofix
- task: update-notebook-outputs
################################################################
### Hidden: Primarily Used within Other Tasks or Used Rarely ###
################################################################
unit-tests: # Execute unit tests and assess code coverage.
cmds:
# Recommended coverage viewer in VSCode: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
# Note: also update .codecov.yml when changing the target coverage.
- poetry run pytest -s --cov --cov-report=lcov:lcov.info --cov-report=term:skip-covered --cov-fail-under=90 {{.CLI_ARGS}} tests/unit/
lint: # Perform linting on the code and automatically fix issues.
cmds:
- poetry run ruff check --fix sec_ai/
- poetry run mypy
lint-without-autofix: # Perform linting on the code without auto-fixing issues.
cmds:
- poetry run ruff check sec_ai/
- poetry run mypy
update-notebook-outputs: # Run and verify all Jupyter notebooks in the documentation source folder, and refresh their output cells to ensure they execute without errors.
silent: true
cmds:
- echo "[Taskfile] Running and verifying Jupyter notebooks in the documentation source folder to ensure they execute without errors, while refreshing their output cells."
- for file in $(find {{.ROOT_DIR}}/docs/source/notebooks -name "*.ipynb"); do echo -n "Processing file \"$file\"... "; poetry run exec_nb --exc_stop $file --dest $file && echo "done!" || { echo "Processing failed for file \"$file\""; exit 1; }; done
ensure-clean-working-tree: # Ensure no changes in the working tree or index, abort if any.
silent: true
internal: true
cmds:
- if git diff --exit-code > /dev/null 2>&1 && git diff --cached --exit-code > /dev/null 2>&1; then :; else echo "Changes detected in the working tree or index. Please commit or stash them before proceeding."; exit 1; fi
version-bump: # Increment the version number.
cmds:
- poetry run cz bump {{.CLI_ARGS}}
update-dependencies:
cmds:
- poetry update
- poetry export --with doc -f requirements.txt --output docs/rtd_requirements.txt
check-and-push:
cmds:
- task: ensure-clean-working-tree
- git pull --no-edit
- task: pre-push-preparation
- git push
###################################################
### Shorthand Tasks for Efficiency (may change) ###
###################################################
c: # You can just run `task c` instead of `task pre-commit-checks`.
deps:
- pre-commit-checks
i: # You can just run `task i` instead of `task ci-checks`.
deps:
- ci-checks
ii: # You can just run `task ii` instead of `task check-and-push`.
deps:
- check-and-push
d: # You can just run `task d` instead of `task launch-debug-dashboard`.
deps:
- launch-debug-dashboard
m: # You can just run `task m` instead of `task monitor-unit-tests`.
deps:
- monitor-unit-tests
x: # You can just run `task x` instead of `task launch-docs`.
deps:
- launch-docs
xx: # You can just run `task xx` instead of `task update-notebook-outputs`.
deps:
- update-notebook-outputs