summaryrefslogtreecommitdiffstats
path: root/.circleci/config.yml
blob: 77442c95fea739b420c71bf34df3b07b84230bc6 (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
# 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_steps
      steps:
        - checkout
        - *attach_workspace
        # TODO: npm/node/front v2
        - *persist_to_workspace

  - &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
          sudo apt-get install -y cmake build-essential git wget make libboost-all-dev 
          sudo apt-get install -y libsox-dev libsox-fmt-all libtag1-dev libmagic-dev libffi-dev libgd-dev libmad0-dev libsndfile1-dev libid3tag0-dev 

  - &install_audiowaveform
      run:
        name: Install audiowaveform
        command: ./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:
              - v1-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "requirements.txt" }}
              - v1-dependencies-{{ checksum "/tmp/.python-version" }}-
              - v1-dependencies-
        - run: python3 -m venv venv
        - run:
            command: |
              . venv/bin/activate
              pip install --requirement requirements.txt
              pip install black
              pip install flake8
        - save_cache:
            key: v1-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "requirements.txt" }}
            paths:
              - ./venv
        - *persist_to_workspace

  - &test_steps
      steps:
        - *attach_workspace
        - *install_system_dependencies
        - *install_audiowaveform
        - run:
            name: Linters
            command: |
              . venv/bin/activate
              black --check .
              flake8 . --count --show-source --statistics
        - run:
            name: Tests
            command: |
              . venv/bin/activate
              cp tests/config_test.py config.py
              mkdir test-reports
              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
              cp config.py.sample config.py
              flask db upgrade
        - store_test_results:
            path: test-reports
        - store_artifacts:
            path: test-reports

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-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-rc-buster-node
      - image: circleci/postgres:11-alpine
        environment:
          POSTGRES_USER: postgres
          POSTGRES_DB: reel2bits_test
    <<: *test_steps

workflows:
  version: 2
  build-and-test:
    jobs:
      - install
      - install-python3.6:
          requires:
            - install
      - install-python3.7:
          requires:
            - install
            - install-python3.6
      - install-python3.8:
          requires:
            - install
            - install-python3.6
      - test-python3.6:
          requires:
            - install-python3.6
      - test-python3.7:
          requires:
            - install-python3.7
      - test-python3.8:
          requires:
            - install-python3.8