summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build-and-test.yml
blob: 4be09d56eb242250477c13416c7f228b35c05ada (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
name: Test builds

on: push

jobs:
  frontend:
    name: Test build frontend
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node: [12.x, 14.x, 15.x]

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Uses Node.JS ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - name: Cache Node.js modules
        uses: actions/cache@v2
        with:
          # npm cache files are stored in `~/.npm` on Linux/macOS
          path: ~/.npm
          key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.OS }}-node-
            ${{ runner.OS }}-

      - name: Install dependencies
        run: |
          yarn install --frozen-lockfile
          sudo apt update
          sudo apt install -y firefox
        working-directory: front

      - name: Lint code
        run: npm run lint
        working-directory: front

      # might need firefox...
      - name: Test front
        run: npm run unit
        working-directory: front

  backend:
    name: Test build backend
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python: [3.6, 3.7, 3.8, 3.9]
    
    services:
      postgres:
        image: postgres:12
        env:
          POSTGRES_DB: reel2bits_test
          POSTGRES_USER: postgres
          POSTGRES_HOST_AUTH_METHOD: trust
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Uses Python ${{ matrix.python }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}
      - name: Cache pip
        uses: actions/cache@v2
        with:
          # This path is specific to Ubuntu
          path: ~/.cache/pip
          # Look to see if there is a cache hit for the corresponding requirements file
          key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
            ${{ runner.os }}-

      - name: Install system dependencies
        run: |
          sudo add-apt-repository -y ppa:chris-needham/ppa
          sudo apt update
          sudo apt install -y sox libtag1v5 libmagic1 libffi7 ffmpeg postgresql-client-12 rsync
          sudo apt install -y cmake build-essential git wget make libboost-all-dev rustc cargo
          sudo apt install -y libsox-dev libsox-fmt-all libtag1-dev libmagic-dev libffi-dev libgd-dev libmad0-dev libsndfile1-dev libid3tag0-dev libmediainfo-dev audiowaveform

      - name: Install python dependencies
        run: |
          pip install --requirement api/requirements.txt
          pip install black
          pip install flake8
          touch front/dist/index.html

      - name: Lint code
        run: |
          black --check .
          flake8 . --count --show-source --statistics
        working-directory: api
      
      - name: Test backend
        run: python setup.py test
        working-directory: api
        env:
          AUTHLIB_INSECURE_TRANSPORT: 1
          APP_SETTINGS: "config.testing.Config"

      - name: Test full migrations
        run: |
          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
          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
        working-directory: api