| 
1 |  | -name: 'Lint Code'  | 
 | 1 | +---  | 
 | 2 | +name: 'CI Pipeline'  | 
2 | 3 | 
 
  | 
3 |  | -on:  | 
 | 4 | +'on':  | 
4 | 5 |   push:  | 
5 | 6 |     branches: [master, main]  | 
6 | 7 |   pull_request:  | 
7 | 8 |     branches: [master, main]  | 
8 | 9 | 
 
  | 
 | 10 | +env:  | 
 | 11 | +  CI: true  | 
 | 12 | +  NODE_VERSION: '20'  | 
 | 13 | +  PYTHON_VERSION: '3.12'  | 
 | 14 | + | 
9 | 15 | jobs:  | 
10 | 16 |   lint_python:  | 
11 | 17 |     name: Lint Python Files  | 
12 | 18 |     runs-on: ubuntu-latest  | 
13 | 19 | 
 
  | 
14 | 20 |     steps:  | 
 | 21 | +      - name: Checkout Repository  | 
 | 22 | +        uses: actions/checkout@v4  | 
 | 23 | + | 
 | 24 | +      - name: Set up Python  | 
 | 25 | +        uses: actions/setup-python@v5  | 
 | 26 | +        with:  | 
 | 27 | +          python-version: ${{ env.PYTHON_VERSION }}  | 
 | 28 | +          cache: 'pip'  | 
 | 29 | +          cache-dependency-path: server/requirements.txt  | 
 | 30 | + | 
 | 31 | +      - name: Install dependencies  | 
 | 32 | +        run: |  | 
 | 33 | +          python -m pip install --upgrade pip  | 
 | 34 | +          pip install flake8  | 
15 | 35 | 
  | 
16 |  | -    - name: Checkout Repository  | 
17 |  | -      uses: actions/checkout@v3  | 
18 |  | -      | 
19 |  | -    - name: Set up Python  | 
20 |  | -      uses: actions/setup-python@v4  | 
21 |  | -      with:  | 
22 |  | -        python-version: 3.12  | 
23 |  | - | 
24 |  | -    - name: Install dependencies  | 
25 |  | -      run: |  | 
26 |  | -        python -m pip install --upgrade pip  | 
27 |  | -        pip install flake8  | 
28 |  | -
  | 
29 |  | -    - name: Print working directory  | 
30 |  | -      run: pwd  | 
31 |  | - | 
32 |  | -    - name: Run Linter  | 
33 |  | -      run: |  | 
34 |  | -        pwd  | 
35 |  | -        # This command finds all Python files recursively and runs flake8 on them  | 
36 |  | -        find . -name "*.py" -exec flake8 {} +  | 
37 |  | -        echo "Linted all the python files successfully"  | 
 | 36 | +      - name: Print working directory  | 
 | 37 | +        run: pwd  | 
 | 38 | + | 
 | 39 | +      - name: Run Linter  | 
 | 40 | +        run: |  | 
 | 41 | +          pwd  | 
 | 42 | +          # Find all Python files recursively and run flake8 on them  | 
 | 43 | +          find . -name "*.py" -exec flake8 {} +  | 
 | 44 | +          echo "Linted all the python files successfully"  | 
38 | 45 | 
  | 
39 | 46 |   lint_js:  | 
40 |  | -      name: Lint JavaScript Files  | 
41 |  | -      runs-on: ubuntu-latest  | 
 | 47 | +    name: Lint JavaScript Files  | 
 | 48 | +    runs-on: ubuntu-latest  | 
42 | 49 | 
 
  | 
43 |  | -      steps:  | 
 | 50 | +    steps:  | 
44 | 51 |       - name: Checkout Repository  | 
45 |  | -        uses: actions/checkout@v3  | 
 | 52 | +        uses: actions/checkout@v4  | 
46 | 53 | 
 
  | 
47 | 54 |       - name: Install Node.js  | 
48 |  | -        uses: actions/setup-node@v3  | 
 | 55 | +        uses: actions/setup-node@v4  | 
49 | 56 |         with:  | 
50 |  | -          node-version: 14  | 
 | 57 | +          node-version: ${{ env.NODE_VERSION }}  | 
51 | 58 | 
 
  | 
52 | 59 |       - name: Install JSHint  | 
53 | 60 |         run: npm install jshint --global  | 
54 | 61 | 
 
  | 
55 | 62 |       - name: Run Linter  | 
56 | 63 |         run: |  | 
57 |  | -          # This command finds all JavaScript files recursively and runs JSHint on them  | 
58 |  | -          find ./server/database -name "*.js" -not -path "*/node_modules/*" -exec jshint {} +  | 
 | 64 | +          # Find all JavaScript files and run JSHint on them  | 
 | 65 | +          find ./server/database -name "*.js" -exec jshint {} +  | 
59 | 66 |           echo "Linted all the js files successfully"  | 
 | 67 | +
  | 
 | 68 | +  build_frontend:  | 
 | 69 | +    name: Build and Test Frontend  | 
 | 70 | +    runs-on: ubuntu-latest  | 
 | 71 | + | 
 | 72 | +    steps:  | 
 | 73 | +      - name: Checkout Repository  | 
 | 74 | +        uses: actions/checkout@v4  | 
 | 75 | + | 
 | 76 | +      - name: Setup Node.js  | 
 | 77 | +        uses: actions/setup-node@v4  | 
 | 78 | +        with:  | 
 | 79 | +          node-version: ${{ env.NODE_VERSION }}  | 
 | 80 | +          cache: 'npm'  | 
 | 81 | +          cache-dependency-path: server/frontend/package-lock.json  | 
 | 82 | + | 
 | 83 | +      - name: Install dependencies  | 
 | 84 | +        working-directory: ./server/frontend  | 
 | 85 | +        run: npm ci  | 
 | 86 | + | 
 | 87 | +      - name: Run tests  | 
 | 88 | +        working-directory: ./server/frontend  | 
 | 89 | +        run: npm test -- --watchAll=false --passWithNoTests  | 
 | 90 | +        # TODO: Remove continue-on-error once tests are implemented  | 
 | 91 | +        continue-on-error: true  | 
 | 92 | + | 
 | 93 | +      - name: Build application  | 
 | 94 | +        working-directory: ./server/frontend  | 
 | 95 | +        run: npm run build  | 
 | 96 | + | 
 | 97 | +  build_database:  | 
 | 98 | +    name: Build and Test Database Service  | 
 | 99 | +    runs-on: ubuntu-latest  | 
 | 100 | + | 
 | 101 | +    steps:  | 
 | 102 | +      - name: Checkout Repository  | 
 | 103 | +        uses: actions/checkout@v4  | 
 | 104 | + | 
 | 105 | +      - name: Setup Node.js  | 
 | 106 | +        uses: actions/setup-node@v4  | 
 | 107 | +        with:  | 
 | 108 | +          node-version: ${{ env.NODE_VERSION }}  | 
 | 109 | +          cache: 'npm'  | 
 | 110 | +          cache-dependency-path: server/database/package-lock.json  | 
 | 111 | + | 
 | 112 | +      - name: Install dependencies  | 
 | 113 | +        working-directory: ./server/database  | 
 | 114 | +        run: npm ci  | 
 | 115 | + | 
 | 116 | +      - name: Run tests (if available)  | 
 | 117 | +        working-directory: ./server/database  | 
 | 118 | +        run: npm test || echo "No tests specified yet"  | 
 | 119 | + | 
 | 120 | +  test_python:  | 
 | 121 | +    name: Test Python Django App  | 
 | 122 | +    runs-on: ubuntu-latest  | 
 | 123 | + | 
 | 124 | +    steps:  | 
 | 125 | +      - name: Checkout Repository  | 
 | 126 | +        uses: actions/checkout@v4  | 
 | 127 | + | 
 | 128 | +      - name: Set up Python  | 
 | 129 | +        uses: actions/setup-python@v5  | 
 | 130 | +        with:  | 
 | 131 | +          python-version: ${{ env.PYTHON_VERSION }}  | 
 | 132 | +          cache: 'pip'  | 
 | 133 | +          cache-dependency-path: server/requirements.txt  | 
 | 134 | + | 
 | 135 | +      - name: Install dependencies  | 
 | 136 | +        working-directory: ./server  | 
 | 137 | +        run: |  | 
 | 138 | +          python -m pip install --upgrade pip  | 
 | 139 | +          pip install -r requirements.txt  | 
 | 140 | +
  | 
 | 141 | +      - name: Run Django tests  | 
 | 142 | +        working-directory: ./server  | 
 | 143 | +        run: python manage.py test  | 
 | 144 | +        # TODO: Remove continue-on-error once tests are implemented  | 
 | 145 | +        continue-on-error: true  | 
0 commit comments