-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
177 lines (155 loc) · 5.81 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
---
version: '3'
dotenv:
- task.env
vars:
GIT_ROOT:
sh: git rev-parse --show-toplevel
includes:
test: ./.taskfiles/test.yaml
tasks:
arduino-lint:
desc: Lint using arduino-lint
cmds:
- arduino-lint
attach:
desc: Export board and port to sketch.json file
cmds:
- jq -n --arg board {{ .BOARD }} --arg port {{ .PROTOCOL }}://{{ .PORT}} '{"cpu":{"fqbn":$board,"port":$port}}' > sketch.json
deps:
- task: _varcheck
bootstrap:
desc: Bootstrap the entire environment. ⚠️ WARNING! This overwrites the exiting arduino-cli config file!
cmds:
- arduino-cli config init --overwrite
- task: core-install
- task: lib-install
- task: attach
compile:
desc: Compile the main sketch
cmds:
- arduino-cli compile .
compile-upload:
desc: Compile and upload main sketch
cmds:
- task: compile
- task: upload
- task: console
console:
desc: Monitor the console with screen
cmds:
- screen {{ .PORT }} $BAUD_RATE
core-install:
desc: Install core
cmds:
- >
arduino-cli config add board_manager.additional_urls
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
- arduino-cli core update-index
- arduino-cli core install {{ .CORES }}
deploy:
desc: Deploy gh-pages using mkdocs
cmds:
- mkdocs gh-deploy --force
silent: true
get-fingerprint:
desc: Get the SHA-1 fingerprint of ThingSpeak's website
cmds:
- >
openssl s_client -connect api.thingspeak.com:443 < /dev/null 2>/dev/null |
openssl x509 -fingerprint -noout -in /dev/stdin | cut -d"=" -f2
lib-install:
desc: Install arduino-cli libraries
cmds:
- 'arduino-cli lib install {{ .LIBS }}'
lint:
desc: Lint the files
cmds:
- yamllint .
- arduino-lint --compliance specification --project-type all
pre-commit:
desc: Install pre-commit hooks
cmds:
- "pre-commit install"
- "pre-commit install-hooks"
preconditions:
- sh: type pre-commit
msg: "pre-commit is not installed."
silent: true
secrets:
desc: Export parameters to secrets.h ⚠️ WARNING! This task overwrites secrets.h
cmds:
- test ! -z "{{.SSID}}" || (echo "Please define SSID parameter"; exit 1)
- test ! -z "{{.PASS}}" || (echo "Please define PASS parameter"; exit 1)
- test ! -z "{{.CH_ID}}" || (echo "Please define CH_ID parameter"; exit 1)
- test ! -z "{{.WRITE_APIKEY}}" || (echo "Please define WRITE_APIKEY parameter"; exit 1)
- test ! -z "{{.USER_APIKEY}}" || (echo "Please define USER_APIKEY parameter"; exit 1)
- test ! -z "{{.PROJECT_ID}}" || (echo "Please define PROJECT_ID parameter"; exit 1)
- test ! -z "{{.CLIENT_EMAIL}}" || (echo "Please define CLIENT_EMAIL parameter"; exit 1)
- test ! -z "{{.SPREADSHEET_ID}}" || (echo "Please define SPREADSHEET_ID parameter"; exit 1)
- test ! -z "{{.PRIVATE_KEY}}" || (echo "Please define PRIVATE_KEY parameter"; exit 1)
- echo "#define SECRET_SSID \"{{ .SSID }}\"" > secrets.h
- echo "#define SECRET_PASS \"{{ .PASS }}\"" >> secrets.h
- echo "#define SECRET_CH_ID {{ .CH_ID }}" >> secrets.h
- echo "#define SECRET_WRITE_APIKEY \"{{ .WRITE_APIKEY }}\"" >> secrets.h
- echo "#define SECRET_HOSTNAME \"{{ .HOSTNAME }}\"" >> secrets.h
- echo "#define SECRET_USER_APIKEY \"{{ .USER_APIKEY }}\"" >> secrets.h
- echo "#define PROJECT_ID \"{{ .PROJECT_ID }}\"" >> secrets.h
- echo "#define CLIENT_EMAIL \"{{ .CLIENT_EMAIL }}\"" >> secrets.h
- echo "#define SPREADSHEET_ID \"{{ .SPREADSHEET_ID }}\"" >> secrets.h
- echo "#define PRIVATE_KEY \"{{ .PRIVATE_KEY }}\"" >> secrets.h
vars:
HOSTNAME: Feather
# FINGERPRINT:
# sh: >
# openssl s_client -connect api.thingspeak.com:443 < /dev/null 2>/dev/null |
# openssl x509 -fingerprint -noout -in /dev/stdin | cut -d"=" -f2
silent: true
serve:
desc: Run the builtin mkdocs development server.
cmds:
- mkdocs serve
silient: true
switch:
desc: Switch between the ESP8266 and ESP32 boards in the sketch.json file.
cmds:
- >
TEMP2=$(cat {{ .GIT_ROOT }}/sketch.json | jq -r '.cpu.fqbn');
if [[ "$TEMP2" == "esp32:esp32:featheresp32" ]]; then
jq -n --arg board "esp8266:esp8266:huzzah" --arg port {{ .PROTOCOL }}://{{ .PORT}} \
'{"cpu":{"fqbn":$board,"port":$port}}' > sketch.json
else
jq -n --arg board "esp32:esp32:featheresp32" --arg port {{ .PROTOCOL }}://{{ .PORT}} \
'{"cpu":{"fqbn":$board,"port":$port}}' > sketch.json
fi
silent: true
upload:
desc: Upload the main sketch
cmds:
- arduino-cli upload .
vars:
desc: Print all the variables
cmds:
- "printf 'task: Available variables for this project:\n'"
- 'printf "{{ .COLOR }}* BAUD_RATE\e[m %s\n" "{{ .BAUD_RATE }}"'
- 'printf "{{ .COLOR }}* BOARD\e[m %s\n" "{{ .BOARD }}"'
- 'printf "{{ .COLOR }}* CORES\e[m %s\n" "{{ .CORES }}"'
- 'printf "{{ .COLOR }}* LIBS\e[m %s\n" "{{ .LIBS }}"'
- 'printf "{{ .COLOR }}* PORT\e[m %s\n" "{{ .PORT }}"'
- 'printf "{{ .COLOR }}* PROTOCOL\e[m %s\n" "{{ .PROTOCOL }}"'
vars:
# Blue
COLOR: '\e[1;34m'
PORT:
sh: cat {{ .GIT_ROOT }}/sketch.json | jq -r '.cpu.port' | sed s/"serial:\/\/"//
silent: true
_varcheck:
cmds:
- test ! -z "{{.BOARD}}" || (echo "Please define BOARD parameter"; exit 1)
- test ! -z "{{.PORT}}" || (echo "Please define PORT parameter"; exit 1)
- test ! -z "{{.PROTOCOL}}" || (echo "Please define PROTOCOL parameter"; exit 1)
silent: true
default:
cmds:
- task -l
silent: true