Action Test #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test OSS Helper | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| test_type: | |
| description: 'Type of test to run' | |
| required: true | |
| type: choice | |
| options: | |
| - 'basic-upload' | |
| - 'multiple-files' | |
| - 'directory-upload' | |
| - 'advanced-options' | |
| - 'large-file-test' | |
| - 'dry-run' | |
| default: 'dry-run' | |
| region: | |
| description: 'OSS Region (e.g., oss-cn-beijing)' | |
| required: false | |
| default: '' | |
| bucket: | |
| description: 'OSS Bucket Name' | |
| required: false | |
| default: '' | |
| custom_assets: | |
| description: 'Custom assets (optional, for advanced testing)' | |
| required: false | |
| default: '' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| # Set fallback values using environment variables | |
| OSS_REGION: ${{ inputs.region != '' && inputs.region || secrets.OSS_REGION || 'oss-cn-beijing' }} | |
| OSS_BUCKET: ${{ inputs.bucket != '' && inputs.bucket || secrets.OSS_BUCKET || 'test-bucket' }} | |
| OSS_ACCESS_KEY: ${{ secrets.OSS_ACCESS_KEY || 'test-key' }} | |
| OSS_SECRET_KEY: ${{ secrets.OSS_SECRET_KEY || 'test-secret' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Create test files | |
| run: | | |
| # Create test directory structure | |
| mkdir -p test-files/{docs,images,config} | |
| # Create various test files | |
| echo "# Test README" > test-files/README.md | |
| echo "Test content for documentation" > test-files/docs/guide.md | |
| echo "Configuration file content" > test-files/config/app.json | |
| echo "Binary-like content" > test-files/images/logo.png | |
| # Create a larger file for testing (1KB) | |
| head -c 1024 /dev/urandom > test-files/large-file.bin | |
| # Create files with special characters | |
| echo "Unicode test 中文测试" > "test-files/unicode-测试.txt" | |
| echo "Spaces in filename" > "test-files/file with spaces.txt" | |
| echo "📁 Created test files:" | |
| find test-files -type f -exec ls -lh {} \; | |
| - name: Create large files for big file testing | |
| if: inputs.test_type == 'large-file-test' | |
| run: | | |
| echo "🏗️ Creating large test files..." | |
| # Check available disk space | |
| echo "💾 Available disk space:" | |
| df -h . | |
| # Create a 1.2GB file for testing large file uploads | |
| # Using dd with sparse file creation for efficiency | |
| echo "📦 Creating 1.2GB test file..." | |
| dd if=/dev/zero of=test-files/huge-file-1.2gb.bin bs=1M count=1200 status=progress | |
| # Create a 2.5GB file for extreme testing (if space allows) | |
| if [ $(df . | tail -1 | awk '{print $4}') -gt 3000000 ]; then | |
| echo "📦 Creating 2.5GB test file..." | |
| dd if=/dev/zero of=test-files/massive-file-2.5gb.bin bs=1M count=2500 status=progress | |
| else | |
| echo "⚠️ Insufficient disk space for 2.5GB file, skipping..." | |
| fi | |
| # Create some medium-large files too | |
| echo "📦 Creating additional large files..." | |
| dd if=/dev/urandom of=test-files/random-500mb.bin bs=1M count=500 status=progress | |
| dd if=/dev/zero of=test-files/zeros-800mb.bin bs=1M count=800 status=progress | |
| echo "📊 Large file summary:" | |
| ls -lh test-files/*.bin | |
| echo "" | |
| echo "💾 Disk space after creation:" | |
| df -h . | |
| - name: Test - Dry Run | |
| if: inputs.test_type == 'dry-run' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: 'test-key-id' | |
| secret-key: 'test-key-secret' | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| timeout: 60 | |
| continue-on-error: true | |
| env: | |
| # This will fail but test the action logic | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Test - Basic Upload (Dry Run) | |
| if: inputs.test_type == 'basic-upload' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| timeout: 120 | |
| continue-on-error: true | |
| - name: Test - Multiple Files | |
| if: inputs.test_type == 'multiple-files' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| test-files/docs/guide.md:documentation/guide.md | |
| test-files/config/app.json:config/application.json | |
| timeout: 180 | |
| continue-on-error: true | |
| - name: Test - Directory Upload | |
| if: inputs.test_type == 'directory-upload' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/:website/ | |
| timeout: 180 | |
| continue-on-error: true | |
| - name: Test - Advanced Options | |
| if: inputs.test_type == 'advanced-options' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| test-files/large-file.bin:files/large.bin | |
| timeout: 300 | |
| max-retries: 5 | |
| enable-gzip: true | |
| public-read: true | |
| headers: '{"Cache-Control":"max-age=3600","Content-Type":"text/html"}' | |
| continue-on-error: true | |
| - name: Test - Large File Upload (>1GB) | |
| if: inputs.test_type == 'large-file-test' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/huge-file-1.2gb.bin:large-files/huge-1.2gb.bin | |
| test-files/random-500mb.bin:large-files/random-500mb.bin | |
| test-files/zeros-800mb.bin:large-files/zeros-800mb.bin | |
| timeout: 1800 | |
| max-retries: 3 | |
| enable-gzip: false | |
| continue-on-error: true | |
| - name: Test - Massive File Upload (2.5GB if available) | |
| if: inputs.test_type == 'large-file-test' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/massive-file-2.5gb.bin:extreme-files/massive-2.5gb.bin | |
| timeout: 3600 | |
| max-retries: 2 | |
| enable-gzip: false | |
| continue-on-error: true | |
| continue-on-error: true | |
| - name: Test - Custom Assets | |
| if: inputs.custom_assets != '' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: ${{ inputs.custom_assets }} | |
| timeout: 180 | |
| continue-on-error: true | |
| - name: Display Results | |
| if: always() | |
| run: | | |
| echo "🧪 Test completed!" | |
| echo "📊 Test type: ${{ inputs.test_type }}" | |
| echo "🌏 Region: ${{ env.OSS_REGION }}" | |
| echo "🪣 Bucket: ${{ env.OSS_BUCKET }}" | |
| if [ -n "${{ inputs.custom_assets }}" ]; then | |
| echo "📋 Custom assets: ${{ inputs.custom_assets }}" | |
| fi | |
| echo "" | |
| echo "💡 To test with real credentials:" | |
| echo "1. Add OSS_ACCESS_KEY, OSS_SECRET_KEY, OSS_REGION, and OSS_BUCKET to repository secrets" | |
| echo "2. Re-run this workflow" | |
| echo "" | |
| echo "🔍 Check the action logs above for detailed results" |