From 9baa2b6eeb24ad952cb6757b6d558810fdd8c11d Mon Sep 17 00:00:00 2001 From: Fabio Burzigotti <34456377+fabiobrz@users.noreply.github.com> Date: Thu, 9 Jan 2025 08:06:34 +0100 Subject: [PATCH] [issue-1343] - Improve GitHub workflow for CI checks (#1341) --- .circleci/config.yml | 77 --------------------- .github/workflows/maven.yml | 133 ++++++++++++++++++++++++------------ 2 files changed, 89 insertions(+), 121 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 91e9eae23..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,77 +0,0 @@ -version: 2.1 - -commands: - mvn-build: - parameters: - category: - type: enum - enum: ["docker", "kubernetes", "openshift"] - steps: - - run: - name: "Maven pre-fetch dependencies" - command: ./mvnw verify -q -U -DskipTests # pre-fetch dependencies (dependency:resolve fails) - - when: - condition: - equal: [ docker, << parameters.category >> ] - steps: - - run: - name: "Maven build for Docker" - command: ./mvnw clean package -Dfailsafe.groups=org.arquillian.cube.docker.impl.requirement.RequiresDocker -Dcontainerless.skip.tests=true - - when: - condition: - equal: [ kubernetes, << parameters.category >> ] - steps: - - run: - name: "Maven build for Kubernetes" - command: ./mvnw clean package -Dfailsafe.groups=org.arquillian.cube.docker.impl.requirement.RequiresDocker - - when: - condition: - equal: [ openshift, << parameters.category >> ] - steps: - - run: - name: "Maven build for OpenShift" - command: ./mvnw clean package -Dfailsafe.groups=org.arquillian.cube.docker.impl.requirement.RequiresDocker - -jobs: - build: - parameters: - jdk-version: - type: string - category: - type: enum - enum: ["docker", "kubernetes", "openshift"] - working_directory: ~/circleci-arquillian-cube - docker: - - image: cimg/openjdk:<< parameters.jdk-version >> - steps: - - checkout - - setup_remote_docker: - version: docker24 - docker_layer_caching: true - - restore_cache: - key: circleci-arquillian-cube-{{ checksum "pom.xml" }} - - run: - name: "Change owner of /var/run/docker.sock to circleci for local CLI builds" - command: | - if [[ $CIRCLE_SHELL_ENV == *"localbuild"* ]]; then - echo 'Changing owner of /var/run/docker.sock to circleci' - sudo chown circleci /var/run/docker.sock - fi - - mvn-build: - category: << parameters.category >> - - store_test_results: - path: target/surefire-reports - - save_cache: - paths: - - ~/.m2 - key: circleci-arquillian-cube-{{ checksum "pom.xml" }} - -workflows: - version: 2.1 - circleci_build: - jobs: - - build: - matrix: - parameters: - jdk-version: ["11.0"] # TODO: Add JDK 11.0 when builds for JDK8 work - category: ["docker"] # TODO: Add builds for kubernetes and openshift diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 57eaef894..c53d2a776 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -8,28 +8,53 @@ on: branches: - main paths-ignore: - - 'doc/**' - - '.circleci/**' -env: - DOCKER_HOST: 'unix:///var/run/docker.sock' + - 'docs/**' jobs: - build: - runs-on: ubuntu-20.04 + docker-it: + runs-on: ubuntu-latest + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + java: ['11'] + steps: + - name: Checkout arquillian-cube + uses: actions/checkout@v4 + - name: Cache .m2 registry + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: docker-it-cache-e2e-${{ github.sha }}-${{ github.run_id }} + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + - name: Maven pre-fetch dependencies ${{ matrix.java }} + run: | + ./mvnw clean install -q -U -DskipTests + - name: Build and run integration tests for Docker target (${{ matrix.java }}) + run: | + ./mvnw verify -B -Dfailsafe.groups=org.arquillian.cube.docker.impl.requirement.RequiresDocker -Dcontainerless.skip.tests=true + - uses: actions/upload-artifact@v4 + with: + name: docker-it-surefire-reports-jdk-${{ matrix.java }} + path: | + '${{ github.workspace }}/**/surefire-reports/*.*' + '${{ github.workspace }}/**/*.log' + + k8s-it: + runs-on: ubuntu-latest timeout-minutes: 90 strategy: fail-fast: false matrix: java: ['11'] - target: ['docker', 'kubernetes', 'openshift'] - env: - # failsafe.groups configuration depends on the env setup. - FAILSAFE_GROUPS: '' steps: - name: Checkout arquillian-cube uses: actions/checkout@v4 - name: Setup Minikube - if: ${{ matrix.target == 'kubernetes' }} uses: manusa/actions-setup-minikube@v2.13.0 with: driver: docker @@ -39,35 +64,69 @@ jobs: github token: ${{ secrets.GITHUB_TOKEN }} start args: "--memory='4gb' --cpus='2'" - name: Enable minikube registry - if: ${{ matrix.target == 'kubernetes' }} run: | minikube addons enable registry kubectl port-forward --namespace kube-system service/registry 5000:80 & + - name: Cache .m2 registry + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: k8s-it-cache-e2e-${{ github.sha }}-${{ github.run_id }} + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + - name: Maven pre-fetch dependencies ${{ matrix.java }} + run: | + ./mvnw clean install -q -U -DskipTests + - name: Build and run integration tests for Kubernetes target (${{ matrix.java }}) + run: | + ./mvnw verify -B -Dfailsafe.groups=org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes -Dcontainerless.skip.tests=true + - uses: actions/upload-artifact@v4 + with: + name: k8s-it-surefire-reports-jdk-${{ matrix.java }} + path: | + '${{ github.workspace }}/**/surefire-reports/*.*' + '${{ github.workspace }}/**/*.log' + - name: Stop minikube + run: | + minikube stop + + openshift-it: + runs-on: ubuntu-20.04 + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + java: ['11'] + steps: + - name: Checkout arquillian-cube + uses: actions/checkout@v4 - name: Setup OpenShift - if: ${{ matrix.target == 'openshift' }} uses: manusa/actions-setup-openshift@v1.1.5 with: oc version: 'v3.10.0' github token: ${{ secrets.GITHUB_TOKEN }} -# - name: Setup OLM on OpenShift v3.z -# if: ${{ matrix.target == 'openshift' }} -# run: | -# set -x -# # operator-sdk must be installed manually on OpenShift v3 -# oc version -# oc create -f https://github.com/operator-framework/operator-lifecycle-manager/tree/master/deploy/upstream/manifests/0.6.0/ -# # OR... -# export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac) -# export OS=$(uname | awk '{print tolower($0)}') -# export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.37.0 -# curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH} -# chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk -# operator-sdk olm install + # TODO - there are issues when installing OLM on OpenShift v3, and we're aiming at having CI running on OpenShift 4, actually... + # - name: Setup OLM on OpenShift v3.z + # run: | + # set -x + # # operator-sdk must be installed manually on OpenShift v3 + # oc version + # oc create -f https://github.com/operator-framework/operator-lifecycle-manager/tree/master/deploy/upstream/manifests/0.6.0/ + # # OR... + # export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac) + # export OS=$(uname | awk '{print tolower($0)}') + # export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.37.0 + # curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH} + # chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk + # operator-sdk olm install - name: Cache .m2 registry uses: actions/cache@v4 with: path: ~/.m2/repository - key: cache-e2e-${{ github.sha }}-${{ github.run_id }} + key: openshift-it-cache-e2e-${{ github.sha }}-${{ github.run_id }} - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v4 with: @@ -76,26 +135,12 @@ jobs: - name: Maven pre-fetch dependencies ${{ matrix.java }} run: | ./mvnw clean install -q -U -DskipTests - - name: Build and run integration tests for Docker target (${{ matrix.java }}) - if: ${{ matrix.target == 'docker' }} - run: | - ./mvnw verify -Dfailsafe.groups=org.arquillian.cube.docker.impl.requirement.RequiresDocker -Dcontainerless.skip.tests=true - - name: Build and run integration tests for Kubernetes target (${{ matrix.java }}) - if: ${{ matrix.target == 'kubernetes' }} - run: | - ./mvnw verify -Dfailsafe.groups=org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes -Dcontainerless.skip.tests=true - name: Build and run integration tests for OpenShift target (${{ matrix.java }}) - if: ${{ matrix.target == 'openshift' }} run: | - ./mvnw verify -pl openshift -amd -Dfailsafe.groups=org.arquillian.cube.openshift.impl.requirement.RequiresOpenshift -Dfailsafe.excludedGroups=org.arquillian.cube.openshift.impl.requirement.RequiresOpenshift4 -Dcontainerless.skip.tests=true + ./mvnw verify -B -Dfailsafe.groups=org.arquillian.cube.openshift.impl.requirement.RequiresOpenshift -Dfailsafe.excludedGroups=org.arquillian.cube.openshift.impl.requirement.RequiresOpenshift4 -Dcontainerless.skip.tests=true - uses: actions/upload-artifact@v4 - if: failure() with: - name: surefire-reports-jdk-${{ matrix.java }} + name: openshift-it-surefire-reports-jdk-${{ matrix.java }} path: | '${{ github.workspace }}/**/surefire-reports/*.*' '${{ github.workspace }}/**/*.log' - - name: Stop minikube - if: ${{ matrix.target == 'kubernetes' }} - run: | - minikube stop