diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..da9c46c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,132 @@ +name: CI Pipeline + +on: + push: + branches: + - main + pull_request: + branches: + - "**" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: "graalvm" + java-version: "21" + - name: Cache Gradle Packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + - name: Build Project + run: ./gradlew assemble + env: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + + pmd: + name: PMD Analysis + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: "graalvm" + java-version: "21" + - name: Cache Gradle Packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + - name: Run PMD Analysis + run: ./gradlew pmdMain + + checkstyle: + name: Checkstyle Analysis + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: "graalvm" + java-version: "21" + - name: Cache Gradle Packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + - name: Run Checkstyle + run: ./gradlew checkstyleMain + + unit-test: + name: Unit Tests + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: "graalvm" + java-version: "21" + - name: Cache Gradle Packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + - name: Run Unit Tests + run: ./gradlew test + + tests-terminated: + name: test end node + runs-on: ubuntu-latest + needs: [build, pmd, checkstyle, unit-test] + steps: + - run: echo "finished test stage" # this is a indirection to the previous test steps + + docker-image-native: + name: Docker image native + if: github.event_name == 'push' && github.ref_name == 'main' + needs: [tests-terminated] + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Build and Push Image + uses: explorviz/deployment/.github/actions/build-and-deploy-quarkus-native@main + with: + platforms: "linux/amd64,linux/arm64/v8" + docker-username: ${{ secrets.DOCKER_USERNAME }} + docker-password: ${{ secrets.DOCKER_PASSWORD }} + image-name: ${{ vars.DOCKER_NATIVE_IMAGE_NAME }} + image-tag: "latest" + + docker-image-jvm: + name: Docker image JVM + if: github.event_name == 'push' && github.ref_name == 'main' + needs: [tests-terminated] + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Build and Push Image + uses: explorviz/deployment/.github/actions/build-and-deploy-quarkus-jvm@main + with: + platforms: "linux/amd64,linux/arm64/v8" + docker-username: ${{ secrets.DOCKER_USERNAME }} + docker-password: ${{ secrets.DOCKER_PASSWORD }} + image-name: ${{ vars.DOCKER_JVM_IMAGE_NAME }} + image-tag: "latest" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee99cc0..e49ddd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,6 @@ stages: - coverage - visualize - deploy:images - - deploy:retagging build: stage: build @@ -103,20 +102,6 @@ coverage: coverage_format: cobertura path: build/cobertura.xml -push-dockerhub-native-main-amd64: - extends: .build-and-deploy-quarkus-native - variables: - IMAGE_TAG: "amd64" - -push-dockerhub-native-main-arm64: - extends: .build-and-deploy-quarkus-native - rules: - - if: $MULTI_ARCH_BUILD || $ARM64_BUILD - variables: - IMAGE_TAG: "arm64" - tags: - - arm64 - push-dockerhub-native-mr: extends: .build-and-deploy-quarkus-native rules: @@ -124,44 +109,9 @@ push-dockerhub-native-mr: variables: IMAGE_TAG: mr-${CI_MERGE_REQUEST_IID}-native -push-dockerhub-main-amd64: - extends: .build-and-deploy-quarkus-jvm - variables: - IMAGE_TAG: "amd64" - -push-dockerhub-main-arm64: - extends: .build-and-deploy-quarkus-jvm - rules: - - if: $MULTI_ARCH_BUILD || $ARM64_BUILD - variables: - IMAGE_TAG: "arm64" - tags: - - arm64 - push-dockerhub-mr: extends: .build-and-deploy-quarkus-jvm rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" variables: IMAGE_TAG: mr-${CI_MERGE_REQUEST_IID}-jvm - -retag-amd64-as-latest-jvm: - extends: .retag-dockerhub-image - variables: - SOURCE_TAG: "amd64" - TARGET_TAG: "latest" - -retag-amd64-as-latest-native: - extends: .retag-dockerhub-image - variables: - IMAGE_NAME: $DOCKERHUB_IMAGE_NAME_NATIVE - SOURCE_TAG: "amd64" - TARGET_TAG: "latest" - -publish-multi-arch-manifest-jvm: - extends: .retag-as-multi-arch-dockerhub-image - -publish-multi-arch-manifest-native: - extends: .retag-as-multi-arch-dockerhub-image - variables: - IMAGE_NAME: $DOCKERHUB_IMAGE_NAME_NATIVE