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