-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTaskfile.yml
95 lines (85 loc) · 2.64 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
version: "3"
vars:
TEST_BROKER_IMAGE: eclipse-mosquitto:1.6
TEST_BROKER_NAME: wotpy_test_broker
TEST_BROKER_MAPPED_PORT: "{{default 1883 .TEST_BROKER_MAPPED_PORT}}"
VENV_PATH: "{{.ROOT_DIR}}/.venv"
MAIN_IP_ADDRESS:
sh: ip route get 1.2.3.4 | awk '{print $7}'
WOTPY_TESTS_MQTT_BROKER_URL: mqtt://{{.MAIN_IP_ADDRESS}}:{{.TEST_BROKER_MAPPED_PORT}}
env:
WOTPY_TESTS_MQTT_BROKER_URL: "{{.WOTPY_TESTS_MQTT_BROKER_URL}}"
tasks:
clean:
desc: Clean the development and testing resources
cmds:
- cmd: rm -fr {{.VENV_PATH}}
ignore_error: true
- cmd: docker rm -f {{.TEST_BROKER_NAME}}
ignore_error: true
test-broker:
desc: Run the MQTT broker used for testing
cmds:
- >
docker run -d
-p {{.TEST_BROKER_MAPPED_PORT}}:1883
--name {{.TEST_BROKER_NAME}}
{{.TEST_BROKER_IMAGE}}
status:
- docker ps | grep {{.TEST_BROKER_NAME}}
venv:
desc: Create the virtual environment for development
cmds:
- virtualenv --python python3 {{.VENV_PATH}}
- "{{.VENV_PATH}}/bin/pip install -U -e '{{.ROOT_DIR}}[tests]'"
status:
- test -d {{.VENV_PATH}}
docker-tests:
deps:
- test-broker
desc: Run the tests in a Docker container
vars:
PYTEST_ARGS_DEFAULT: -v
PYTHON_TAG: "{{default 3.7 .PYTHON_TAG}}"
PYTEST_ARGS: "{{default .PYTEST_ARGS_DEFAULT .PYTEST_ARGS}}"
env:
PYTHON_TAG: "{{.PYTHON_TAG}}"
PYTEST_ARGS: "{{.PYTEST_ARGS}}"
cmds:
- echo "⚙️ Running tests for Python {{.PYTHON_TAG}}..."
- "{{.ROOT_DIR}}/pytest-docker.sh"
- echo "✅ Tests for Python {{.PYTHON_TAG}} completed successfully"
docker-tests-all:
desc: Run the tests in a Docker container for all Python versions
cmds:
- for: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
task: docker-tests
vars:
PYTHON_TAG: "{{.ITEM}}"
tests:
desc: Run the tests in the local virtualenv
deps:
- venv
dir: "{{.ROOT_DIR}}"
cmds:
- "{{.VENV_PATH}}/bin/pytest -v"
version:
desc: Bump the package version
requires:
vars: [VERSION_PART]
cmds:
- source {{.VENV_PATH}}/bin/activate
- "{{.ROOT_DIR}}/version.sh {{.VERSION_PART}}"
start-devcontainer:
desc: Open a shell in a development container
deps:
- test-broker
vars:
PYTHON_TAG: "{{default 3.8 .PYTHON_TAG}}"
cmds:
- >
docker run --rm -it
-v {{.ROOT_DIR}}:/workspace
-e WOTPY_TESTS_MQTT_BROKER_URL={{.WOTPY_TESTS_MQTT_BROKER_URL}}
python:{{.PYTHON_TAG}}
/bin/bash -c "cd /workspace && pip install -U -e .[tests] && bash"