From e6e33e35c09027ebb932a76a4e82f5d6a21c93cf Mon Sep 17 00:00:00 2001 From: Kostas Stamatakis Date: Thu, 21 Mar 2024 16:04:49 +0200 Subject: [PATCH] message --- .github/actions/docker-images/action.yml | 11 +++++--- .github/actions/k8s-ci/action.yml | 13 ++++------ .github/workflows/ci.yml | 32 +++++++++++++++++++++++- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.github/actions/docker-images/action.yml b/.github/actions/docker-images/action.yml index 784bfed8d9..cb6aade822 100644 --- a/.github/actions/docker-images/action.yml +++ b/.github/actions/docker-images/action.yml @@ -54,7 +54,7 @@ runs: uses: actions/cache@v4 with: path: /tmp/docker-images/ - key: ci-docker-images-${{ runner.os }}-${{ runner.arch }}-${{ github.workflow }}-${{ inputs.container-image-suffix }} + key: ci-docker-images-${{ runner.os }}-${{ runner.arch }}-${{ github.workflow }}-${{ github.head_ref || github.ref_name }} - name: Build cloudbeat-docker image uses: docker/build-push-action@v5 @@ -65,7 +65,8 @@ runs: tags: cloudbeat:latest cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new - outputs: type=docker,dest=/tmp/docker-images/cloudbeat-${{ inputs.container-image-suffix }}.tar + outputs: type=docker,dest=/tmp/docker-images/cloudbeat.tar + no-cache: false - name: Build elastic-agent uses: docker/build-push-action@v5 @@ -80,8 +81,9 @@ runs: tags: ${{ inputs.elastic-agent-docker-image }}:${{ inputs.elastic-agent-docker-image-tag }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new - outputs: type=docker,dest=/tmp/docker-images/elastic-agent-${{ inputs.container-image-suffix }}.tar + outputs: type=docker,dest=/tmp/docker-images/elastic-agent.tar build-args: ELASTIC_AGENT_IMAGE=docker.elastic.co/beats/elastic-agent:${{ inputs.elastic-agent-docker-image-tag }} + no-cache: false - name: Build pytest-docker uses: docker/build-push-action@v5 @@ -91,7 +93,8 @@ runs: tags: cloudbeat-test:latest cache-from: type=local,mode=max,src=/tmp/.buildx-cache cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new - outputs: type=docker,dest=/tmp/docker-images/pytest-${{ inputs.container-image-suffix }}.tar + outputs: type=docker,dest=/tmp/docker-images/pytest.tar + no-cache: false - name: Rotate cache shell: bash diff --git a/.github/actions/k8s-ci/action.yml b/.github/actions/k8s-ci/action.yml index 8d81b72a27..abde507d17 100644 --- a/.github/actions/k8s-ci/action.yml +++ b/.github/actions/k8s-ci/action.yml @@ -7,7 +7,7 @@ inputs: kind-config: description: 'KIND configuration' required: true - container-image-suffix: + container-image-suffix: # todo: remove description: 'Container image suffix' required: true elastic-agent-docker-image: @@ -48,7 +48,7 @@ runs: uses: actions/cache@v4 with: path: /tmp/docker-images/ - key: ci-docker-images-${{ runner.os }}-${{ runner.arch }}-${{ github.workflow }}-${{ inputs.container-image-suffix }} + key: ci-docker-images-${{ runner.os }}-${{ runner.arch }}-${{ github.workflow }}-${{ github.head_ref || github.ref_name }} - name: Prepare Kind Cluster for Process Tests if: ${{ contains(inputs.kind-config, 'conf2') }} @@ -63,16 +63,13 @@ runs: shell: bash run: just create-kind-cluster ${{ inputs.kind-config }} - # - name: Load images to kind - # shell: bash - # run: ./.ci/scripts/kind-images.sh '${{ inputs.container-image-suffix }}' '${{ inputs.kind-config }}' - name: Load images to kind shell: bash run: | ls -lahR /tmp/docker-images/ - kind load image-archive /tmp/docker-images/cloudbeat-${{ inputs.container-image-suffix }}.tar --name='${{ inputs.kind-config }}' - kind load image-archive /tmp/docker-images/pytest-${{ inputs.container-image-suffix }}.tar --name='${{ inputs.kind-config }}' - kind load image-archive /tmp/docker-images/elastic-agent-${{ inputs.container-image-suffix }}.tar --name='${{ inputs.kind-config }}' + kind load image-archive /tmp/docker-images/cloudbeat.tar --name='${{ inputs.kind-config }}' + kind load image-archive /tmp/docker-images/pytest.tar --name='${{ inputs.kind-config }}' + kind load image-archive /tmp/docker-images/elastic-agent.tar --name='${{ inputs.kind-config }}' - name: Deploy tests Helm chart id: deploy_helm diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9ea0a2ffa..a53cb1a8dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -286,6 +286,8 @@ jobs: name: Upload integration tests results runs-on: ubuntu-22.04 timeout-minutes: 60 + permissions: + pull-requests: write if: ${{ success() || failure() }} steps: - uses: actions/download-artifact@v4 @@ -320,4 +322,32 @@ jobs: bucket: csp-allure-reports prefix: allure_reports/cloudbeat/ci/${{ github.event.number }} ignoreMissingResults: true - debug: true + debug: false + + - name: Allure Summary + if: ${{ success() && github.event_name == 'pull_request' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + jobs=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs) + job_id=$(echo $jobs | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}") | .id') + echo "job_id: ${job_id}" + + allure_summary=$(curl --silent --show-error --fail --location "https://github.com/elastic/cloudbeat/actions/runs/${{ github.run_id }}/jobs/${job_id}/summary_raw") + + # saving result into env variable (with multiline handling) + echo "ALLURE_SUMMARY<> $GITHUB_ENV + echo "$allure_summary" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + + - name: Comment test success result + uses: marocchino/sticky-pull-request-comment@v2 + if: ${{ success() && github.event_name == 'pull_request' }} + with: + header: CI Test Results + number: ${{ github.event.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + message: | + ${{ env.ALLURE_SUMMARY }}