Repository navigation
164 lines (160 loc) · 6.38 KB
/
Copy pathbuild.yml
File metadata and controls
164 lines (160 loc) · 6.38 KB
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
---
name: Build And Test CWMS Data API
on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
build:
strategy:
fail-fast: false
matrix:
jdk: [17]
# place holder for now and leaving commented but in place. General scheme target tests again the current
# release, the next release, the previous release, and latest development. Next-release will be the current
# release until the next version is started. This is to make the required builds integration easier to deal with.
schema:
- env: latest
image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:latest-dev"
- env: release
image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:26.07.16"
- env: next-release
image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:26.07.16"
- env: previous
image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:26.02.17"
name: build and test (jdk ${{matrix.jdk}}, schema ${{matrix.schema.env}})
runs-on: ubuntu-latest
outputs:
thewar: ${{steps.thebuild.outputs.WARFILE}}
steps:
- name: Clean up disk space, so we don't run out.
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
- name: checkout code
uses: actions/checkout@v5.0.0
- name: setup java
uses: actions/setup-java@v5.2.0
with:
distribution: 'temurin'
java-version: ${{matrix.jdk}}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0
with:
gradle-version: wrapper
- name: build and test
id: thebuild
run: ./gradlew clean build --info --init-script init.gradle
- name: integration tests
run: ./gradlew integrationtest --info --init-script init.gradle -PCDA.oracle.database.image=${{matrix.schema.image}}
- name: Create matrix job badge
if: success() || failure() # always run even if the previous step fails
uses: ./.github/actions/badge
with:
label: 'Build'
status: ${{ job.status == 'success' && 'Pass' || 'Fail' }}
file: ${{ matrix.jdk }}/${{ matrix.schema.env }}.svg
run_id: ${{ github.run_id }}
- name: Install xmllint
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
- name: coverage
id: coverage
run: |
# combine the test and integration test reports.
./gradlew codeCoverageReport --info --init-script init.gradle -PCDA.oracle.database.image=${{matrix.schema.image}}
# calculate coverage percentage
MISSED_LINES=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@missed)" cwms-data-api/build/reports/jacoco-composite.xml`
COVERED_LINES=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@covered)" cwms-data-api/build/reports/jacoco-composite.xml`
PERCENT=`echo "scale=1; (${COVERED_LINES} / (${COVERED_LINES} + ${MISSED_LINES})) * 100" | bc`
echo "Coverage from missed $MISSED_LINES and covered $COVERED_LINES is $PRECENT"
echo "coverage=$PERCENT %" >> $GITHUB_OUTPUT
- name: Create matrix coverage badge
if: success() || failure() # always run even if the previous step fails
uses: ./.github/actions/badge
with:
label: 'Coverage'
status: ${{ steps.coverage.outputs.coverage }}
file: ${{ matrix.jdk }}/${{ matrix.schema.env }}-coverage.svg
run_id: ${{ github.run_id }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v6.4.1
if: always()
with:
annotate_only: true
include_passed: true
report_paths: '**/TEST-*.xml'
detailed_summary: true
open-api-static-analysis:
name: OpenApi Static Analysis Tests
runs-on: ubuntu-latest
env:
OPEN_API_TEST: "true"
steps:
- name: checkout code
uses: actions/checkout@v5.0.0
- name: setup java
uses: actions/setup-java@v5.2.0
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: build and test
id: thebuild
run: ./gradlew clean :cwms-data-api:test --tests "cwms.cda.api.OpenApiDocTest" --info --init-script init.gradle
- name: Publish Test Report
uses: mikepenz/action-junit-report@v6.4.1
if: always()
with:
annotate_only: true
include_passed: true
report_paths: '**/TEST-*.xml'
detailed_summary: true
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v5.0.0
- name: Build docker image
run: docker build -t cda:build-latest .
build-schema-migration-image:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v5.0.0
# No uploads, we're just verifying that nothing broke the docker image.
- name: Build Migration image
uses: ./.github/actions/database-migration-image
with:
base-image: ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/schema_installer
# TODO get current target image from build information
tag: latest-dev
badges:
needs: build
runs-on: ubuntu-latest
# we are reporing build state so always run, but only on builds on the main branch
if: always() && (github.ref_name == 'develop')
steps:
- name: Badge Branch
uses: actions/checkout@v5.0.0
with:
ref: badges
fetch-depth: 1
- name: Download badges
uses: actions/download-artifact@v4
with:
pattern: badges_${{ github.run_id }}_*
path: ./build # directory to download artifacts into
merge-multiple: true # downloaded artifacts will be in the same directory specified by path
- name: Apply Badge
run: |
find . -type f
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add build/**/*.svg
git status
git commit --allow-empty -m "Update Badge for build of ${{ github.sha }}"
git push origin badges -f