From a6bfa5b62b38cb1d8c86377acce9af5126b932c9 Mon Sep 17 00:00:00 2001 From: Martin Besozzi Date: Thu, 9 Nov 2023 11:21:03 -0300 Subject: [PATCH] feat: Initial version of the SPI for publising the events to the OpenFGA platform. --- .github/tag-changelog-config.js | 31 ++++++++++++++++ .github/workflows/release.yml | 63 +++++++++++++++++++++++++++++++++ docker-compose.yml | 26 +++++++------- pom.xml | 63 +++++++++++++++++++++++---------- 4 files changed, 151 insertions(+), 32 deletions(-) create mode 100644 .github/tag-changelog-config.js create mode 100644 .github/workflows/release.yml diff --git a/.github/tag-changelog-config.js b/.github/tag-changelog-config.js new file mode 100644 index 0000000..bcab84e --- /dev/null +++ b/.github/tag-changelog-config.js @@ -0,0 +1,31 @@ +module.exports = { + types: [ + { types: ["feat", "feature"], label: "โœจ New Features" }, + { types: ["fix", "bugfix"], label: "๐Ÿ› Bugfixes" }, + { types: ["improvements", "enhancement"], label: "๐Ÿ”จ Improvements" }, + { types: ["perf"], label: "๐ŸŽ๏ธ Performance Improvements" }, + { types: ["build", "ci"], label: "๐Ÿ—๏ธ Build System" }, + { types: ["refactor"], label: "๐Ÿชš Refactors" }, + { types: ["doc", "docs"], label: "๐Ÿ“š Documentation Changes" }, + { types: ["test", "tests"], label: "๐Ÿ” Tests" }, + { types: ["style"], label: "๐Ÿ’… Code Style Changes" }, + { types: ["chore"], label: "๐Ÿงน Chores" }, + { types: ["other"], label: "Other Changes" }, + ], + + excludeTypes: ["other"], + + renderTypeSection: function (label, commits) { + let text = `\n## ${label}\n`; + commits.forEach((commit) => { + const scope = commit.scope ? `**${commit.scope}**: ` : '' + text += `- [\`${commit.sha.substring(0, 7)}\`](${commit.url}) ${scope} ${commit.subject}\n`; + }); + return text; + }, + + renderChangelog: function (release, changes) { + const now = new Date(); + return `# ${release} - ${now.toISOString().substr(0, 10)}\n` + changes + "\n\n"; + }, + }; \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..75be355 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + build-upload-release: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + discussions: write + steps: + - uses: actions/checkout@v3 + + - name: Get version from tag + id: version + run: echo ::set-output name=number::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d / -f 3 | sed -e 's/^v//') + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Get jar name + id: get_name + run: echo "::set-output name=name::$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" + + - name: Build with maven + run: mvn clean package + + - name: Create changelog text + id: changelog + uses: loopwerk/tag-changelog@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + exclude_types: other,doc,chore + config_file: .github/tag-changelog-config.js + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.number }} + release_name: ${{ steps.version.outputs.number }} + body: ${{ steps.changelog.outputs.changes }} + draft: false + prerelease: false + + - name: Upload JAR to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./target/${{ steps.get_name.outputs.name }}.jar + asset_name: ${{ steps.get_name.outputs.name }}.jar + asset_content_type: application/java-archive diff --git a/docker-compose.yml b/docker-compose.yml index 803d416..d6f175e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ version: '3.8' -volumes: - postgres_data: - driver: local +# volumes: +# postgres_data: +# driver: local services: postgres: @@ -46,12 +46,12 @@ services: - 9080:8080 - 8443:8443 volumes: - - $PWD/target/keycloak-openfga-event-publisher-1.0.0-jar-with-dependencies.jar:/opt/keycloak/providers/keycloak-openfga-event-publisher-1.0.0.jar + - $PWD/target/keycloak-openfga-event-publisher.jar:/opt/keycloak/providers/keycloak-openfga-event-publisher.jar depends_on: - - postgres -# condition: service_completed_successfully -# openfga: -# condition: service_completed_successfully + postgres: + condition: service_completed_successfully + openfga: + condition: service_completed_successfully networks: default: aliases: @@ -98,11 +98,11 @@ services: - OPENFGA_DATASTORE_ENGINE=postgres - OPENFGA_DATASTORE_URI=postgres://postgres:password@postgres-openfga:5432/postgres?sslmode=disable - OPENFGA_DATASTORE_MAX_OPEN_CONNS=100 -# healthcheck: -# interval: 5s -# test: ["CMD", "curl", "-f", "http://localhost:8080/healthz"] -# timeout: 5s -# retries: 5 + healthcheck: + test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=openfga:8081"] + interval: 3s + timeout: 30s + retries: 3 networks: - default ports: diff --git a/pom.xml b/pom.xml index de4f2f9..ccdb03f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,25 +4,26 @@ 4.0.0 com.twogentity.keycloak keycloak-openfga-event-publisher - 1.0.0 + 1.0.1 11 11 19.0.0 - 3.3.1 + 2.15.2 + 2.15.2 5.8.1 - - org.keycloak - keycloak-parent - ${keycloak.version} - pom - import - + + org.keycloak + keycloak-parent + ${keycloak.version} + pom + import + @@ -31,8 +32,8 @@ org.keycloak keycloak-core - ${keycloak.version} - + provided + org.keycloak @@ -51,6 +52,7 @@ org.jboss.logging jboss-logging + 3.5.0.Final provided @@ -60,6 +62,24 @@ 0.1.0 + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + provided + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.databind.version} + provided + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + provided + org.junit.jupiter junit-jupiter-api @@ -69,23 +89,28 @@ + ${project.artifactId} - maven-assembly-plugin - - - jar-with-dependencies - - + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 - make-assembly package - single + shade + + + + org.openapitools:jackson-databind-nullable + dev.openfga:openfga-sdk + + +