From 1430207afb2cf5d66dc8c0834d00a4d9b3637e9b Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Wed, 30 Oct 2024 13:32:43 +0100 Subject: [PATCH] archive some logs --- .github/workflows/test.yml | 7 +++++++ tests/zzz_test.py | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/zzz_test.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d62026..5a45a4c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,3 +57,10 @@ jobs: ansible-playbook playbooks/deploy.yaml - name: Run tests run: ./run_tests + - name: Upload logs + uses: actions/upload-artifact@v4 + if: ${{ always() }} + with: + name: logs + path: logs.tar.gz + retention-days: 5 diff --git a/tests/zzz_test.py b/tests/zzz_test.py new file mode 100644 index 0000000..e55c331 --- /dev/null +++ b/tests/zzz_test.py @@ -0,0 +1,8 @@ +def test_collect_report(host): + host.run('mkdir -p logs') + for container, filename in [('foreman', '/var/log/foreman/production.log')]: + localfile = filename.replace('/', '_') + host.run(f'podman cp {container}:{filename} logs/{container}-{localfile}') + host.run('tar caf logs.tar.gz logs/') + with open('logs.tar.gz', 'wb') as logstar: + logstar.write(host.file('logs.tar.gz').content)