-
Notifications
You must be signed in to change notification settings - Fork 1
112 lines (98 loc) · 3.73 KB
/
test.yaml
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
name: Run Tests
on:
push:
branches: [ main, develop ]
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
types: [ opened, synchronize ]
workflow_dispatch:
jobs:
test:
runs-on: self-hosted
strategy:
matrix:
service: ['user-verification-service', 'voting-app', 'voting-ledger-follower-app']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check if there were changes for the service
id: metadata
run: |
echo "SERVICE_CHANGED=false" | tee -a "$GITHUB_OUTPUT"
case "${GITHUB_EVENT_NAME}" in
pull_request)
if git log --pretty=format:'%h' -n 1 backend-services/${{ matrix.service }} | grep -q ${{ github.sha }}
then
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
fi
;;
push) # main and develop branches should always trigger the job
BRANCH_NAME=${GITHUB_REF#refs/heads/}
if [[ "${BRANCH_NAME}" == "main" ]] \
|| [[ "${BRANCH_NAME}" == "develop" ]]
then
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
else
if git log --pretty=format:'%h' -n 1 backend-services/${{ matrix.service }} | grep -q ${{ github.sha }}
then
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
fi
fi
;;
*) # ie workflow_dispatch
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
;;
esac
- name: Setup JDK 21
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'corretto'
cache: gradle
- name: Run tests
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
working-directory: ./backend-services/${{ matrix.service }}
run: ./gradlew test
- name: Generate JaCoCo Badge
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
badges-directory: ./backend-services/${{ matrix.service }}/build/reports/jacoco/test/html/badges
jacoco-csv-file: ./backend-services/${{ matrix.service }}/build/reports/jacoco/test/jacocoTestReport.csv
- name: Log coverage percentage
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Publish coverage report to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
if: github.ref == 'refs/heads/main'
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
folder: ./backend-services/${{ matrix.service }}/build/reports/jacoco/test/html
target-folder: ${{ matrix.service }}/coverage-report/
pytest:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.12.2
uses: actions/setup-python@v2
with:
python-version: 3.12.2
- name: Install libsodium
run: sudo apt-get install -y libsodium23
- name: Install dependencies
working-directory: ./backend-services/keri-ballot-verifier
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
- name: Run tests
working-directory: ./backend-services/keri-ballot-verifier
run: |
pytest tests/