summaryrefslogtreecommitdiffstats
path: root/.circleci/config.yml
blob: 9a276ad2639ba7a7649e900f84acbc854925cc5b (plain)
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# Python CircleCI 2.0 configuration file
# Check https://circleci.com/docs/2.0/language-python/ for more details
version: 2

aliases:
  - &defaults
    docker:
      - image: circleci/python:3.6-buster-node
    working_directory: ~/projects/reel2bits

  - &attach_workspace
      attach_workspace:
        at: ~/projects/

  - &persist_to_workspace
      persist_to_workspace:
        root: ~/projects/
        paths:
          - ./reel2bits/
          - ./audiowaveform/
        
  - &install_system_dependencies
      run:
        name: Install system dependencies
        command: |
          sudo apt-get update
          sudo apt-get install -y sox libtag1v5 libmagic1 libffi6 ffmpeg postgresql-client-11 rsync
          sudo apt-get install -y cmake build-essential git wget make libboost-all-dev rustc
          sudo apt-get install -y libsox-dev libsox-fmt-all libtag1-dev libmagic-dev libffi-dev libgd-dev libmad0-dev libsndfile1-dev libid3tag0-dev libmediainfo-dev

  - &install_audiowaveform
      run:
        name: Install audiowaveform
        command: ./api/tests/install_audiowaveform.sh

  - &install_python_dependencies
      steps:
        - *attach_workspace
        - *install_system_dependencies
        - *install_audiowaveform
        - run: python -V | tee /tmp/.python-version
        - restore_cache:
            keys:
              - v2-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "api/requirements.txt" }}
        - run: python3 -m venv venv
        - run:
            command: |
              . venv/bin/activate
              pip install --requirement api/requirements.txt
              pip install black
              pip install flake8
              touch front/dist/index.html
        - save_cache:
            key: v2-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "api/requirements.txt" }}
            paths:
              - ./venv
        - *persist_to_workspace

  - &install_steps
      steps:
        - checkout
        - *attach_workspace
        - restore_cache:
            keys:
              - v1-node-dependencies-{{ checksum "front/yarn.lock" }}
              - v1-node-dependencies-
        - run:
            command: |
              cd front
              yarn install --frozen-lockfile
        - save_cache:
            key: v1-node-depdencies-{{ checksum "front/yarn.lock" }}
            paths:
              - ./front/node_modules/
        - *persist_to_workspace

  - &test_steps
      steps:
        - *attach_workspace
        - *install_system_dependencies
        - *install_audiowaveform
        - run:
            name: Linters
            command: |
              . venv/bin/activate
              cd api
              black --check .
              flake8 . --count --show-source --statistics
        - run:
            name: Tests
            command: |
              . venv/bin/activate
              cd api
              mkdir test-reports
              export AUTHLIB_INSECURE_TRANSPORT=1
              export APP_SETTINGS="config.testing.Config"
              python setup.py test
        - run:
            name: Full migrations
            command: |
              psql -U postgres -h localhost -w -c 'CREATE DATABASE reel2bits'
              psql -U postgres -h localhost -w -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' reel2bits
              . venv/bin/activate
              cd api
              flask db upgrade
              flask db-datas 000-seeds
              flask db-datas 001-generate-tracks-uuids
              flask db-datas 002-set-local-users
              flask db-datas 003-set-user-quota
              flask db-datas 004-update-file-sizes
              flask db-datas 005-update-user-quotas
        - store_test_results:
            path: api/test-reports
        - store_artifacts:
            path: api/test-reports

  - &lint_steps_front
      steps:
        - *attach_workspace
        - run:
            name: Front lint
            command: |
              cd front
              npm run lint

  - &test_steps_front
      steps:
        - *attach_workspace
        - run:
            name: Front test
            command: |
              firefox --version
              cd front
              npm run unit

  - &build_front
      steps:
        - *attach_workspace
        - run:
            name: Install rsync
            command: |
              sudo apt-get update
              sudo apt-get install -y rsync
        - run:
            name: Front build
            command: |
              cd front
              npm run build
        - persist_to_workspace:
            root: ~/projects/
            paths:
              - ./reel2bits/front/dist

  - &sync_front
      steps:
        - *attach_workspace
        - add_ssh_keys:
            fingerprints:
              - "8b:e8:75:22:8a:21:35:5a:50:1c:da:75:2f:11:6c:2b"
              - "66:7c:0f:97:42:b2:eb:fe:53:3c:0a:db:a5:5c:7a:27"
        - run:
            name: Install rsync
            command: |
              sudo apt-get update
              sudo apt-get install -y rsync
        - deploy:
            name: zip and sync artifacts
            command: |
              cd front
              if [ "${CIRCLE_BRANCH}" = "master" ]; then
                export NAME="front-dist-${CIRCLE_BRANCH}"
                zip -r "${NAME}.zip" dist/
                rsync -avc -e "ssh -o StrictHostKeyChecking=no -p 22" ${NAME}.zip assets.reel2bits.org@cadance.licorn.eu:/
              fi
              if [ ! -z "${CIRCLE_TAG}" ]; then
                export NAME="front-dist-${CIRCLE_TAG}"
                zip -r "${NAME}.zip" dist/
                rsync -avc -e "ssh -o StrictHostKeyChecking=no -p 22" ${NAME}.zip assets.reel2bits.org@cadance.licorn.eu:/
              fi

  - &build_and_sync_doc
      steps:
        - checkout
        - *attach_workspace
        - add_ssh_keys:
            fingerprints:
              - "66:80:b8:db:44:06:34:e1:f0:ac:35:b2:a0:80:98:bd"
        - run:
            name: Install rsync
            command: |
              sudo apt-get update
              sudo apt-get install -y rsync graphviz
        - run:
            name: Install dependencies
            command: |
              python3 -m venv venv
              . venv/bin/activate
              pip install sphinx-guillotina-theme sphinx
        - run:
            name: Build docs
            command: |
              . venv/bin/activate
              cd docs && ./build_docs.sh
        - deploy:
            name: deploy
            command: |
              rsync -avc -e "ssh -o StrictHostKeyChecking=no -p 22" --delete docs-build/ docs-develop.reel2bits.org@cadance.licorn.eu:/
jobs:
  install:
    <<: *defaults
    <<: *install_steps

  install-python3.6:
    <<: *defaults
    <<: *install_python_dependencies

  install-python3.7:
    <<: *defaults
    docker:
      - image: circleci/python:3.7-buster-node
    <<: *install_python_dependencies

  install-python3.8:
    <<: *defaults
    docker:
      - image: circleci/python:3.8-buster-node
    <<: *install_python_dependencies

  install-python3.9:
    <<: *defaults
    docker:
      - image: circleci/python:3.9-rc-buster-node
    <<: *install_python_dependencies

  test-python3.6:
    <<: *defaults
    docker:
      - image: circleci/python:3.6-buster-node
      - image: circleci/postgres:11-alpine
        environment:
          POSTGRES_USER: postgres
          POSTGRES_DB: reel2bits_test
    <<: *test_steps

  test-python3.7:
    <<: *defaults
    docker:
      - image: circleci/python:3.7-buster-node
      - image: circleci/postgres:11-alpine
        environment:
          POSTGRES_USER: postgres
          POSTGRES_DB: reel2bits_test
    <<: *test_steps

  test-python3.8:
    <<: *defaults
    docker:
      - image: circleci/python:3.8-buster-node
      - image: circleci/postgres:11-alpine
        environment:
          POSTGRES_USER: postgres
          POSTGRES_DB: reel2bits_test
    <<: *test_steps

  test-python3.9:
    <<: *defaults
    docker:
      - image: circleci/python:3.9-rc-buster-node
      - image: circleci/postgres:11-alpine
        environment:
          POSTGRES_USER: postgres
          POSTGRES_DB: reel2bits_test
    <<: *test_steps

  front-lint:
    <<: *defaults
    docker:
      - image: circleci/node:12.9.0-buster-browsers
    <<: *lint_steps_front

  front-lint-lts:
    <<: *defaults
    docker:
      - image: circleci/node:10.16.3-buster-browsers
    <<: *lint_steps_front

  front-test-lts:
    <<: *defaults
    docker:
      - image: circleci/node:10.16.3-buster-browsers
    <<: *test_steps_front

  front-build:
    <<: *defaults
    docker:
      - image: circleci/node:10.16.3-buster-browsers
    <<: *build_front

  front-sync:
    <<: *defaults
    docker:
      - image: circleci/node:10.16.3-buster-browsers
    <<: *sync_front

  build-develop-doc:
    <<: *defaults
    docker:
      - image: circleci/python:3.7-buster-node
        environment:
          BUILD_PATH: ../docs-build
    <<: *build_and_sync_doc

workflows:
  version: 2
  build-docs:
    jobs:
      - build-develop-doc:
          filters:
            branches:
              only: master
  build-and-test:
    jobs:
      - install
      - install-python3.6:
          requires:
            - install
      - install-python3.7:
          requires:
            - install
      - install-python3.8:
          requires:
            - install
      - install-python3.9:
          requires:
            - install
      - test-python3.6:
          requires:
            - install-python3.6
      - test-python3.7:
          requires:
            - install-python3.7
      - test-python3.8:
          requires:
            - install-python3.8
      - test-python3.9:
          requires: