-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTaskfile.yml
More file actions
201 lines (178 loc) · 5.76 KB
/
Taskfile.yml
File metadata and controls
201 lines (178 loc) · 5.76 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# https://taskfile.dev
version: '3'
vars:
APP_FOLDER: "app"
TEST_FOLDER: "tests"
FEATURES_FOLDER: "features"
PORT_LOCAL_SERVER: 8888
CURRENT_E2E_TEST: "@CURRENT"
tasks:
build:
aliases:
- default
cmds:
- task: rollup:build
- task: minify-widget
rollup:build:
deps: [npm:install]
sources:
- "{{.APP_FOLDER}}/data/**/*.md"
- "{{.APP_FOLDER}}/index.md"
- "{{.APP_FOLDER}}/css/**/*.css"
- "{{.APP_FOLDER}}/js/**/*.mjs"
- "{{.APP_FOLDER}}/js/**/*.js"
- "{{.APP_FOLDER}}/index.html"
- "{{.APP_FOLDER}}/DEBUG" # On vérifie si ce fichier a changé (parce qu'on a lancé une nouvelle version pour le DEBUG), afin de pouvoir relancer le build pour la version PROD
- rollup.config.mjs
generates:
- "{{.APP_FOLDER}}/css/styles.min.css"
- "{{.APP_FOLDER}}/script.min.js"
- "{{.APP_FOLDER}}/script.min.js.map"
method: timestamp
cmds:
- cmd: npx rollup --config
- cmd: | # On supprime le fichier DEBUG si on build en version PROD
if [ -e "{{.APP_FOLDER}}/DEBUG" ]; then
rm "{{.APP_FOLDER}}/DEBUG"
fi
silent: true
npm:install:
sources:
- package.json
- package-lock.json
generates:
- node_modules/.package-lock.json
cmds:
- npm install
debug:
deps: [npm:install]
sources:
cmds:
- cmd: npx rollup --config --environment DEBUG
- cmd: touch "{{.APP_FOLDER}}/DEBUG" # On ajoute un fichier DEBUG pour indiquer qu'on n'est pas en mode prod (warning pour ne pas push le build de l'application)
silent: true
minify-widget:
sources:
- widget/widget.js
- widget/widget.min.js
generates:
- widget/widget.min.js
cmds:
- npx rollup widget/widget.js --file widget/widget.min.js --format iife --compact -p @rollup/plugin-terser
init-repo:
cmds:
- git remote add chatmd git@forge.apps.education.fr:chatMD/chatMD.forge.apps.education.fr.git
- git remote add apps git@forge.apps.education.fr:eyssette/chatMD.git
- git remote add drane git@forge.apps.education.fr:drane-lyon/chatmd.git
- git remote add github git@github.com:eyssette/chatMD.git
- git remote add gitlab git@gitlab.com:chatmd/chatmd.gitlab.io.git
- git remote add frama git@framagit.org:chatmd/chatmd.frama.io.git
push:
vars:
GIT_REPO_NAMES: [apps, drane, chatmd, github, gitlab, frama]
preconditions:
- test ! -f app/DEBUG
cmds:
- task: lint
- task: tests
- for: { var: GIT_REPO_NAMES }
cmd: git push {{.ITEM}} && git push {{.ITEM}} --tags
tag:
desc: "Crée un tag avec pour date du tag la date du commit (usage: task tag -- <commit> <tag>)"
cmds:
- |
bash -c '
set -- "{{.CLI_ARGS}}"
COMMIT=$1
TAG=$2
if [ -z "$COMMIT" ] || [ -z "$TAG" ]; then
echo "❌ Usage: task tag -- <commit> <tag>"
exit 1
fi
TAG_DATE=$(git show -s --format=%aD "$COMMIT")
echo "📌 Création du tag \"$TAG\" sur le commit $COMMIT (date: $TAG_DATE)"
GIT_COMMITTER_DATE="$TAG_DATE" git tag -a "$TAG" "$COMMIT" -m ""
'
silent: false
tests:
cmds:
- task: ecma
- task: tests:unit
- task: tests:e2e
tests:e2e:
aliases:
- tests:codeceptjs
sources:
- "{{.APP_FOLDER}}/data/**/*.md"
- "{{.APP_FOLDER}}/index.md"
- "{{.APP_FOLDER}}/css/**/*.css"
- "{{.APP_FOLDER}}/js/**/*.mjs"
- "{{.APP_FOLDER}}/js/**/*.js"
- "{{.APP_FOLDER}}/index.html"
- "{{.TEST_FOLDER}}/e2e/**/*.js"
- "{{.TEST_FOLDER}}/e2e/.config/generateStepsDefinitionsFromFeatures.js"
- "{{.TEST_FOLDER}}/e2e/step_definitions/**/*.js"
- "{{.FEATURES_FOLDER}}/**/*.feature"
cmds:
# On vérifie avant qu'il n'y ait pas le terme "@CURRENT" dans les fichiers tests e2e
- cmd: |
bash -c '
set -e
if grep -R --line-number --exclude-dir=node_modules "{{.CURRENT_E2E_TEST}}" tests/e2e features; then
echo "❌ {{.CURRENT_E2E_TEST}} trouvé dans les tests e2e — supprimez-le avant de lancer les tests."
exit 1
fi
'
silent: true
- task: server:start
- defer: {task: server:stop}
- npx codeceptjs run --steps --grep '(?=.*)^(?!.*@WIP)'
tests:e2e:current:
cmds:
- task: server:start
- defer: {task: server:stop}
- npx codeceptjs run --steps --grep '(?=.*)^(?!.*@WIP)(?=.*{{.CURRENT_E2E_TEST}})'
tests:unit:
aliases:
- tests:jasmine
sources:
- "{{.APP_FOLDER}}/js/**/*.mjs"
- "{{.TEST_FOLDER}}/unit/**/*.mjs"
cmds:
- npx jasmine --config='tests/unit/.config/jasmine.mjs'
tests:createSteps:
sources:
- tests/e2e/.config/generateStepsDefinitionsFromFeatures.js
- features/**/*.feature
- tests/e2e/step_definitions/**/*.js
cmds:
- node tests/e2e/.config/generateStepsDefinitionsFromFeatures.js
tests:widget:
cmds:
- node tests/test_widget.mjs
bump:
generates:
- VERSION
- package.json
- package-lock.json
cmds:
- task: lint
- task: tests
- cz bump
server:start:
cmds:
- node --env-file=.env server.js {{.PORT_LOCAL_SERVER}} & # On lance le serveur en arrière-plan
- until nc -z localhost {{.PORT_LOCAL_SERVER}}; do sleep 1; done # On attend que le port soit ouvert avant de lancer la suite
server:stop:
cmds:
- kill $(lsof -ti :{{.PORT_LOCAL_SERVER}}) 2>/dev/null || true
ecma:
sources:
- "{{.APP_FOLDER}}/js/**/*.mjs"
cmds:
- npx es-check es2018 "{{.APP_FOLDER}}/js/**/*.mjs" --module
lint:
sources:
- "{{.APP_FOLDER}}/js/**/*.mjs"
cmds:
- npx eslint "app/**/*.mjs"