-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (101 loc) · 4.78 KB
/
ci.yml
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
name: Test suite
on:
push:
jobs:
backend-test:
name: Test Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Backend Tests
run: sudo docker-compose --env-file .env-github-actions run server bash -c "coverage run manage.py test"
- name: Generate Backend Coverage Report (Inline)
run: sudo docker-compose --env-file .env-github-actions run server bash -c "coverage report --show-missing"
# Generate coverage badge (only for main and develop branches)
- name: Generate Backend Coverage Report (XML) and Badge
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
run: |
sudo docker-compose --env-file .env-github-actions run server bash -c "coverage xml"
sudo docker-compose --env-file .env-github-actions run server bash -c "genbadge coverage -i coverage.xml -o coverage-backend-badge-new.svg -n \"Backend Code Coverage\""
# Push coverage badge to separate branch (only for main and develop branches)
- name: Push Backend Coverage Badge to separate branch
continue-on-error: true
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
run: |
if git ls-remote --heads origin code-coverage-badges; then
git fetch origin code-coverage-badges
git checkout code-coverage-badges
else
git checkout -b code-coverage-badges
git push origin code-coverage-badges
fi
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
rm backend/coverage-backend-badge.svg -f
mv backend/coverage-backend-badge-new.svg backend/coverage-backend-badge.svg
git add backend/coverage-backend-badge.svg
git commit -m "Add backend coverage badge for commit $GITHUB_SHA"
git push origin code-coverage-badges
# Check if there are any changes
if git diff --staged --quiet; then
echo "No changes in coverage badge. Skipping commit and push."
else
git commit -m "Add backend coverage badge for commit $GITHUB_SHA"
git push origin code-coverage-badges
fi
backend-lint:
name: Lint Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint Backend
continue-on-error: false
run: sudo docker-compose --env-file .env-github-actions run server bash -c "flake8"
frontend-test:
name: Test Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Frontend Tests
run: sudo docker-compose --env-file .env-github-actions run client yarn test:ci
frontend-coverage-badge:
name: Generate Frontend Coverage Badge
needs: frontend-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v3
- name: Generate Frontend Coverage Report (XML) and Badge
run: |
sudo docker-compose --env-file .env-github-actions run client yarn test:ci --coverageDirectory=public/coverage
sudo docker-compose --env-file .env-github-actions run client yarn coverage-badges -s public/coverage/coverage-summary.json -o public/coverage/coverage-frontend-badge-new.svg --label 'Frontend Code Coverage'
- name: Push Frontend Coverage Badge to separate branch
continue-on-error: true
run: |
if git ls-remote --heads origin code-coverage-badges; then
git fetch origin code-coverage-badges
git checkout code-coverage-badges
else
git checkout -b code-coverage-badges
git push origin code-coverage-badges
fi
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
rm frontend/coverage-frontend-badge.svg -f
sudo mv frontend/public/coverage/coverage-frontend-badge-new.svg frontend/coverage-frontend-badge.svg
git add frontend/coverage-frontend-badge.svg
git commit -m "Add frontend coverage badge for commit $GITHUB_SHA"
git push origin code-coverage-badges
# Check if there are any changes
if git diff --staged --quiet; then
echo "No changes in coverage badge. Skipping commit and push."
else
git commit -m "Add frontend coverage badge for commit $GITHUB_SHA"
git push origin code-coverage-badges
fi
frontend-lint:
name: Lint Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo docker-compose --env-file .env-github-actions run client yarn lint