Skip to content

Commit

Permalink
Implement JPA through Elide
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Sep 30, 2024
1 parent b1024e6 commit 6379eee
Show file tree
Hide file tree
Showing 24 changed files with 1,234 additions and 672 deletions.
15 changes: 13 additions & 2 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: 'setup'
description: 'CI setup, such as installing JDK'
name: 'CI Setup'
description: 'Environment setup for CI phase such as installing JDK and Elide data models'

inputs:
data-models-repo-org:
description: 'Elide data models repo owner, e.g. paion-data'
required: true
data-models-repo-name:
description: 'Elide data models repo name, e.g. my-jpa-data-model'
required: true

runs:
using: "composite"
steps:
- name: Set up JDK
uses: QubitPi/jersey-webservice-deployment-actions/.github/actions/jdk-setup@master
- name: Load Maven settings.xml
shell: bash
run: cp settings.xml.example ~/.m2/settings.xml
49 changes: 18 additions & 31 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ name: Template CI/CD
push:
branches:
- master
- jpa-elide

env:
JDK_VERSION: 17
JDK_DISTRIBUTION: 'adopt'
USER: QubitPi
EMAIL: jack20220723@gmail.com
MODEL_PACKAGE_NAME: 'io.github.qubitpi.ws.jersey.template.models'

jobs:
yml-md-style-and-link-checks:
uses: QubitPi/hashistack/.github/workflows/yml-md-style-and-link-checks.yml@master
uses: QubitPi/hashicorp-aws/.github/workflows/yml-md-style-and-link-checks.yml@master

tests:
name: Unit & Integration Tests
Expand All @@ -38,6 +40,9 @@ jobs:
- uses: actions/checkout@v3
- name: Test environment setup
uses: ./.github/actions/ci-setup
with:
data-models-repo-org: QubitPi
data-models-repo-name: jersey-webservice-template-jpa-data-models
- name: Set up Docker for Integration Tests
uses: docker-practice/actions-setup-docker@master
- name: Run unit & integration tests
Expand All @@ -54,6 +59,9 @@ jobs:
node-version: 18
- name: Test environment setup
uses: ./.github/actions/ci-setup
with:
data-models-repo-org: QubitPi
data-models-repo-name: jersey-webservice-template-jpa-data-models
- name: Install dependencies
working-directory: docs
run: yarn
Expand All @@ -75,36 +83,15 @@ jobs:
user_name: ${{ env.USER }}
user_email: ${{ env.EMAIL }}

docker-image:
name: Build Test & Release Development Docker Image
needs: tests
triggering:
name: Triggering data model CI/CD
needs: documentation
if: github.ref == 'refs/heads/jpa-elide'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test environment setup
uses: ./.github/actions/ci-setup
- name: Build App WAR file so that Docker can pickup during image build
run: mvn clean package
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Test image build
uses: docker/build-push-action@v3
with:
context: .
push: false
- name: Login to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v3
- name: Trigger data model CI/CD
uses: peter-evans/repository-dispatch@v2
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/jersey-webservice-template:latest
token: ${{ secrets.JWT_DOWNSTREAM_CICD_TRIGGER_TOKEN }}
repository: QubitPi/jersey-webservice-template-jpa-data-models
event-type: jersey-webservice-template-jpa-elide-changes
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright Jiaqi Liu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version: "3.9"
services:
web:
build: .
ports:
- "8080:8080"
environment:
- MODEL_PACKAGE_NAME=${MODEL_PACKAGE_NAME}
- DB_USER=root
- DB_PASSWORD=root
- DB_DRIVER=com.mysql.jdbc.Driver
- DB_DIALECT=org.hibernate.dialect.MySQLDialect
- DB_URL=jdbc:mysql://db/elide?serverTimezone=UTC
- OAUTH_ENABLED=${OAUTH_ENABLED:-false}
- JWKS_URL=${JWKS_URL}
- HIBERNATE_HBM2DDL_AUTO=create
depends_on:
db:
condition: service_healthy
db:
image: "mysql:5.7"
ports:
- "3306:3306"
volumes:
- "${MYSQL_INIT_SCRIPT_PATH:-./mysql-init.sql}:/docker-entrypoint-initdb.d/mysql-init.sql"
environment:
MYSQL_ROOT_PASSWORD: root
command: --character-set-server=utf8 --collation-server=utf8_general_ci
healthcheck:
test: mysqladmin ping -h localhost -u root -proot
timeout: 3s
retries: 3
16 changes: 16 additions & 0 deletions mysql-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright Jiaqi Liu
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

CREATE DATABASE IF NOT EXISTS elide;
USE elide;
143 changes: 59 additions & 84 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

<version.elide>7.1.0</version.elide>
<version.validation.api>3.0.1</version.validation.api>
<version.jersey>3.1.1</version.jersey>
<hibernate.version>6.2.4.Final</hibernate.version>
<version.jcip.annotations>1.0</version.jcip.annotations>
<version.slf4j>1.7.25</version.slf4j>
<version.logback>1.2.3</version.logback>
<version.jackson>2.13.3</version.jackson>
<version.owner>1.0.12</version.owner>
<version.servlet>6.0.0</version.servlet>
<version.jersey>3.1.1</version.jersey>
<version.groovy>4.0.6</version.groovy>
<version.jetty>11.0.15</version.jetty>

Expand All @@ -62,15 +60,6 @@

<dependencyManagement>
<dependencies>
<!-- JSON Parsing -->
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${version.jackson}</version>
<scope>import</scope>
<type>pom</type>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.spockframework</groupId>
Expand All @@ -91,85 +80,75 @@

<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.2</version>
<groupId>${model.package.jar.group.id}</groupId>
<artifactId>${model.package.jar.artifact.id}</artifactId>
<version>${model.package.jar.version}</version>
</dependency>

<!-- Elide -->
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${version.validation.api}</version>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-core</artifactId>
<version>${version.elide}</version>
</dependency>

<!-- Servlet API -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${version.servlet}</version>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-datastore-jpa</artifactId>
<version>${version.elide}</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.1.0</version>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-graphql</artifactId>
<version>${version.elide}</version>
<scope>compile</scope>
</dependency>

<!-- Jersey -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${version.jersey}</version>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-test-helpers</artifactId>
<version>${version.elide}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${version.jersey}</version>
<groupId>io.github.graphql-java</groupId>
<artifactId>graphql-java-annotations</artifactId>
<version>21.5</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${version.jersey}</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${version.jersey}</version>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${version.validation.api}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<version>${version.jersey}</version>
<scope>test</scope>
</dependency>
<dependency> <!-- Jersey Test 'grizzly' container -->
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${version.jersey}</version>
<scope>test</scope>
<scope>compile</scope>
</dependency>

<!-- Injection -->
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-locator</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>

<!-- JSON Parsing -->
<!-- Hibernate -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>

<dependency>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<version>3.0.0.Beta2</version>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-hikaricp</artifactId>
<version>${hibernate.version}</version>
</dependency>

<!-- Concurrency -->
Expand All @@ -188,27 +167,18 @@

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${version.logback}</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-logback</artifactId>
<version>6.25.2</version>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>

<!-- Testing -->
<dependency>
<groupId>io.github.qubitpi</groupId>
<artifactId>jersey-webservice-template-jpa-data-models</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
Expand All @@ -224,7 +194,6 @@
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
Expand Down Expand Up @@ -269,6 +238,12 @@
<version>1.19.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>1.19.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Loading

0 comments on commit 6379eee

Please sign in to comment.