-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (115 loc) · 6 KB
/
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
name: Run Gradle on PRs
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
version:
type: string
description: the version to publish
jobs:
gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- name: Setup Gradle
uses: gradle/[email protected]
- name: Import GPG key
run: |
echo "${{ secrets.GPG_BASE64 }}" | base64 --decode > /tmp/gpg.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --import --passphrase-fd 0 /tmp/gpg.key
echo "signing.keyId=BB19097D" >> ~/.gradle/gradle.properties
echo "signing.password=${{ secrets.GPG_PASSPHRASE }}" >> ~/.gradle/gradle.properties
echo "signing.secretKeyRingFile=/tmp/gpg.key" >> ~/.gradle/gradle.properties
echo "ossrhUsername=${{ secrets.OSSRH_USERNAME }}" >> ~/.gradle/gradle.properties
echo "ossrhPassword=${{ secrets.OSSRH_PASSWORD }}" >> ~/.gradle/gradle.properties
echo "gradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}" >> ~/.gradle/gradle.properties
echo "gradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}" >> ~/.gradle/gradle.properties
sed "s@MAVEN_CENTRAL_PASSWORD@${{ secrets.OSSRH_PASSWORD }}@" maven-plugin/settings.xml.tmpl | sed "s@MAVEN_CENTRAL_USERNAME@${{ secrets.OSSRH_USERNAME }}@" > maven-plugin/settings.xml
- name: Setup Atlas
uses: ariga/setup-atlas@master
- name: Build and test Plugin
run: ./gradlew build
- name: Integration tests with local plugin repo
run: |
PROVIDER_VERSION=0.1.1 ./gradlew publishAllPublicationsToLocalPluginRepositoryRepository
cd examples/with_local_plugin_repository
./gradlew -q schema | tee schema_output
diff schema_output src/test/expected_default_schema
./gradlew integrationTests
- name: Integration tests with unsupported schema
run: |
cd examples/with_forbidden_generation_type
if (set -o pipefail && atlas schema inspect --env hibernate --url env://src 2>&1 | tee /tmp/forbidden_output); then
echo "expected schema extraction to fail due to an unsupported SQL command" && false
else
echo "command failed successfully, checking output contains error string"
grep -i "unsupported.sql.command" /tmp/forbidden_output || (echo "Failed output comparison, output was:" && cat /tmp/forbidden_output && false)
echo "error string found"
fi
- name: Build Maven Plugin
run: |
cd maven-plugin
mvn clean install -Dgpg.passphrase='${{ secrets.gpg_passphrase }}' --batch-mode
- name: Integration tests with maven plugin
run: |
cd examples/maven_project_example
mvn compile --batch-mode
cd allowed_types
set -x
mvn -q hibernate-provider:schema | tee maven_schema_output
diff maven_schema_output src/test/expected_default_schema
mvn -q hibernate-provider:schema@schema-using-postgresql-properties | tee maven_psql_output
diff maven_psql_output src/test/expected_postgresql_output
mvn -q hibernate-provider:schema -Dregistry-builder=com.example.H2ServiceRegistryBuilder | tee maven_h2_output
diff maven_h2_output src/test/expected_h2_output
mvn -q hibernate-provider:schema -Dmetadata-builder=com.example.MetadataBuilder | tee maven_mini_output
diff maven_mini_output src/test/expected_mini_output
mvn -q hibernate-provider:schema -Dpackages="com.example.model" | tee maven_employee_output
diff maven_employee_output src/test/expected_employee_output
mvn -q hibernate-provider:schema -Dpackages="com.example.model" -Dclasses="com.example.minimodel.Location" | tee maven_classes_and_packages_output
diff maven_classes_and_packages_output src/test/expected_default_schema
cd ../forbidden_types
if (set -o pipefail && atlas schema inspect --env hibernate --url env://src 2>&1 | tee /tmp/forbidden_output); then
echo "expected schema extraction to fail due to an unsupported SQL command" && false
else
echo "command failed successfully, checking output contains error string"
grep -i "unsupported GenerationType.SEQUENCE" /tmp/forbidden_output || (echo "Failed output comparison, output was:" && cat /tmp/forbidden_output && false)
echo "error string found"
fi
set +x
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
- name: E2E test spring project
run: |
cd examples/with_spring_gradle
output=$(atlas migrate diff --env hibernate)
[ "$output" = "The migration directory is synced with the desired state, no changes to be made" ] || (echo "diff detected? unexpected output: $output"; ls -l migrations; exit 1)
- name: E2E test maven project
run: |
cd examples/maven_project_example/allowed_types
output=$(atlas migrate diff --env hibernate)
[ "$output" = "The migration directory is synced with the desired state, no changes to be made" ] || (echo "diff detected? unexpected output: $output"; ls -l migrations; exit 1)
- name: Release
if: github.event_name == 'workflow_dispatch'
run: |
export PROVIDER_VERSION=${{ inputs.provider-version }}
cd hibernate-provider
./gradlew publishPluginMavenPublicationToOssrhRepository
cd ../gradle-plugin
./gradlew publishPlugins
cd ../maven-plugin
mvn clean deploy --batch-mode -Dprovider.version=$PROVIDER_VERSION -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -s settings.xml
- name: Cleanup
if: always()
run: |
rm ~/.gradle/gradle.properties
rm /tmp/gpg.key