Skip to content

Commit

Permalink
Gather environment on e2e workflow errors
Browse files Browse the repository at this point in the history
If any build step fails, try to gather the environment and upload the
gathered data as build artifacts.

The gathered data will be kept for 15 days (instead of the default 90
days) to minimize storage usage.

We manually tar the gathered data for 2 reasons:
- Avoid github limitations with special characters (:) in file names
- Get much better compression compared to zip (6m instead of 12m)

GitHub supports only zip format when downloading artifacts. You will
download a tar.gz file wrapped in a zip archive. On macOS this is
extracted automatically in one step. On Linux you will have to extract
twice and delete the .zip and .tar.gz files.

[1] actions/upload-artifact#546

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Jul 24, 2024
1 parent 7de6a0c commit b15991d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
NAME_PREFIX: "rdr-"
# Limit number of drenv workers.
MAX_WORKERS: 4
GATHER_DIR: gather.${{ github.run_id }}-${{ github.run_attempt }}

jobs:
e2e-rdr:
Expand Down Expand Up @@ -68,6 +69,29 @@ jobs:
cat ~/.config/drenv/${{ env.NAME_PREFIX }}rdr/config.yaml >> e2e/config.yaml
make e2e-rdr
- name: Gather environment data
if: failure()
working-directory: test
run: drenv gather --directory ${{ env.GATHER_DIR }} --name-prefix ${{ env.NAME_PREFIX }} envs/regional-dr.yaml

# Tar manually to work around github limitations with special chracters (:)
# in file names, and getting much smaller archives comapred with zip (6m vs
# 12m).
# https://github.com/actions/upload-artifact/issues/546
- name: Archive gathered data
if: failure()
working-directory: test
run: tar czf ${{ env.GATHER_DIR }}.tar.gz ${{ env.GATHER_DIR }}

- name: Upload artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{ env.GATHER_DIR }}
path: test/${{ env.GATHER_DIR }}.tar.gz
compression-level: 0
retention-days: 15

- name: Delete clusters
if: always()
working-directory: test
Expand Down

0 comments on commit b15991d

Please sign in to comment.