-
Notifications
You must be signed in to change notification settings - Fork 3
168 lines (152 loc) Β· 4.56 KB
/
order-ci.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
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
name: Order service CI
on:
push:
branches: [ "main" ]
paths:
- "order/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/order-ci.yaml"
- "pom.xml"
pull_request:
branches: [ "main" ]
paths:
- "order/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/order-ci.yaml"
- "pom.xml"
workflow_dispatch:
jobs:
style:
runs-on: ubuntu-latest
name: Check style
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run maven checkstyle
run: mvn checkstyle:checkstyle -f order
compile:
runs-on: ubuntu-latest
name: Compile project
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'
cache: maven
- name: Compile project
run: mvn clean compile -f order
unit-tests:
runs-on: ubuntu-latest
name: Unit tests
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'
cache: maven
- name: Running unit tests
run: mvn test -f order jacoco:report
build:
runs-on: ubuntu-latest
name: Build project
needs: [compile, unit-tests]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'
cache: maven
- name: Building project
run: mvn package -f order
coverage:
runs-on: ubuntu-latest
env:
FROM_ORIGINAL_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main' }}
permissions:
pull-requests: write
packages: write
name: Coverage and Package
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'
cache: maven
- name: Building project
run: mvn package -f order
- name: Add coverage report to PR
uses: madrapps/[email protected]
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
with:
paths: ${{github.workspace}}/order/target/site/jacoco/jacoco.xml
token: ${{secrets.GITHUB_TOKEN}}
min-coverage-overall: 30
min-coverage-changed-files: 20
title: 'Order Coverage Report'
update-comment: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
continue-on-error: false
- name: OWASP Dependency Check
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
uses: dependency-check/Dependency-Check_Action@main
env:
JAVA_HOME: /opt/jdk
with:
project: 'matcha'
path: '.'
format: 'HTML'
- name: Upload OWASP Dependency Check results
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
uses: actions/upload-artifact@master
with:
name: OWASP Dependency Check Report
path: ${{github.workspace}}/reports
- name: Log in to the Container registry
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v6
with:
context: ./order
push: true
file: ./order/Dockerfile
platforms: linux/amd64
tags: ghcr.io/${{ github.repository_owner }}/matcha-order:latest
check:
runs-on: ubuntu-latest
name: Git-leaks check
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Gitleaks check
run: |
docker pull zricethezav/gitleaks:v8.18.4
docker run --rm -v ${{ github.workspace }}:/work -w /work zricethezav/gitleaks:v8.18.4 detect --source="." --config="/work/gitleaks.toml" --verbose --no-git