Commit ffeab76e authored by Daniel Kennedy's avatar Daniel Kennedy
Browse files

Add CI tests for direct uploads

parent 6b684709
Loading
Loading
Loading
Loading
+95
Changes for .github/workflows/test.yml: 95 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -213,6 +213,101 @@ jobs:
            Write-Error "File contents of downloaded artifact are incorrect"
        }
      shell: pwsh

    # Upload a single file without archiving (direct file upload)
    - name: 'Create direct upload file'
      run: echo -n 'direct file upload content' > direct-upload-${{ matrix.runs-on }}.txt
      shell: bash

    - name: 'Upload direct file artifact'
      uses: ./
      with:
        name: 'Direct-File-${{ matrix.runs-on }}'
        path: direct-upload-${{ matrix.runs-on }}.txt
        archive: false

    - name: 'Download direct file artifact'
      uses: actions/download-artifact@v4
      with:
        name: direct-upload-${{ matrix.runs-on }}.txt
        path: direct-download

    - name: 'Verify direct file artifact'
      run: |
        $file = "direct-download/direct-upload-${{ matrix.runs-on }}.txt"
        if(!(Test-Path -path $file))
        {
            Write-Error "Expected file does not exist"
        }
        if(!((Get-Content $file -Raw).TrimEnd() -ceq "direct file upload content"))
        {
            Write-Error "File contents of downloaded artifact are incorrect"
        }
      shell: pwsh

  upload-html-report:
    name: Upload HTML Report
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - name: Setup Node 24
      uses: actions/setup-node@v4
      with:
        node-version: 24.x
        cache: 'npm'

    - name: Install dependencies
      run: npm ci

    - name: Compile
      run: npm run build

    - name: Create HTML report
      run: |
        cat > report.html << 'EOF'
        <!DOCTYPE html>
        <html lang="en">
        <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <title>Artifact Upload Test Report</title>
          <style>
            body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; max-width: 800px; margin: 40px auto; padding: 0 20px; color: #24292f; }
            h1 { border-bottom: 1px solid #d0d7de; padding-bottom: 8px; }
            .success { color: #1a7f37; }
            .info { background: #ddf4ff; border: 1px solid #54aeff; border-radius: 6px; padding: 12px 16px; margin: 16px 0; }
            table { border-collapse: collapse; width: 100%; margin: 16px 0; }
            th, td { border: 1px solid #d0d7de; padding: 8px 12px; text-align: left; }
            th { background: #f6f8fa; }
          </style>
        </head>
        <body>
          <h1>Artifact Upload Test Report</h1>
          <div class="info">
            <strong>This HTML file was uploaded as a single un-zipped artifact.</strong>
            If you can see this in the browser, the feature is working correctly!
          </div>
          <table>
            <tr><th>Property</th><th>Value</th></tr>
            <tr><td>Upload method</td><td><code>archive: false</code></td></tr>
            <tr><td>Content-Type</td><td><code>text/html</code></td></tr>
            <tr><td>File</td><td><code>report.html</code></td></tr>
          </table>
          <p class="success">&#10004; Single file upload is working!</p>
        </body>
        </html>
        EOF

    - name: Upload HTML report (no archive)
      uses: ./
      with:
        name: 'test-report'
        path: report.html
        archive: false

  merge:
    name: Merge
    needs: build