-
Notifications
You must be signed in to change notification settings - Fork 14
133 lines (114 loc) · 3.85 KB
/
badges.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Generate badges
on:
push:
branches: [ main ]
jobs:
create-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Git
run: |
git config --global user.name 'Groupings Project'
git config --global user.email '[email protected]'
- name: Create the badges branch if it doesn't exist
run: |
branch_name="badges"
if ! git ls-remote --exit-code origin refs/heads/$branch_name; then
echo "Branch $branch_name does not exist. Creating it..."
git checkout --orphan $branch_name
git rm -rf .
git commit --allow-empty -m "Create $branch_name branch"
git push -u origin $branch_name
else
echo "Branch $branch_name already exists."
fi
generate-jest-badges:
needs: create-branch
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Installing dependencies
run: |
cd ui
npm install
- name: Tests
run: |
cd ui
npm run test:coverage
- name: Switch to badges branch
run: |
git fetch
git switch badges
- name: Generating coverage badges
uses: jpb06/jest-badges-action@latest
with:
branches: '*'
coverage-summary-path: ui/coverage/coverage-summary.json
no-commit: true
target-branch: badges
- name: Commit and push badges
run: |
cd badges
if [[ `git status --porcelain *.svg` ]]; then
git config --global user.name 'Groupings Project'
git config --global user.email '[email protected]'
git add *.svg
git commit -m "Autogenerated Jest badges" *.svg
git push origin badges -f
fi
# Re-enable once UH Groupings API is added to this repo
# generate-jacoco-badges:
# needs: create-branch
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Set up JDK 17
# uses: actions/setup-java@v1
# with:
# java-version: 17
# - name: Build with Maven and Generate JaCoCo Report
# run: |
# mvn clean test jacoco:report -f api/pom.xml -D'logging.level.edu.hawaii.its.holiday=OFF' -D'logging.level.org.springframework=ERROR' -D'spring.main.banner-mode=off'
# mv api/target/ target/
# - name: Switch to badges branch
# run: |
# git fetch
# git switch badges
# - name: Generate Jacoco Badge
# id: jacoco
# uses: cicirello/jacoco-badge-generator@v2
# with:
# coverage-label: junit coverage
# badges-directory: badges
# generate-branches-badge: true
# - name: Log coverage percentage
# run: |
# echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
# - name: Commit and push
# if: ${{ github.event_name != 'pull_request' }}
# run: |
# cd badges
# if [[ `git status --porcelain *.svg` ]]; then
# git config --global user.name 'Groupings Project'
# git config --global user.email '[email protected]'
# git add *.svg
# git commit -m "Autogenerated JaCoCo coverage badge" *.svg
# git push origin badges -f
# fi
# - name: Upload Jacoco coverage report
# uses: actions/upload-artifact@v2
# with:
# name: jacoco-report
# path: target/site/jacoco/