Skip to content

Commit

Permalink
feat(Taskfile): improve development flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijas committed Oct 24, 2023
1 parent 41388dc commit ceeea1a
Show file tree
Hide file tree
Showing 3 changed files with 382 additions and 378 deletions.
46 changes: 28 additions & 18 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,36 @@ tasks:
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.
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-checks:
desc: Execute all pre-push checks before pushing code or creating a PR.
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 CI/CD checks for debugging a failing CI/CD pipeline.
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: verify-docs-integrity
- task: update-notebook-outputs

################################################################
### Hidden: Primarily Used within Other Tasks or Used Rarely ###
Expand All @@ -68,11 +74,10 @@ tasks:
- poetry run ruff check sec_ai/
- poetry run mypy

verify-docs-integrity: # Check the integrity of the documentation.
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:
- poetry export --with doc -f requirements.txt --output docs/rtd_requirements.txt
- echo "[Taskfile] Executing notebooks and checking for errors. The output will be saved to the notebook files."
- 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.
Expand All @@ -86,24 +91,29 @@ tasks:
- poetry run cz bump {{.CLI_ARGS}}
- poetry export --with doc -f requirements.txt --output docs/rtd_requirements.txt

update-dependencies:
cmds:
- poetry update
- poetry export --with doc -f requirements.txt --output docs/rtd_requirements.txt

check-and-push:
cmds:
- task: pre-push-checks
- task: pre-push-preparation
- git push

######################################
### Shorthand Tasks for Efficiency ###
######################################
###################################################
### Shorthand Tasks for Efficiency (may change) ###
###################################################

c: # You can just run `task c` instead of `task pre-commit-checks`.
deps:
- pre-commit-checks

p: # You can just run `task p` instead of `task pre-push-checks`.
i: # You can just run `task i` instead of `task ci-checks`.
deps:
- pre-push-checks
- ci-checks

pp: # You can just run `task pp` instead of `task check-and-push`.
ii: # You can just run `task ii` instead of `task check-and-push`.
deps:
- check-and-push

Expand All @@ -119,6 +129,6 @@ tasks:
deps:
- launch-docs

xx: # You can just run `task xx` instead of `task verify-docs-integrity`.
xx: # You can just run `task xx` instead of `task update-notebook-outputs`.
deps:
- verify-docs-integrity
- update-notebook-outputs
Loading

0 comments on commit ceeea1a

Please sign in to comment.