summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/ci.yml
blob: 5bdc2eeba213c13f68093955534d30cc28d34fe7 (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
name: CI

on:
  push:
    branches: [development]
    paths:
      - frontend/**
      - bazarr/**
      - libs/**
      - migrations/**
      - bazarr.py
      - requirements.txt
      - dev-requirements.txt
      - .github/workflows/ci.yml
  pull_request:
    branches: [development]

env:
  UI_DIRECTORY: ./frontend
  UI_ARTIFACT_NAME: ui

jobs:
  Frontend:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Cache node_modules
        uses: actions/cache@v3
        with:
          path: "${{ env.UI_DIRECTORY }}/node_modules"
          key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
          restore-keys: ${{ runner.os }}-modules-

      - name: Setup NodeJS
        uses: actions/setup-node@v3
        with:
          node-version: "lts/*"

      - name: Install dependencies
        run: npm install
        working-directory: ${{ env.UI_DIRECTORY }}

      - name: Check Types
        run: npm run check:ts
        working-directory: ${{ env.UI_DIRECTORY }}

      - name: Check Styles
        run: npm run check
        working-directory: ${{ env.UI_DIRECTORY }}

      - name: Check Format
        run: npm run check:fmt
        working-directory: ${{ env.UI_DIRECTORY }}

      - name: Unit Test
        run: npm test
        working-directory: ${{ env.UI_DIRECTORY }}

      - name: Build
        run: npm run build:ci
        working-directory: ${{ env.UI_DIRECTORY }}

      - uses: actions/upload-artifact@v4
        with:
          name: ${{ env.UI_ARTIFACT_NAME }}
          path: "${{ env.UI_DIRECTORY }}/build"

  Backend:
    runs-on: ubuntu-latest
    needs: Frontend

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Python 3.8
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"

      - name: Install UI
        uses: actions/download-artifact@v4
        with:
          name: ${{ env.UI_ARTIFACT_NAME }}
          path: "${{ env.UI_DIRECTORY }}/build"

      - name: Install Python dependencies
        run: pip install -r requirements.txt

      - name: Unit Tests
        run: |
          python3 bazarr.py --no-update &
          PID=$!
          sleep 15
          if kill -s 0 $PID
          then
            echo "**** Bazarr launch successful ****"
            kill $PID
            exit 0
          else
          echo "**** Bazarr launch failed ****"
            exit 1
          fi