-
Notifications
You must be signed in to change notification settings - Fork 6
170 lines (146 loc) · 5.75 KB
/
test-code.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: "PR: Test code"
on:
# Trigger on all pull requests
pull_request:
branches:
- "*"
# Trigger when called by another GitHub Action
workflow_call:
inputs:
run_all_tests:
required: false
type: boolean
default: true
# Allow manual triggering
workflow_dispatch:
jobs:
test-java:
runs-on: ubuntu-latest
steps:
- name: "Checkout source code"
uses: actions/checkout@v3
- name: "Set up VRO build env"
uses: ./.github/actions/setup-vro
- name: "Run quick linters"
run: |
./gradlew spotlessCheck shellcheck lintDockerfile
- name: "Python isort"
uses: isort/isort-action@v1
with:
requirementsFiles: "**/requirements.txt \
**/dev-requirements.txt"
- name: "Run tests and checks"
# `check` runs all checks, including spectralLint, hadolint, and shellcheck
run: |
echo "::group::Gradle test check"
./gradlew test check
echo "::endgroup::"
echo "::group::Gradle test check - mocks"
./gradlew -p mocks test check
echo "::endgroup::"
- name: "Check for adequate test coverage"
run: |
./gradlew jacocoLogTestCoverage jacocoTestCoverageVerification
- name: "Publish Test Results as PR comment and GH Check Run"
# Known issue: Associates results to random workflow
# https://github.com/EnricoMi/publish-unit-test-result-action/issues/12
uses: EnricoMi/publish-unit-test-result-action@v2
# Skip if Dependabot created the PR due to check-runs permission error
# https://github.com/EnricoMi/publish-unit-test-result-action#support-fork-repositories-and-dependabot-branches
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events
if: always() && github.actor != 'dependabot[bot]'
with:
files: |
**/build/test-results/*/*.xml
- name: "Aggregate JaCoCo reports"
# `jacocoAggregatedReport` reports aggregated coverage of all the subprojects
# excluding integrationTest and end2endTest (which are run elsewhere)
run: |
./gradlew jacocoAggregatedReport
- name: "Report JaCoCo Coverage as a GH Check Run"
# This takes about 1 minute, so don't run on PRs
# if: github.event_name != 'pull_request'
id: jacoco_reporter
uses: PavanMudigonda/[email protected]
# Skip if Dependabot created the PR due to check-runs permission error
if: github.actor != 'dependabot[bot]'
with:
coverage_results_path: build/reports/jacoco/jacocoAggregatedReport/jacocoAggregatedReport.xml
coverage_report_name: Coverage
coverage_report_title: JaCoCo
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_check_run: false
minimum_coverage: 80
fail_below_threshold: false
publish_only_summary: false
- name: "Add JaCoCo Coverage Report as PR comment"
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
uses: madrapps/[email protected]
with:
paths: ${{ github.workspace }}/build/reports/jacoco/jacocoAggregatedReport/jacocoAggregatedReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
title: "JaCoCo Test Coverage"
test-ruby:
runs-on: ubuntu-latest
steps:
- name: "Checkout source code"
uses: actions/checkout@v3
with:
# Need to fetch more than 1 deep to see changes
fetch-depth: 2
- name: "Get changed Ruby files"
id: changed-files-specific
if: '! inputs.run_all_tests'
uses: tj-actions/changed-files@v35
with:
files: svc-bgs-api/**
- name: "Set up Ruby"
if: inputs.run_all_tests || steps.changed-files-specific.outputs.any_changed == 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
# Used to resolve .ruby-version, .tool-versions and Gemfile.lock
working-directory: svc-bgs-api/src
- name: "Run rspec tests"
if: inputs.run_all_tests || steps.changed-files-specific.outputs.any_changed == 'true'
env:
# https://github.com/rails/spring
DISABLE_SPRING: true
run: |
cd svc-bgs-api/src
bundle exec rspec --format documentation
test-python:
runs-on: ubuntu-latest
steps:
- name: "Checkout source code"
uses: actions/checkout@v3
with:
# Need to fetch more than 1 deep to see changes
fetch-depth: 2
- name: "Get changed files"
if: '! inputs.run_all_tests'
id: changed-files-specific
uses: tj-actions/changed-files@v35
with:
files: domain-cc/**
- name: "Get changed domain-ee files"
if: '! inputs.run_all_tests'
id: ee-changed-files-specific
uses: tj-actions/changed-files@v35
with:
files: domain-ee/**
- name: "Install Python"
if: inputs.run_all_tests || steps.changed-files-specific.outputs.any_changed == 'true' || steps.ee-changed-files-specific.any_changed == 'true'
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- name: "Run contention classification tests"
if: inputs.run_all_tests || steps.changed-files-specific.outputs.any_changed == 'true'
run: |
./gradlew :domain-cc:test
- name: "Run Employee Experience tests"
if: inputs.run_all_tests || steps.ee-changed-files-specific.any_changed == 'true'
run: |
./gradlew :domain-ee:test