-
Notifications
You must be signed in to change notification settings - Fork 25
118 lines (99 loc) · 3.62 KB
/
database.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
name: Build
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 8 * * *"
permissions:
id-token: write
contents: read
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
services:
docker:
image: docker:20.10.7
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better SonarCloud analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven
- name: Set timezone
run: |
export TZ=America/Los_Angeles
- name: Setup Maven settings
run: |
cp .github/maven-settings.xml $HOME/.m2/settings.xml
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml
- name: Test and Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn -e -Dfailsafe.rerunFailingTestsCount=3 -Dmaven.javadoc.skip=true \
"-Duser.timezone=America/Los_Angeles" \
"-Dhsqldb.database.url=jdbc:hsqldb:file:target/hsqldb;shutdown=true" \
-Dhsqldb.database.user=SA -Dhsqldb.database.password= -Pcoverage,hsqldb verify &&
bash test-postgres.sh &&
bash test-sqlserver.sh &&
bash test-oracle.sh &&
mvn -e org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=susom_database
- name: Display Surefire reports on failure
if: failure()
run: |
for F in target/surefire-reports/*.txt; do echo $F; cat $F; echo; done
deploy-snapshots:
name: Deploy to Artifact Registry
runs-on: ubuntu-latest
if: github.repository == 'susom/database' && github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: build-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven
- name: Setup Maven settings
run: |
cp .github/maven-settings.xml $HOME/.m2/settings.xml
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.WORKLOAD_IDENTITY_PROJECT }}
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
create_credentials_file: true
export_environment_variables: true
cleanup_credentials: true
- name: Set up OAuth2 access token for Maven
run: |
echo "ACCESS_TOKEN=$(gcloud auth print-access-token)" >> $GITHUB_ENV
- name: Deploy to Maven
run: mvn --batch-mode -e -DskipTests=true deploy