diff --git a/.commitlintrc.js b/.commitlintrc.js new file mode 100644 index 00000000..f2a2f255 --- /dev/null +++ b/.commitlintrc.js @@ -0,0 +1,19 @@ +module.exports = { + extends: ["@commitlint/config-conventional"], + rules: { + "type-empty": [2, "never"], + "type-case": [2, "always", "lower-case"], + "type-enum": [ + 2, + "always", + ["build", "ci", "feat", "fix", "docs", "style", "refactor", "revert", "chore", "wip", "perf"], + ], + "scope-empty": [2, "never"], + "scope-case": [2, "always", "kebab-case"], + "scope-enum": [ + 2, + "always", + ["all", "application", "runtime", "workflow", "readme", "kubernetes", "docker", "gradle"], + ], + }, +}; diff --git a/.github/workflows/build_container.yml b/.github/workflows/build_container.yml deleted file mode 100644 index fb5ce3a5..00000000 --- a/.github/workflows/build_container.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Workflow requires Variables to be defined as follows: -# secrets.GHCR_USER -> User to push to GHCR -# secrets.GITHUB_TOKEN -> Password with rights to push to GHCR - -name: "Build And Push Container" -on: - workflow_dispatch: - release: - types: - - released - -jobs: - docker_image: - name: Generate Docker Image - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - persist-credentials: false - - name: Get Release Version - id: release - uses: GuillaumeFalourd/get-release-or-tag@v2 - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - - name: Build Docker Image - run: ./gradlew jibDockerBuild - - name: Login to Github Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ secrets.GHCR_USER }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Push Applications Github Container Registry - run: docker push --all-tags ghcr.io/es-ude/elastic-ai.cloud.applications.ball_challenge - - name: Push Monitor to Github Container Registry - run: docker push --all-tags ghcr.io/es-ude/elastic-ai.cloud.applications.monitor diff --git a/.github/workflows/build_packages.yml b/.github/workflows/build_packages.yml new file mode 100644 index 00000000..54d64acf --- /dev/null +++ b/.github/workflows/build_packages.yml @@ -0,0 +1,66 @@ +name: "Build Release Packages" +on: + workflow_dispatch: + release: + types: + - released +permissions: + contents: read + packages: write +jobs: + maven_package: + name: Publish runtime as Maven Package + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + - name: Get Release Version + id: release + uses: GuillaumeFalourd/get-release-or-tag@v2 + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 22 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Push Package + env: + ACTOR: ${{ github.actor }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ./gradlew -Pversion=${{ steps.release.outputs.tag }} :runtime:publish + container_image: + name: Publish Monitor as Container Image + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + - name: Get Release Version + id: release + uses: GuillaumeFalourd/get-release-or-tag@v2 + - name: Get Release Artifacts + uses: Itsblue/download-release-assets-action@v4 + with: + version: ${{ steps.release.outputs.tag }} + file: "monitor.jar" + path: "monitor/build/libs" + - name: Build Monitor Image + working-directory: ./monitor + env: + RELEASE_TAG: ${{ steps.release.outputs.tag }} + run: | + docker build --file Dockerfile --tag ghcr.io/$GITHUB_REPOSITORY:$RELEASE_TAG --tag ghcr.io/$GITHUB_REPOSITORY:latest . + - name: Login to Github Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Push Image to Github Container Registry + run: | + docker push --all-tags ghcr.io/$GITHUB_REPOSITORY diff --git a/.github/workflows/push_to_main.yml b/.github/workflows/create_release.yml similarity index 56% rename from .github/workflows/push_to_main.yml rename to .github/workflows/create_release.yml index 187c50cc..d7aecffe 100644 --- a/.github/workflows/push_to_main.yml +++ b/.github/workflows/create_release.yml @@ -1,33 +1,37 @@ -# Workflow requires Variables to be defined as follows: -# secrets.PUSH_TOKEN -> Password with rights to push to repository - name: "Create Release" on: workflow_dispatch: push: branches: - - 'main' - + - "main" +permissions: + contents: read jobs: - semantic_release: + release: name: Generate Release runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write steps: - name: Checkout Repository uses: actions/checkout@v4 with: fetch-depth: 0 - persist-credentials: false + - name: Build bootJar + run: | + ./gradlew :monitor:bootJar - name: Install Node.js uses: actions/setup-node@v4 with: cache: npm node-version: "lts/*" - - name: Install semantic-release Plugin + - name: Install NodeJS Dependencies run: npm clean-install - - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies + - name: Verify the integrity and registry signatures for dependencies run: npm audit signatures - name: Create Release env: - GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release diff --git a/.github/workflows/run_checks.yml b/.github/workflows/run_checks.yml index 67b496a0..fda6c44a 100644 --- a/.github/workflows/run_checks.yml +++ b/.github/workflows/run_checks.yml @@ -6,11 +6,9 @@ on: workflow_dispatch: pull_request: branches: - - 'main' - + - "main" jobs: lint-commits: - name: Commitlint runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -20,15 +18,14 @@ jobs: persist-credentials: false fetch-depth: 0 - name: Lint Commits - uses: wagoid/commitlint-github-action@v5 - + uses: wagoid/commitlint-github-action@v6 + with: + failOnWarnings: true + failOnErrors: true prettier: - name: Beautify runs-on: ubuntu-latest needs: - lint-commits - outputs: - new_sha: ${{ steps.sha.outputs.SHA }} steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -39,30 +36,25 @@ jobs: uses: actions/setup-node@v4 with: node-version: 21 - - name: Install Prettier - run: npm ci + - name: Install NodeJS Dependencies + run: npm clean-install - name: Run Prettier - run: npx prettier --write ./**/*.{java,md} - - name: Publish Changes - id: commit-and-push - uses: EndBug/add-and-commit@v9.1.4 + run: npx prettier --write "**/*.{md,yaml,js,html,java,properties}" + - name: Commit Changes + id: auto-commit + uses: stefanzweifel/git-auto-commit-action@v4 with: - committer_name: "Prettier Action" - committer_email: "prettier@noreply.github.com" - message: "refactor(style): beautify ${{ github.head_ref }}" - push: true - - name: Update SHA - id: sha + commit_message: "style(all): apply prettier to '${{ github.head_ref }}'" + commit_user_name: github-actions + commit_user_email: action@github.com + commit_author: github-actions + - name: Check For Updated Files + id: check-further-execution + if: steps.auto-commit.outputs.changes_detected =='true' run: | - if [[ "${{ steps.commit-and-push.outputs.pushed }}" == "true" ]]; then - new_sha="${{ steps.commit-and-push.outputs.commit_long_sha }}" - else - new_sha="${{ github.head_ref }}" - fi - echo "SHA=$new_sha" >> $GITHUB_OUTPUT - + echo "Updates detected. Abort Workflow execution!" | + exit 1 unit-tests: - name: Unit Tests runs-on: ubuntu-latest needs: - prettier @@ -73,37 +65,34 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: - ref: ${{ needs.prettier.outputs.new_sha }} + ref: ${{ github.head_ref }} - name: Setup Java environment uses: actions/setup-java@v4 with: distribution: temurin - java-version: 17 + java-version: 22 - name: Setup Gradle uses: gradle/gradle-build-action@v3 - name: Clean Build Artifacts run: ./gradlew clean - name: Run All Integration Tests run: ./gradlew test - integration-tests: - name: Integration Tests runs-on: ubuntu-latest needs: - - prettier - unit-tests steps: - name: Checkout Repository uses: actions/checkout@v4 with: - ref: ${{ needs.prettier.outputs.new_sha }} + ref: ${{ github.head_ref }} - name: Setup Java Environment uses: actions/setup-java@v4 with: distribution: temurin - java-version: 17 + java-version: 22 - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v3 - name: Clean Build Artifacts run: ./gradlew clean - name: Run Integration Tests diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 108dc819..9b41aefe 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -38,16 +38,28 @@