forked from mangeshpa/simple-java-maven-app
-
Notifications
You must be signed in to change notification settings - Fork 18
250 lines (223 loc) · 8.23 KB
/
action.yml
File metadata and controls
250 lines (223 loc) · 8.23 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
env:
STACK: java
BUILD_TECH: java_maven
MVN_ARGS: clean install --batch-mode --update-snapshots verify
CONTINUE_ON_ERROR: false
CONTINUE_ON_ERROR_SETUP: true
JOB_STATUS_CODE: 0
on:
push:
# and the target with some regex to match specific branch namess
branches:
- master
- 'FEATURE-[0-9]-[0-9]-[0-9]-X-BRANCH'
- '[0-9]_[0-9]_x'
- '[0-9]-[0-9]-X-BRANCH'
pull_request:
branches:
- master
- 'FEATURE-[0-9]-[0-9]-[0-9]-X-BRANCH'
- '[0-9]_[0-9]_x'
- '[0-9]-[0-9]-X-BRANCH'
jobs:
# pre-commit:
# runs-on: ubuntu-latest
#
# steps:
# - name: Set up pre-commit cache
# id: commit_check
# uses: pre-commit/action@v2.0.0
# with:
# extra_args: --files ${{steps.file_changes.outputs.files}}
#
# - name: PR comment
# if: failure()
# uses: actions/github-script@v4
#
# with:
# github-token: ${{secrets.GIT_TOKEN}}
# script: |
# github.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: ' Ups, something went wrong. Please checkout the following error: '
# });
Build:
runs-on: ubuntu-latest
steps:
######## Checkout code ########
- name: 'Checkout repository on branch: ${{ github.REF }}'
uses: actions/checkout@v2
continue-on-error: ${{ env.CONTINUE_ON_ERROR }}
with:
ref: ${{ github.REF }}
fetch-depth: 0
#- name: Notify dedicated teams channel
#uses: jdcargile/ms-teams-notification@v1.3
#with:
#github-token: ${{ github.token }} # this will use the runner's token.
#ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
#notification-summary: Build Started
#notification-color: 17a2b8
# - name: show job status
# if: always()
# run: echo ${{ job.status }}
# - name: fail the job
# run: exit 1
# - name: set_step_status
# if: ${{ job.status == 0 }}
# run: |
# echo ::set-env JOB_STATUS_CODE=2
######## Setup JDK 11 ########
- name: set up JDK 11
id: setup_jdk
if: ${{ env.STACK == 'java' }}
uses: actions/setup-java@v2
continue-on-error: ${{ env.CONTINUE_ON_ERROR }}
with:
java-version: '11'
distribution: 'adopt'
# - name: Print Setup status
# run: echo ${{ steps.setup_jdk.outcome }}
######## Build - Maven ########
- name: Build with Maven
id: build_maven
if: ${{ env.BUILD_TECH == 'java_maven' }}
run: |
mvn ${{ env.MVN_ARGS }}
continue-on-error: ${{ env.CONTINUE_ON_ERROR }}
######## Build - Ant ########
- name: Build with Ant
if: ${{ env.BUILD_TECH == 'java_ant' }}
run: ant -noinput -buildfile build.xml
continue-on-error: ${{ env.CONTINUE_ON_ERROR }}
######## Build - Gradle ########
- name: Validate Gradle wrapper
if: ${{ env.BUILD_TECH == 'java_gradle' }}
uses: gradle/wrapper-validation-action@v1
continue-on-error: ${{ env.CONTINUE_ON_ERROR_SETUP }}
- name: Build with Gradle
if: ${{ env.BUILD_TECH == 'java_gradle' }}
run: ./gradlew build
continue-on-error: ${{ env.CONTINUE_ON_ERROR }}
######## Notify MS Teams Channel on Failure ########
#- name: Notify dedicated MS teams channel [Build failure]
#if: ${{ failure() }}
#uses: jdcargile/ms-teams-notification@v1.3
#with:
#github-token: ${{ github.token }} # this will use the runner's token.
#ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
#notification-summary: Deployment Failed while Building the code
#notification-color: dc3545
######## JUnit Test with Maven ########
- name: Test with Maven
run: mvn -B test --file pom.xml
- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: target/site/jacoco/jacoco.csv
badges-directory: .github/JaCoCo
generate-coverage-badge: true
coverage-badge-filename: jacoco.svg
generate-branches-badge: false
branches-badge-filename: branches.svg
colors: '#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44'
intervals: 100 90 80 70 60 0
on-missing-report: fail
fail-if-coverage-less-than: 0
fail-if-branches-less-than: 0
fail-on-coverage-decrease: false
fail-on-branches-decrease: false
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Upload JaCoCo coverage report
uses: actions/upload-artifact@v2
with:
name: jacoco-report
path: target/site/jacoco/
- uses: codecov/codecov-action@v1
with:
file: ./**/target/site/jacoco/jacoco.xml
name: codecov
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: target/surefire-reports/*.xml
######## Setup .Net ########
- name: Setup .NET 3.x
if: ${{ env.STACK == 'dotnet' }}
uses: actions/setup-dotnet@v1
continue-on-error: ${{ env.CONTINUE_ON_ERROR_SETUP }}
with:
dotnet-version: '3.x'
- name: Sanity Check
run: ls -l $GITHUB_WORKSPACE
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.2.4
with:
# Artifact name
name: artifact
path: ${{ github.workspace }}/
# optional, default is artifact
# A file, directory or wildcard pattern that describes what to upload
- name: list
run: |
cd ${{ github.workspace }}
ls
pwd
whoami
ls -ltrR
######## Sonar Cloud Scan ########
Code-Quality-Check:
needs: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# if: ${{ job.status == 2 }}
- name: SonarCloud Scan
#run: mvn -B sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=pintu-gupta-github -Dsonar.projectKey=pintu-gupta-github
run: mvn -B sonar:sonar -Dsonar.projectKey=Java-Maven-Jacoco-Sonar -Dsonar.projectName=Java-Maven-Jacoco-Sonar -Dsonar.host.url=http://3.141.23.89:9000 -Dsonar.login=103e87043953a8c9564be3a5fbed3a26a6d084c2
#uses: sonarsource/sonarcloud-github-action@master
#with:
# args: >
# -Dsonar.language=java
# -Dsonar.host.url=https://sonarcloud.io
# -Dsonar.organization=pintu-gupta
# -Dsonar.projectKey=pintu-gupta-github
# -Dsonar.projectName=simple-java-maven-app
# -Dsonar.projectVersion=1.0
#env:
#GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
#SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
######## Notify MS Teams Channel on Failure ########
#- name: Notify dedicated MS teams channel [Sonar Scan failure]
#if: ${{ failure() }}
#uses: jdcargile/ms-teams-notification@v1.3
#with:
#github-token: ${{ github.token }} # this will use the runner's token.
#ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
#notification-summary: Deployment Failed while Building the code
#notification-color: dc3545
######## Deployment - Dev Environment ########
Functional-Test-Progression:
runs-on: ubuntu-latest
needs: Deploy-Dev
steps:
- name: Progression
run: echo ${{ job.status }}
Performance-Test:
runs-on: ubuntu-latest
needs: Deploy-Dev
steps:
- name: Peerformance-Test
run: echo ${{ job.status }}
Stage-Artifacts:
runs-on: ubuntu-latest
needs: [Functional-Test-Progression, Functional-Test-Regression]
steps:
- name: Upload Artifacts to Artifactory
run: echo ${{ job.status }}