|
| 1 | +name: "Zstandard bundle (streaming)" |
| 2 | +description: "Stream the download and extraction of a Zstandard-compressed CodeQL Bundle" |
| 3 | +versions: |
| 4 | + - linked |
| 5 | +operatingSystems: |
| 6 | + - macos |
| 7 | + - ubuntu |
| 8 | +env: |
| 9 | + CODEQL_ACTION_ZSTD_BUNDLE: true |
| 10 | + CODEQL_ACTION_ZSTD_BUNDLE_STREAMING_EXTRACTION: true |
| 11 | +steps: |
| 12 | + - name: Remove CodeQL from toolcache |
| 13 | + uses: actions/github-script@v7 |
| 14 | + with: |
| 15 | + script: | |
| 16 | + const fs = require('fs'); |
| 17 | + const path = require('path'); |
| 18 | + const codeqlPath = path.join(process.env['RUNNER_TOOL_CACHE'], 'CodeQL'); |
| 19 | + fs.rmdirSync(codeqlPath, { recursive: true }); |
| 20 | + - id: init |
| 21 | + uses: ./../action/init |
| 22 | + with: |
| 23 | + languages: javascript |
| 24 | + tools: ${{ steps.prepare-test.outputs.tools-url }} |
| 25 | + - uses: ./../action/analyze |
| 26 | + with: |
| 27 | + output: ${{ runner.temp }}/results |
| 28 | + upload-database: false |
| 29 | + - name: Upload SARIF |
| 30 | + uses: actions/upload-artifact@v3 |
| 31 | + with: |
| 32 | + name: zstd-bundle.sarif |
| 33 | + path: ${{ runner.temp }}/results/javascript.sarif |
| 34 | + retention-days: 7 |
| 35 | + - name: Check diagnostic with expected tools URL appears in SARIF |
| 36 | + uses: actions/github-script@v7 |
| 37 | + env: |
| 38 | + SARIF_PATH: ${{ runner.temp }}/results/javascript.sarif |
| 39 | + with: |
| 40 | + script: | |
| 41 | + const fs = require('fs'); |
| 42 | +
|
| 43 | + const sarif = JSON.parse(fs.readFileSync(process.env['SARIF_PATH'], 'utf8')); |
| 44 | + const run = sarif.runs[0]; |
| 45 | +
|
| 46 | + const toolExecutionNotifications = run.invocations[0].toolExecutionNotifications; |
| 47 | + const downloadTelemetryNotifications = toolExecutionNotifications.filter(n => |
| 48 | + n.descriptor.id === 'codeql-action/bundle-download-telemetry' |
| 49 | + ); |
| 50 | + if (downloadTelemetryNotifications.length !== 1) { |
| 51 | + core.setFailed( |
| 52 | + 'Expected exactly one reporting descriptor in the ' + |
| 53 | + `'runs[].invocations[].toolExecutionNotifications[]' SARIF property, but found ` + |
| 54 | + `${downloadTelemetryNotifications.length}. All notification reporting descriptors: ` + |
| 55 | + `${JSON.stringify(toolExecutionNotifications)}.` |
| 56 | + ); |
| 57 | + } |
| 58 | +
|
| 59 | + const toolsUrl = downloadTelemetryNotifications[0].properties.attributes.toolsUrl; |
| 60 | + console.log(`Found tools URL: ${toolsUrl}`); |
| 61 | +
|
| 62 | + if (!toolsUrl.endsWith('.tar.zst')) { |
| 63 | + core.setFailed( |
| 64 | + `Expected the tools URL to be a .tar.zst file, but found ${toolsUrl}.` |
| 65 | + ); |
| 66 | + } |
0 commit comments