From 202711d2de24d37273d1c1a3e35af67f405bab82 Mon Sep 17 00:00:00 2001 From: VOID404 Date: Fri, 6 Sep 2024 08:33:16 +0200 Subject: [PATCH 1/3] Extract artifacts names to vars --- .github/workflows/compass-manager.yaml | 33 +++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/compass-manager.yaml b/.github/workflows/compass-manager.yaml index 59e58c5..a037d9f 100644 --- a/.github/workflows/compass-manager.yaml +++ b/.github/workflows/compass-manager.yaml @@ -29,6 +29,10 @@ permissions: id-token: write # This is required for requesting the JWT token contents: read # This is required for actions/checkout +env: + unit-test-log: unit-test.log + trivy-table: trivy-table.txt + jobs: setup: permissions: @@ -80,13 +84,13 @@ jobs: cache-dependency-path: go.sum go-version-file: go.mod - name: Run unit tests - run: make test | tee unit-test.log + run: make test | tee ${{ env.unit-test-log }} - name: Upload test logs artifact uses: actions/upload-artifact@v4 if: success() || failure() with: - name: unit-test.log - path: test.log + name: ${{ env.unit-test-log }} + path: ${{ env.unit-test-log }} trivy: permissions: @@ -118,14 +122,15 @@ jobs: vuln-type: "os,library" format: table - output: "trivy-results.txt" + output: ${{ env.trivy-table }} - name: Upload trivy table if: success() || failure() uses: actions/upload-artifact@v4 with: - name: trivy-results.txt - path: trivy-results.txt + name: ${{ env.trivy-table }} + path: ${{ env.trivy-table }} + build-image: needs: setup uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main # Usage: kyma-project/test-infra/.github/workflows/image-builder.yml@main @@ -144,28 +149,28 @@ jobs: uses: actions/download-artifact@v4 continue-on-error: true with: - name: test.log + name: ${{ env.unit-test-log }} - name: "Download trivy log" uses: actions/download-artifact@v4 continue-on-error: true with: - name: trivy-results.txt + name: ${{ env.trivy-table }} - name: "Generate summary" run: | { echo '# Compass Manager' - # if trivy-results.txt exists - if [ -f trivy-results.txt ]; then + # if trivy results table exists + if [ -f ${{ env.trivy-table }} ]; then echo '## Trivy' printf '\n```txt\n' - cat trivy-results.txt + cat ${{ env.trivy-table }} printf '\n```\n' fi - # if test.log exists - if [ -f test.log ]; then + # if test log exists + if [ -f ${{ env.unit-test-log }} ]; then echo '## Unit Tests' printf '\n```\n' - cat test.log + cat ${{ env.unit-test-log }}} printf '\n```\n' fi # if build-image was successful From bd0230a98991e48404cd7be7717c450fdd349a6c Mon Sep 17 00:00:00 2001 From: VOID404 Date: Fri, 6 Sep 2024 08:34:46 +0200 Subject: [PATCH 2/3] Add folding to logs --- .github/workflows/compass-manager.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compass-manager.yaml b/.github/workflows/compass-manager.yaml index a037d9f..887d191 100644 --- a/.github/workflows/compass-manager.yaml +++ b/.github/workflows/compass-manager.yaml @@ -169,9 +169,9 @@ jobs: # if test log exists if [ -f ${{ env.unit-test-log }} ]; then echo '## Unit Tests' - printf '\n```\n' + printf '
\nclick to expand logs\n```\n' cat ${{ env.unit-test-log }}} - printf '\n```\n' + printf '\n```\n
\n' fi # if build-image was successful if [ "${{ needs.build-image.result }}" == "success" ]; then From 87b932d853f1a7b006d15862703576d384110839 Mon Sep 17 00:00:00 2001 From: VOID404 Date: Fri, 6 Sep 2024 08:35:18 +0200 Subject: [PATCH 3/3] Add trivy table to logs --- .github/workflows/compass-manager.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/compass-manager.yaml b/.github/workflows/compass-manager.yaml index 887d191..ad39bdf 100644 --- a/.github/workflows/compass-manager.yaml +++ b/.github/workflows/compass-manager.yaml @@ -131,6 +131,10 @@ jobs: name: ${{ env.trivy-table }} path: ${{ env.trivy-table }} + - name: Print trivy table + if: success() || failure() + run: cat ${{ env.trivy-table }} + build-image: needs: setup uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main # Usage: kyma-project/test-infra/.github/workflows/image-builder.yml@main