forked from InseeFr/Trevas
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (163 loc) · 5.4 KB
/
ci.yml
File metadata and controls
167 lines (163 loc) · 5.4 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
name: Trevas CI
on:
push:
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Verify code format with Spotless
run: mvn spotless:check
test-excluding-vtl-sdmx:
name: Run Trevas tests excluding vtl-sdmx module
runs-on: ubuntu-latest
needs: format
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
# Also exclude vtl-prov because of vtl-sdmx scope test dependency
- name: Test
run: mvn test -pl '!vtl-sdmx,!vtl-prov'
test:
name: Run Trevas tests
if: (github.repository != 'InseeFr/Trevas' &&
github.event_name == 'push') ||
(github.event.pull_request.head.repo.fork == true ||
(github.event.pull_request.head.repo.fork == false &&
github.event.pull_request.merged == false))
runs-on: ubuntu-latest
needs: format
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
- uses: s4u/maven-settings-action@v3.0.0
with:
githubServer: false
servers: |
[{
"id": "Github",
"username": "${{ secrets.GH_PACKAGES_USERNAME }}",
"password": "${{ secrets.GH_PACKAGES_PASSWORD }}"
}]
- name: Test
run: mvn test
package:
name: Package Trevas modules
# Filter thanks to test job
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
- uses: s4u/maven-settings-action@v3.0.0
with:
githubServer: false
servers: |
[{
"id": "Github",
"username": "${{ secrets.GH_PACKAGES_USERNAME }}",
"password": "${{ secrets.GH_PACKAGES_PASSWORD }}"
}]
- name: Test
run: mvn package
# test-sonar-package:
# name: Run Trevas tests with coverage & sonar checks
# Trevas main repo commit branch or merged PR
# if: github.repository == 'InseeFr/Trevas' &&
# (github.event_name == 'push' ||
# github.event.pull_request.head.repo.fork == false ||
# (github.event.pull_request.head.repo.fork == true &&
# github.event.pull_request.merged == true))
# runs-on: ubuntu-latest
# needs: format
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Set up Maven Central Repository
# uses: actions/setup-java@v4
# with:
# java-version: 17
# distribution: "adopt"
# - uses: s4u/maven-settings-action@v3.0.0
# with:
# githubServer: false
# servers: |
# [{
# "id": "Github",
# "username": "${{ secrets.GH_PACKAGES_USERNAME }}",
# "password": "${{ secrets.GH_PACKAGES_PASSWORD }}"
# }]
# - name: Test, package and analyze with maven & SonarCloud
# run: mvn verify sonar:sonar -Pcoverage -Dsonar.projectKey=InseeFr_Trevas -Dsonar.organization=inseefr -Dsonar.host.url=https://sonarcloud.io
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
publish-release:
name: Publish Trevas modules on Maven
if: startsWith(github.event.ref, 'refs/tags/v')
# Temp update because of sonar token issue
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v1
env:
GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- uses: s4u/maven-settings-action@v3.0.0
with:
githubServer: false
servers: |
[
{
"id": "Github",
"username": "${{ secrets.GH_PACKAGES_USERNAME }}",
"password": "${{ secrets.GH_PACKAGES_PASSWORD }}"
},
{
"id": "central",
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
"password": "${{ secrets.MAVEN_CENTRAL_TOKEN }}"
}
]
- name: Publish Trevas
run: mvn -B deploy -Prelease -DskipTests=true --no-transfer-progress
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}