-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (118 loc) · 4.55 KB
/
ci.yaml
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
name: Run Python Tests
on:
push
env:
PYTHONPATH: gw_spaceheat:$PYTHONPATH
PYTHON_VERSION: 3.11.9
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install gwcert
run: |
pipx install gridworks-cert
gwcert --version
- name: Generate CA
run: |
echo Creating CA
gwcert ca create --ca-dir ${{ github.workspace }}/tests/.ci-ca ci-test-ca
echo "\nCA info:"
gwcert ca info --ca-dir ${{ github.workspace }}/tests/.ci-ca
echo "\nAdding mosquitto key:"
gwcert key add --ca-dir ${{ github.workspace }}/tests/.ci-ca --certs-dir ${{ github.workspace }}/tests/.ci-ca/certs --dns localhost mosquitto
echo "\nCA info:"
gwcert ca info --ca-dir ${{ github.workspace }}/tests/.ci-ca
sudo chmod a+r ${{ github.workspace }}/tests/.ci-ca/certs/mosquitto/private/mosquitto.pem
ls -lR ${{ github.workspace }}/tests/.ci-ca
- name: Start 'Local' Mosquitto
uses: namoshek/[email protected]
with:
ports: '18831:18831'
config: ${{ github.workspace }}/tests/config/local_mosquitto.conf
container-name: 'local-mqtt'
- name: Start 'GridWorks' Mosquitto
uses: namoshek/[email protected]
with:
ports: '1883:1883 8883:8883'
config: ${{ github.workspace }}/tests/config/gw_mosquitto.conf
certificates: ${{ github.workspace }}/tests/.ci-ca
container-name: 'gw-mqtt'
- name: Wait for 'GridWorks' Mosquitto
uses: iFaxity/[email protected]
with:
resource: tcp:localhost:1883
timeout: 5000
- name: Try Mosquitto Clients on 'GridWorks' Mosquitto Broker
run: |
gwcert key add --ca-dir ${{ github.workspace }}/tests/.ci-ca --certs-dir ${{ github.workspace }}/tests/.ci-ca/certs ci
sudo apt-get install mosquitto-clients
echo pub clear
mosquitto_pub -h localhost -p 1883 -t foo -m '{"bla":1}'
echo sub clear
mosquitto_sub -h localhost -p 1883 -t foo -E
echo pub TLS
mosquitto_pub -h localhost -p 8883 -t foo \
--cafile ${{ github.workspace }}/tests/.ci-ca/ca.crt \
--cert ${{ github.workspace }}/tests/.ci-ca/certs/ci/ci.crt \
--key ${{ github.workspace }}/tests/.ci-ca/certs/ci/private/ci.pem \
-m '{"bar":1}'
echo sub TLS
mosquitto_sub -h localhost -p 8883 -t foo \
--cafile ${{ github.workspace }}/tests/.ci-ca/ca.crt \
--cert ${{ github.workspace }}/tests/.ci-ca/certs/ci/ci.crt \
--key ${{ github.workspace }}/tests/.ci-ca/certs/ci/private/ci.pem \
-E
- name: Install Python 3
uses: actions/[email protected]
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r gw_spaceheat/requirements/dev.txt
- name: Copy Test .env
uses: canastro/copy-file-action@master
with:
source: "tests/config/.env-ci"
target: "tests/.env-gw-spaceheat-test"
- name: Run Tests with Pytest under Coverage
env:
GWPROACTOR_TEST_CA_CERT_PATH: ${{ github.workspace }}/tests/.ci-ca/ca.crt
GWPROACTOR_TEST_CA_KEY_PATH: ${{ github.workspace }}/tests/.ci-ca/private/ca_key.pem
run: coverage run -m pytest -s
- name: Upload coverage data
if: always()
uses: "actions/[email protected]"
with:
name: coverage-data
path: ".coverage*"
if-no-files-found: error
include-hidden-files: true
- name: Local Mosquitto Log
if: failure()
run: |
docker logs local-mqtt
- name: GridWorks Mosquitto Log
if: failure()
run: |
docker logs gw-mqtt
coverage_report:
name: Combine & check coverage.
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: python -m pip install --upgrade coverage[toml]
- name: Download coverage data.
uses: "actions/download-artifact@v4"
with:
name: coverage-data
- name: Report and upload
run: |
python -m coverage xml
- name: Upload coverage report
uses: codecov/[email protected]