-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (111 loc) · 4.58 KB
/
maven-verify.yml
File metadata and controls
122 lines (111 loc) · 4.58 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
# https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
# https://docs.github.com/en/actions/sharing-automations/reusing-workflows
name: Maven verify
on:
workflow_call:
inputs:
# calling workflow can specify inputs as follows:
# uses: <this reusable workflow>
# with:
# mvn-options: <custom options>
mvn-options:
description: 'extra maven command line options (space separated)'
default: ''
required: false
type: string
runner:
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
description: 'label of the hosted runner'
default: 'ubuntu-latest'
required: false
type: string
java-version:
description: 'java version for use with the setup-java action'
default: 21
required: false
type: number
db-type:
description: 'type of database: postgresql or mongodb'
required: true
type: string
db-name:
description: 'name of database to be created'
default: ''
required: false
type: string
db-username:
default: ''
required: false
type: string
db-password:
default: ''
required: false
type: string
db-port:
default: 0
required: false
type: number
db-version:
required: true
type: number
jobs:
build:
runs-on: ${{ inputs.runner }}
steps:
- # https://github.com/actions/checkout
name: Clone repository
uses: actions/checkout@v6
- # https://github.com/ikalnytskyi/action-setup-postgres
# copied from FDP develop (3ff9f64) build.yml
# TODO: can we use the pre-installed postgres instead of this action?
# (see readme files in https://github.com/actions/runner-images/tree/main/images)
name: Setup PostgreSQL database
if: inputs.db-type == 'postgresql'
uses: ikalnytskyi/action-setup-postgres@v8
with:
username: ${{ inputs.db-username }}
password: ${{ inputs.db-password }}
database: ${{ inputs.db-name }}
port: ${{ inputs.db-port }}
postgres-version: ${{ inputs.db-version }}
- name: Test PostgreSQL connection
if: inputs.db-type == 'postgresql'
run: pg_isready --host=localhost --port=${{ inputs.db-port }} --dbname=${{ inputs.db-name }} --username=${{ inputs.db-username }}
- # https://github.com/ankane/setup-mongodb
# copied from FDP v1.17.2 build.yml
# TODO: ankane/setup-mongodb is a one-man band, should we use an alternative?
# (see e.g. https://github.com/supercharge/mongodb-github-action)
name: Set up MongoDB
if: inputs.db-type == 'mongodb'
uses: ankane/setup-mongodb@v1
with:
mongodb-version: ${{ inputs.db-version }}
- name: Check MongoDB
if: inputs.db-type == 'mongodb'
run: |
${{ inputs.db-version < 6 && 'mongo' || 'mongosh' }} --eval "db.version()"
- # https://github.com/actions/setup-java
name: Setup Java
uses: actions/setup-java@v5
with:
java-version: ${{ inputs.java-version }}
distribution: 'temurin'
cache: maven
- # test and verify
# Note that e.g. `mvn verify` runs all lifecycle phases up to and including the verify phase [1].
# A spring-boot profile can be specified, e.g. `mvn-options: '-D"spring.profiles.active"=testing'`.
# (beware: the quotes around spring.profiles.active are required when using a Windows runner)
# Currently [2] it is not possible to pass env variables from caller to a reusable workflow, but, if necessary,
# we can override settings using `mvn-options`, e.g. `spring.datasource.url` etc. (see FDP application.yml).
# [1]: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
# [2]: https://docs.github.com/en/actions/sharing-automations/reusing-workflows#limitations
name: Run maven verify
run: mvn --batch-mode --update-snapshots --fail-fast ${{ inputs.mvn-options }} verify
- # https://github.com/actions/upload-artifact
name: Upload surefire reports
if: failure()
uses: actions/upload-artifact@v5
with:
name: "surefire-reports-${{ inputs.runner }}"
path: target/surefire-reports/**
retention-days: 7