diff --git a/.github/dco.yml b/.github/dco.yml deleted file mode 100644 index 37e411e1bee..00000000000 --- a/.github/dco.yml +++ /dev/null @@ -1,2 +0,0 @@ -require: - members: false \ No newline at end of file diff --git a/.github/workflows/deploy-and-test-cluster.yml b/.github/workflows/deploy-and-test-cluster.yml deleted file mode 100644 index 7353a604bba..00000000000 --- a/.github/workflows/deploy-and-test-cluster.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Deploy and Test Cluster - -on: - push: - branches: [main] - paths: - - 'k8s/**' - pull_request: - branches: [main] - paths: - - 'k8s/**' - -jobs: - deploy-and-test-cluster: - runs-on: ubuntu-latest - steps: - - name: Check out the repository - uses: actions/checkout@v2 - - - name: Create k8s Kind Cluster - uses: helm/kind-action@v1 - - - name: Deploy application - run: | - kubectl apply -f k8s/ - - - name: Wait for Pods to be ready - run: | - kubectl wait --for=condition=ready pod -l app=demo-db --timeout=180s - kubectl wait --for=condition=ready pod -l app=petclinic --timeout=180s - diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml new file mode 100644 index 00000000000..c65a0beb6cc --- /dev/null +++ b/.github/workflows/dev.yaml @@ -0,0 +1,53 @@ +--- +name: dev-branch + +on: + push: + branches: + - dev + +jobs: + maven-build-job: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + security-events: write + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup java + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: java + - name: package the code + run: mvn clean package + - name: Perform code quality analysis + uses: github/codeql-action/analyze@v4 + # - name: publish test results + # uses: EnricoMi/publish-unit-test-result-action@v2 + # with: + # files: '**/target/surefire-reports/**/*.xml' + # comment_mode: always + - name: upload JAR as artifact + uses: actions/upload-artifact@v4 + with: + name: spring-petclinic-jar + path: target/*.jar + docker-build-job: + runs-on: ubuntu-latest + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup docker buildx + uses: docker/setup-buildx-action@v4 + - name: build the docker image + uses: docker/build-push-action@v7 + with: + push: false + tags: spring-petclinic:latest \ No newline at end of file diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml deleted file mode 100644 index c24c121b1e6..00000000000 --- a/.github/workflows/gradle-build.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-gradle - -name: Java CI with Gradle - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - java: [ '17' ] - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{matrix.java}} - uses: actions/setup-java@v4 - with: - java-version: ${{matrix.java}} - distribution: 'adopt' - cache: maven - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - name: Build with Gradle - run: ./gradlew build diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000000..1a3b8fdaebb --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,45 @@ +--- +name: main-branch + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + maven-build-job: + runs-on: ubuntu-latest + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup java + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: java + - name: package the code + run: mvn --batch-mode -Dmaven.test.failure.ignore=true test + - name: Perform code quality analysis + uses: github/codeql-action/analyze@v4 + - name: publish test results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: '**/target/surefire-reports/**/*.xml' + comment_mode: always + docker-build-job: + runs-on: ubuntu-latest + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup docker buildx + uses: docker/setup-buildx-action@v4 + - name: build the docker image + uses: docker/build-push-action@v7 + with: + push: false + tags: spring-petclinic:latest \ No newline at end of file diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml deleted file mode 100644 index a1ec4dab78c..00000000000 --- a/.github/workflows/maven-build.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven - -name: Java CI with Maven - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - java: [ '17' ] - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{matrix.java}} - uses: actions/setup-java@v4 - with: - java-version: ${{matrix.java}} - distribution: 'adopt' - cache: maven - - name: Build with Maven Wrapper - run: ./mvnw -B verify diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 00000000000..d885e61ed17 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,48 @@ +--- +name: pull-request-workflow + +permissions: + checks: write + contents: read + +on: + pull_request: + branches: + - dev + +jobs: + maven-build-job: + runs-on: ubuntu-latest + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup java + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: java + - name: package the code + run: mvn --batch-mode -Dmaven.test.failure.ignore=true test package + - name: Perform code quality analysis + uses: github/codeql-action/analyze@v4 + # - name: publish test results + # uses: EnricoMi/publish-unit-test-result-action@v2 + # with: + # files: '**/target/surefire-reports/**/*.xml' + # comment_mode: always + docker-build-job: + runs-on: ubuntu-latest + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup docker buildx + uses: docker/setup-buildx-action@v4 + - name: build the docker image + uses: docker/build-push-action@v7 + with: + push: false + tags: spring-petclinic:latest \ No newline at end of file diff --git a/.github/workflows/rel_v1.yaml b/.github/workflows/rel_v1.yaml new file mode 100644 index 00000000000..4a328c9df38 --- /dev/null +++ b/.github/workflows/rel_v1.yaml @@ -0,0 +1,72 @@ +--- +name: release-branch + +on: + push: + branches: + - rel_v1 + +jobs: + maven-build-job: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + security-events: write + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup java + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' + server-id: github + settings-path: ${{ github.workspace }} + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: java + + - name: Remove generated toolchains.xml + run: rm -f toolchains.xml + - name: package the code + run: mvn clean package + # - name: Perform code quality analysis + # uses: github/codeql-action/analyze@v4 + # - name: publish test results + # uses: EnricoMi/publish-unit-test-result-action@v2 + # with: + # files: '**/target/surefire-reports/**/*.xml' + # comment_mode: always + - name: publish package + run: mvn deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + docker-build-job: + runs-on: ubuntu-latest + steps: + - name: get the code + uses: actions/checkout@v6 + - name: setup docker buildx + uses: docker/setup-buildx-action@v4 + - name: Login into Github Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata + id: metadata + uses: docker/metadata-action@v6 + with: + images: ghcr.io/${{ github.repository_owner }}/spring-petclinic + + - name: build the docker image + uses: docker/build-push-action@v7 + with: + push: true + context: . + tags: | + ghcr.io/${{ github.repository_owner }}/spring-petclinic:latest + ghcr.io/${{ github.repository_owner }}/spring-petclinic:${{ github.sha }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..5c8b97859a8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM eclipse-temurin:21-jdk AS build +WORKDIR /app +COPY .mvn .mvn +COPY mvnw pom.xml . +RUN ./mvnw dependency:go-offline +COPY src src +RUN ./mvnw package -DskipTests + + +FROM eclipse-temurin:21-jdk +WORKDIR /app +COPY --from=build /app/target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "/app/app.jar"] diff --git a/pom.xml b/pom.xml index 36251b49e5c..b13130deaf5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - + 4.0.0 diff --git a/prompts b/prompts new file mode 100644 index 00000000000..ad419ef4cbb --- /dev/null +++ b/prompts @@ -0,0 +1 @@ +Dockerfile: write a multistage Docker file which runs springpetclinic and uses jdk 21 \ No newline at end of file