diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 75c5497cef..71f7bcddaf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3eb84d1e96..dc63d41378 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -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: diff --git a/Dockerfile b/Dockerfile index af94503f32..d6d49b63d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/scripts/test-helpers b/scripts/test-helpers index 7f1d86d02f..dc44358725 100755 --- a/scripts/test-helpers +++ b/scripts/test-helpers @@ -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)" @@ -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" @@ -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