Skip to content

Run Gradle on PRs

Run Gradle on PRs #212

Workflow file for this run

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.version }}
cd hibernate-provider
./gradlew publishHibernate-providerPublicationToOssrhRepository
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