-
Notifications
You must be signed in to change notification settings - Fork 6
190 lines (164 loc) · 6.95 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: "PR: Test code"
on:
# 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@v4
- name: "Set up VRO build env"
uses: ./.github/actions/setup-vro
- name: "Run quick linters"
run: |
./gradlew spotlessCheck shellcheck lintDockerfile
- name: "Run tests and checks"
# `check` runs all checks, including spectralLint, hadolint, and shellcheck
# NOTE: ./gradlew :svc-bie-kafka:check & ./gradlew :shared:lib-bie-kafka:check are disabled. See: https://github.com/department-of-veterans-affairs/abd-vro/issues/3802
run: |
echo "::group::Gradle check including test"
./gradlew :svc-bip-api:check
./gradlew :domain-xample:xample-shared:check
./gradlew :domain-xample:xample-api-controller:check
./gradlew :domain-xample:svc-xample-j:check
./gradlew :shared:persistence-model:check
./gradlew :shared:lib-rabbitmq-connector:check
./gradlew :shared:lib-metrics: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@v4
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@v45
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@v4
with:
# Need to fetch more than 1 deep to see changes
fetch-depth: 2
- name: "Set up VRO build env"
uses: ./.github/actions/setup-vro
- name: "Python isort"
uses: isort/isort-action@v1
with:
configuration: --profile black
requirementsFiles: "**/requirements.txt \
**/dev-requirements.txt"
- name: "Get changed files"
if: '! inputs.run_all_tests'
id: changed-files-specific
uses: tj-actions/changed-files@v45
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@v45
with:
files: domain-ee/**
# NOTE: The vro-streamlit service is currently disabled because it is not actively used.
# - name: "Get changed vro-streamlit files"
# if: '! inputs.run_all_tests'
# id: vro-streamlit-changed-files-specific
# uses: tj-actions/changed-files@v45
# with:
# files: vro-streamlit/**
- name: "Install Python"
if: inputs.run_all_tests || steps.changed-files-specific.outputs.any_changed == 'true' || steps.ee-changed-files-specific.outputs.any_changed == 'true'
uses: actions/setup-python@v5
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.outputs.any_changed == 'true'
run: |
./gradlew :domain-ee:test
# NOTE: The vro-streamlit service is currently disabled because it is not actively used.
# - name: "Run VRO Streamlit tests"
# if: inputs.run_all_tests || steps.vro-streamlit-changed-files-specific.outputs.any_changed == 'true'
# run: |
# ./gradlew :vro-streamlit:check