From 099c8b1e1243011b91e6f35c6adef9823005b7a4 Mon Sep 17 00:00:00 2001 From: Jingwei Wang Date: Mon, 25 Nov 2024 16:00:26 -0800 Subject: [PATCH] Squashed commit message for the first 10 commits --- .github/workflows/e2e-linux.yaml | 41 ++++++++++++++++++++++++++++++ .github/workflows/e2e-macos.yaml | 36 +++++++++++++++++++++++--- .github/workflows/e2e-windows.yaml | 32 ++++++++++++++++++++++- Makefile | 9 ++++--- 4 files changed, 111 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-linux.yaml b/.github/workflows/e2e-linux.yaml index ee3d3c1ff..e84d5000b 100644 --- a/.github/workflows/e2e-linux.yaml +++ b/.github/workflows/e2e-linux.yaml @@ -90,6 +90,9 @@ jobs: sudo systemctl start finch.service sudo systemctl start finch-buildkit.service sudo systemctl start finch-soci.service + - name: Set up REPORT_DIR + run: | + echo "REPORT_DIR=${{ github.workspace }}/reports" >> $GITHUB_ENV - name: Run e2e tests run: | git status @@ -98,6 +101,44 @@ jobs: eval "$(ssh-agent -s)" INSTALLED=true REGISTRY=${{ steps.vars.outputs.has_creds == true && env.REGISTRY || '' }} sudo -E make test-e2e-container INSTALLED=true REGISTRY=${{ steps.vars.outputs.has_creds == true && env.REGISTRY || '' }} sudo -E make test-e2e-vm + - name: Change ownership of reports + if: always() + run: | + if [ ! -d "$REPORT_DIR" ]; then + echo "Error: Directory $REPORT_DIR does not exist." + exit 1 + fi + + USER=$(whoami) + GROUP=$(id -gn) + + if sudo chown -R "$USER:$GROUP" "$REPORT_DIR"; then + echo "Ownership of $REPORT_DIR changed to $USER:$GROUP" + else + echo "Error: Failed to change ownership of $REPORT_DIR" + exit 1 + fi + - name: Check and upload e2e tests reports to s3 bucket + if: ${{ steps.vars.outputs.has_creds == true && (!(startsWith(inputs.os, 'amazon') && inputs.version == '2' ))}} + run: | + VM_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json" + CONTAINER_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json" + + if [ -f "$VM_REPORT" ]; then + echo "VM report file exists. Uploading to S3..." + aws s3 cp "$VM_REPORT" "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json" + echo "VM report uploaded successfully." + else + echo "VM report file does not exist. Skipping upload." + fi + + if [ -f "$CONTAINER_REPORT" ]; then + echo "Container report file exists. Uploading to S3..." + aws s3 cp "$CONTAINER_REPORT" "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json" + echo "Container report uploaded successfully." + else + echo "Container report file does not exist. Skipping upload." + fi - name: Clean up repo AL2 if: ${{ (startsWith(inputs.os, 'amazon') && inputs.version == '2' && always() ) }} run: | diff --git a/.github/workflows/e2e-macos.yaml b/.github/workflows/e2e-macos.yaml index 9e011d988..ff201de2c 100644 --- a/.github/workflows/e2e-macos.yaml +++ b/.github/workflows/e2e-macos.yaml @@ -53,11 +53,11 @@ jobs: echo "has_creds=$has_creds" >> $GITHUB_OUTPUT - name: configure aws credentials uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 - if: ${{ steps.vars.outputs.has_creds == true }} + if: ${{ steps.vars.outputs.has_creds == 'true' }} with: role-to-assume: ${{ secrets.ROLE }} role-session-name: credhelper-test - aws-region: ${{ secrets.REGION }} + aws-region: ${{ secrets.REGION }} - name: Clean up previous files run: | sudo rm -rf /opt/finch @@ -68,7 +68,7 @@ jobs: fi if pgrep '^socket_vmnet'; then sudo pkill '^socket_vmnet' - fi + fi - name: Install Rosetta 2 run: echo "A" | softwareupdate --install-rosetta || true - run: brew install lz4 automake autoconf libtool yq @@ -84,3 +84,33 @@ jobs: git clean -f -d REGISTRY=${{ steps.vars.outputs.has_creds == true && env.REGISTRY || '' }} make ${{ inputs.test-command }} shell: zsh {0} + - name: Check and upload e2e tests reports to s3 bucket + if: always() + run: | + VM_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json" + CONTAINER_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json" + VM_SERIAL_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json" + + if [ -f "$VM_REPORT" ]; then + echo "VM report file exists. Uploading to S3..." + aws s3 cp "$VM_REPORT" "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json" + echo "VM report uploaded successfully." + else + echo "VM report file does not exist. Skipping upload." + fi + + if [ -f "$CONTAINER_REPORT" ]; then + echo "Container report file exists. Uploading to S3..." + aws s3 cp "$CONTAINER_REPORT" "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json" + echo "Container report uploaded successfully." + else + echo "Container report file does not exist. Skipping upload." + fi + + if [ -f "$VM_SERIAL_REPORT" ]; then + echo "VM serial report file exists. Uploading to S3..." + aws s3 cp "$VM_SERIAL_REPORT" "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json" + echo "VM serial report uploaded successfully." + else + echo "VM serial report file does not exist. Skipping upload." + fi \ No newline at end of file diff --git a/.github/workflows/e2e-windows.yaml b/.github/workflows/e2e-windows.yaml index e3312483a..5217e9ec8 100644 --- a/.github/workflows/e2e-windows.yaml +++ b/.github/workflows/e2e-windows.yaml @@ -59,7 +59,7 @@ jobs: with: role-to-assume: ${{ secrets.ROLE }} role-session-name: credhelper-test - aws-region: ${{ secrets.REGION }} + aws-region: ${{ secrets.REGION }} - name: Remove Finch VM timeout-minutes: 2 run: ./scripts/cleanup_wsl.ps1 @@ -89,6 +89,36 @@ jobs: git status git clean -f -d make ${{ inputs.test-command }} + - name: Check and upload e2e tests reports to s3 bucket + if: ${{ always() }} + run: | + $VM_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json" + $CONTAINER_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json" + $VM_SERIAL_REPORT="${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json" + + if (Test-Path $VM_REPORT) { + Write-Host "VM report file exists. Uploading to S3..." + aws s3 cp $VM_REPORT "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json" + Write-Host "VM report uploaded successfully." + } else { + Write-Host "VM report file does not exist. Skipping upload." + } + + if (Test-Path $CONTAINER_REPORT) { + Write-Host "Container report file exists. Uploading to S3..." + aws s3 cp $CONTAINER_REPORT "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json" + Write-Host "Container report uploaded successfully." + } else { + Write-Host "Container report file does not exist. Skipping upload." + } + + if (Test-Path $VM_SERIAL_REPORT) { + Write-Host "VM serial report file exists. Uploading to S3..." + aws s3 cp $VM_SERIAL_REPORT "s3://finch-e2e-test-log-reports/${{ inputs.os }}-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json.json" + Write-Host "VM serial report uploaded successfully." + } else { + Write-Host "VM serial report file does not exist. Skipping upload." + } - name: Remove Finch VM and Clean Up Previous Environment if: ${{ always() }} timeout-minutes: 2 diff --git a/Makefile b/Makefile index 47a05cac1..933780b41 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ DEST := $(shell echo "$(DESTDIR)/$(PREFIX)" | sed 's:///*:/:g; s://*$$::') BINDIR ?= /usr/local/bin OUTDIR ?= $(CURDIR)/_output OS_OUTDIR ?= $(OUTDIR)/os +REPORT_DIR ?= $(CURDIR)/reports +RUN_ID ?= $(GITHUB_RUN_ID) +RUN_ATTEMPT ?= $(GITHUB_RUN_ATTEMPT) OUTPUT_DIRECTORIES := $(OUTDIR) $(OS_OUTDIR) $(OUTPUT_DIRECTORIES): @@ -266,15 +269,15 @@ test-e2e: test-e2e-vm-serial test-e2e-container .PHONY: test-e2e-vm-serial test-e2e-vm-serial: - go test -ldflags $(LDFLAGS) -timeout 2h ./e2e/vm -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 --installed="$(INSTALLED)" + go test -ldflags $(LDFLAGS) -timeout 2h ./e2e/vm -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR)/$(RUN_ID)-$(RUN_ATTEMPT)-e2e-vm-serial-report.json --installed="$(INSTALLED)" .PHONY: test-e2e-container test-e2e-container: - go test -ldflags $(LDFLAGS) -timeout 2h ./e2e/container -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 --installed="$(INSTALLED)" + go test -ldflags $(LDFLAGS) -timeout 2h ./e2e/container -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR)/$(RUN_ID)-$(RUN_ATTEMPT)-e2e-container-report.json --installed="$(INSTALLED)" .PHONY: test-e2e-vm test-e2e-vm: - go test -ldflags $(LDFLAGS) -timeout 2h ./e2e/vm -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 --installed="$(INSTALLED)" --registry="$(REGISTRY)" + go test -ldflags $(LDFLAGS) -timeout 2h ./e2e/vm -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR)/$(RUN_ID)-$(RUN_ATTEMPT)-e2e-vm-report.json --installed="$(INSTALLED)" --registry="$(REGISTRY)" .PHONY: test-benchmark test-benchmark: