From 155ba95f0d357974fccd633d9128a4a3bb8379c2 Mon Sep 17 00:00:00 2001 From: Jitendrakumar Kushavah <78074038+jitendra-kushavah@users.noreply.github.com> Date: Fri, 4 Jul 2025 12:10:31 +0530 Subject: [PATCH] Workflow for upload local allure report to s3 (#1055) * Added workflow file for upload manual allure report to s3 for testing purpose Signed-off-by: jitendra-kushavah * Modified the file as per existing code stucture Signed-off-by: jitendra-kushavah * Added code for upload manual report to S3 Signed-off-by: jitendra-kushavah * Added option for multiple drive links Signed-off-by: jitendra-kushavah * Modified the description Signed-off-by: jitendra-kushavah --------- Signed-off-by: jitendra-kushavah --- .../manual-allure-report-to-s3/action.yml | 72 ++++++++++ .github/workflows/manual_reports_to_s3.yml | 131 ++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 .github/actions/manual-allure-report-to-s3/action.yml create mode 100644 .github/workflows/manual_reports_to_s3.yml diff --git a/.github/actions/manual-allure-report-to-s3/action.yml b/.github/actions/manual-allure-report-to-s3/action.yml new file mode 100644 index 000000000..bf1bf6ff8 --- /dev/null +++ b/.github/actions/manual-allure-report-to-s3/action.yml @@ -0,0 +1,72 @@ +name: upload report to S3 +description: upload an Allure report to AWS S3 and update the latest reference + +inputs: + test_type: + description: test type of the report + required: true + testbed: + description: "AP model name (cig_wf186h,edgecore_eap104,cig_wf196,etc)" + required: true + report_path: + description: path to the Allure report folder + required: true + s3_access_key_id: + description: AWS access key ID to access S3 bucket + required: true + s3_access_key_secret: + description: AWS access key secret to access S3 bucket + required: true + username: + description: "User who uploaded the report" + required: true + default: "Jitendra" + +runs: + using: "composite" + steps: + - name: install AWS cli + uses: unfor19/install-aws-cli-action@v1 + + - name: upload report to AWS S3 + env: + AWS_S3_BUCKET_NAME: openwifi-allure-reports + AWS_ACCOUNT_ID: "289708231103" + AWS_ACCESS_KEY_ID: ${{ inputs.s3_access_key_id }} + AWS_SECRET_ACCESS_KEY: ${{ inputs.s3_access_key_secret }} + AWS_DEFAULT_REGION: us-east-1 + AWS_DEFAULT_OUTPUT: json + shell: bash + run: | + S3_PATH="manual-tests/${{ inputs.username }}/${{ inputs.test_type }}/${{ inputs.testbed }}/${{ github.run_number }}" + aws s3 cp --acl public-read --recursive ${{ inputs.report_path }} s3://${AWS_S3_BUCKET_NAME}/${S3_PATH} + + - name: set annotation + shell: bash + env: + AWS_S3_BUCKET_WEBSITE_BASE_URL: http://openwifi-allure-reports.s3-website-us-east-1.amazonaws.com + run: | + echo "::notice title=Report uploaded::The test report has been uploaded to ${AWS_S3_BUCKET_WEBSITE_BASE_URL}/manual-tests/${{ inputs.username }}/${{ inputs.test_type }}/${{ inputs.testbed }}/${{ github.run_number }}/" + + - name: update reference to latest report + env: + AWS_S3_BUCKET_NAME: openwifi-allure-reports + AWS_ACCOUNT_ID: "289708231103" + AWS_ACCESS_KEY_ID: ${{ inputs.s3_access_key_id }} + AWS_SECRET_ACCESS_KEY: ${{ inputs.s3_access_key_secret }} + AWS_DEFAULT_REGION: us-east-1 + AWS_DEFAULT_OUTPUT: json + shell: bash + run: | + cat < index.html + + + + + + + + EOF + + LATEST_PATH="manual-tests/${{ inputs.username }}/${{ inputs.test_type }}/${{ inputs.testbed }}/latest" + aws s3 cp --acl public-read --metadata latest=${{ github.run_number }} --content-type text/html index.html s3://${AWS_S3_BUCKET_NAME}/${LATEST_PATH}/index.html \ No newline at end of file diff --git a/.github/workflows/manual_reports_to_s3.yml b/.github/workflows/manual_reports_to_s3.yml new file mode 100644 index 000000000..b30560ccd --- /dev/null +++ b/.github/workflows/manual_reports_to_s3.yml @@ -0,0 +1,131 @@ +name: Manual reports to s3 +env: + # AWS credentials + AWS_EKS_NAME: tip-wlan-main + AWS_DEFAULT_OUTPUT: json + AWS_DEFAULT_REGION: ap-south-1 + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_KEY }} + + # Validation lists + ALLOWED_USERS: "Jitendra,User2,User3" + ALLOWED_TEST_TYPES: "sanity,regression,performance,custom_tests" + APPROVED_AP_MODELS: "cig_wf186h,edgecore_eap104,cig_wf196,udaya_a6-id2,sonicfi_rap630c-311g,hfcl_ion4xe,yuncore_fap655,cig_wf189,edgecore_eap105,sonicfi_rap7110c-341x,edgecore_eap101,edgecore_eap111" + +on: + workflow_dispatch: + inputs: + drive_link: + description: 'Drive link to Allure report .zip' + required: true + user_name: + description: 'User name' + required: true + default: 'Jitendra' + test_type: + description: 'Test type (sanity/regression/performance/custom_tests)' + required: true + default: 'sanity' + AP_model: + description: 'AP model' + required: true + default: "cig_wf196" + +jobs: + validate-inputs: + runs-on: ubuntu-latest + outputs: + is_valid: ${{ steps.validation.outputs.is_valid }} + steps: + - name: Validate inputs + id: validation + run: | + if [[ ! ",${{ env.ALLOWED_USERS }}," =~ ",${{ inputs.user_name }}," ]]; then + echo "::error::User ${{ inputs.user_name }} not allowed!" + echo "is_valid=false" >> $GITHUB_OUTPUT + exit 1 + fi + + if [[ ! ",${{ env.ALLOWED_TEST_TYPES }}," =~ ",${{ inputs.test_type }}," ]]; then + echo "::error::Invalid test type. Allowed: ${{ env.ALLOWED_TEST_TYPES }}" + echo "is_valid=false" >> $GITHUB_OUTPUT + exit 1 + fi + + if [[ ! ",${{ env.APPROVED_AP_MODELS }}," =~ ",${{ inputs.AP_model }}," ]]; then + echo "::error::Invalid AP model. Allowed: ${{ env.APPROVED_AP_MODELS }}" + echo "is_valid=false" >> $GITHUB_OUTPUT + exit 1 + fi + + echo "is_valid=true" >> $GITHUB_OUTPUT + + process-report: + needs: validate-inputs + if: needs.validate-inputs.outputs.is_valid == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Download report + run: | + # Handle Google Drive links + if [[ "${{ inputs.drive_link }}" == *"drive.google.com"* ]]; then + FILE_ID=$(echo "${{ inputs.drive_link }}" | sed -n -e 's/^.*d\/\([^\/]*\)\/.*$/\1/p') + curl -L -o allure-report.zip "https://drive.google.com/uc?export=download&id=${FILE_ID}" || { + echo "::error::Failed to download from Google Drive" + exit 1 + } + # Handle OneDrive/SharePoint links + elif [[ "${{ inputs.drive_link }}" == *"onedrive.live.com"* ]] || [[ "${{ inputs.drive_link }}" == *"sharepoint.com"* ]]; then + curl -L -o allure-report.zip "${{ inputs.drive_link }}" | sed 's/.*\(https:\/\/[^"]*\).*/\1/' | head -1 | xargs curl -L -o allure-report.zip || { + echo "::error::Failed to download from OneDrive/SharePoint" + exit 1 + } + # Handle Dropbox links + elif [[ "${{ inputs.drive_link }}" == *"dropbox.com"* ]]; then + curl -L -o allure-report.zip "${url%?dl=0}?dl=1" || { + echo "::error::Failed to download from Dropbox" + exit 1 + } + # Handle other direct download links + else + curl -L -o allure-report.zip "${{ inputs.drive_link }}" || { + echo "::error::Failed to download from provided URL" + exit 1 + } + fi + + unzip -t allure-report.zip || { + echo "::error::Invalid ZIP file" + exit 1 + } + + - name: Extract report + run: | + unzip -q allure-report.zip -d allure-report + rm allure-report.zip + + - name: Verify report structure + run: | + if [ ! -f "allure-report/index.html" ]; then + echo "::error::Extracted folder doesn't contain valid Allure report" + exit 1 + fi + + - name: Upload report as artifact + uses: actions/upload-artifact@v4 + with: + name: allure-report + path: allure-report + + - name: Upload to S3 + uses: ./.github/actions/manual-allure-report-to-s3 + with: + test_type: ${{ inputs.test_type }} + testbed: ${{ inputs.AP_model }} + report_path: allure-report + s3_access_key_id: ${{ secrets.ALLURE_S3_ACCESS_KEY_ID }} + s3_access_key_secret: ${{ secrets.ALLURE_S3_ACCESS_KEY_SECRET }} + username: ${{ inputs.user_name }}