- pre-work
- start slack-app in debug mode
- tests
- codespaces (TBA)
- gitpod (TBA)
While not strictly needed, it is a good idea to create a virtual environment to run and develop slack-app. See the Python documentation for more details on Creating a virtual environments.
It is possible to use pyenv and pyenv-virtualenv to easily create&manage different Python versions and virtual environments.
See the pyenv documentation and the pyenv-virtualenv documentation for more details about the installation.
# update pyenv
cd $(pyenv root) && git pull && cd -
# pyenv-virtualenv
cd $(pyenv root)/plugins/pyenv-virtualenv && git pull && cd -
# install liblzma
sudo apt update && \
sudo apt install liblzma-dev
# find the latest 3.13.x version available in pyenv
export PY_VERSION=$(pyenv install -l | grep "^\s*3.13" | tail -n 1 | awk '{print $1}') && \
echo $PY_VERSION
# install the latest 3.13.x release
pyenv install $PY_VERSION
# create a virtual environment
pyenv virtualenv $PY_VERSION slack-app-venvSee the Python documentation for more details on Activating a virtual environment.
If using pyenv and pyenv-virtualenv run
pyenv activate slack-app-venvpip install -r requirements-dev.txtpre-commit, black, pylint and flake8 are included in requirements-dev.txt.
- make sure
pre-commitis installedpre-commit --version
- install
pre-committo set up the git hook scriptspre-commit install
See also the pre-commit tips section in miscellanea.md.
Export the environment variables
source ~/.secrets/ENV_VARSRun app.py in debug mode
export SLACK_BOT_DEBUG=true && \
export PYTHONPATH=.; \
export SLACK_BOT_TOKEN; export SLACK_APP_TOKEN; python slackapp/app.pyTo switch off debug mode unset the env variable
unset SLACK_BOT_DEBUG && \
export PYTHONPATH=.; \
export SLACK_BOT_TOKEN; export SLACK_APP_TOKEN; python slackapp/app.pyGH Actions is configured to run pytest on push to the main branch and on PRs opened against the main branch.
It is possible to run tests with docker, or manually like in this example
(slack-app-venv) (...):~/github/slack-app$ pytest
========================= test session starts =========================
platform linux -- Python 3.13.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /home/user/github/slack-app
collected 1 item
tests/test_dummy.py . [100%]
========================== 1 passed in 0.01s ==========================
(slack-app-venv) (...):~/github/slack-app$
Note that outside a virtual environment it will be needed to add PYTHONPATH explicitly
export PYTHONPATH=. ; pytestdocker build --target test -t slack-app-test .
docker run --rm slack-app-testRun the test container interactively
docker run -it --rm slack-app-test bashdocker build --target dev -t slack-app-dev .
docker run \
--env-file ~/.secrets/ENV_VARS \
-it \
--rm \
slack-app-devIf you wish to export the log files
docker build --target deploy -t slack-app .
mkdir -p ./logs
docker run \
--env-file ~/.secrets/ENV_VARS \
-it \
--rm \
--mount type=bind,source="$(pwd)"/logs,target=/var/log/slack-app \
slack-app