Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload test logs #6675

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,23 @@ jobs:
secret/data/github/repo/${{ github.repository }}/aws/rke2-ci-uploader/credentials AWS_ACCESS_KEY_ID ;
secret/data/github/repo/${{ github.repository }}/aws/rke2-ci-uploader/credentials AWS_SECRET_ACCESS_KEY ;
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
run: dapper -f Dockerfile --target dapper make dapper-ci
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
- name: Test
run: dapper -f Dockerfile --target dapper make test
- name: Prepare Test Logs on Failure
if: ${{ failure() }}
run: |
dapper -f Dockerfile --target dapper make test
sudo cp -r /tmp/rke2-logs ~/rke2-logs
sudo chown -R $USER:$USER ~/rke2-logs
- name: Upload Test Logs on Failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: rke2-test-logs
path: ~/rke2-logs/
build-arm64:
runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
steps:
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ jobs:
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
run: dapper -f Dockerfile --target dapper make dapper-ci
- name: Test
run: dapper -f Dockerfile --target dapper make test
- name: Prepare Test Logs on Failure
if: ${{ failure() }}
run: |
dapper -f Dockerfile --target dapper make test
sudo cp -r /tmp/rke2-logs ~/rke2-logs
sudo chown -R $USER:$USER ~/rke2-logs
ls -la ~/rke2-logs
- name: Upload Logs on Failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: rke2-test-logs
path: ~/rke2-logs/
build-arm64:
runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
steps:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN zypper install -y systemd-rpm-macros

# Dapper/Drone/CI environment
FROM build AS dapper
ENV DAPPER_ENV GODEBUG GOCOVER REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY DOCKER_USERNAME DOCKER_PASSWORD GH_TOKEN
ENV DAPPER_ENV GODEBUG CI GOCOVER REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY DOCKER_USERNAME DOCKER_PASSWORD GH_TOKEN
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./dist ./bin ./build
Expand Down
19 changes: 18 additions & 1 deletion scripts/test-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export -f verify-valid-versions
# ---

dump-logs() {
# Reduce verbosity in GitHub Actions
if [ "$CI" = "true" ]; then
set +x
fi
local testID=$(basename $TEST_DIR)
echo "#---------------------------------"
echo "#- Begin: logs for run ($testID)"
Expand All @@ -141,6 +145,13 @@ dump-logs() {
docker exec $name crictl pods >$node/logs/crictl-pods.txt
docker exec $name crictl ps -a >$node/logs/crictl-ps.txt
fi
done
# In GitHub Actions, don't dump logs to the console, as they will be uploaded as artifacts
if [ "$CI" = "true" ]; then
set -x
return
fi
for node in $TEST_DIR/*/*; do
for log in $node/logs/*.log; do
echo
echo "#- Tail: $log"
Expand Down Expand Up @@ -279,7 +290,13 @@ export -f test-cleanup
# ---

test-setup() {
export TEST_DIR=$(mktemp -d '/tmp/XXXXXX')
# If running in Github Actions, use a known directory, so we can upload logs external to this script
if [ "$CI" = 'true' ]; then
mkdir -p /tmp/rke2-logs
export TEST_DIR=$(mktemp -d '/tmp/rke2-logs/XXXXXX')
else
export TEST_DIR=$(mktemp -d '/tmp/XXXXXX')
fi
trap test-cleanup EXIT INT TERM

mkdir -p $TEST_DIR/metadata
Expand Down
Loading