Repository navigation
feat: add Playwright e2e tests for the block editor #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
34982f4
948ee18
7d1a4f1
aa8506e
7129096
c24b5f2
dab1697
dd747ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| WP_BASE_URL=http://localhost:8889 | ||
| WP_AUTH_STORAGE=wp-auth.json | ||
| WP_USERNAME=admin | ||
| WP_PASSWORD=password | ||
| INTERACTIONS_SLUG=Interactions/interactions | ||
| ELEMENTOR_SLUG=elementor/elementor |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| name: Playwright Tests | ||
| on: | ||
| push: | ||
| branches: [ master, develop ] | ||
| pull_request: | ||
| branches: [ master, develop ] | ||
| permissions: | ||
| contents: read | ||
| actions: write | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| check-latest: true | ||
| cache: npm | ||
| cache-dependency-path: package-lock.json | ||
| - name: Build Interactions Free Plugin | ||
| run: | | ||
| npm ci --legacy-peer-deps | ||
| npm run build:e2e | ||
| - name: Archive plugin build | ||
| run: tar --exclude=./node_modules --exclude=./.git -czf /tmp/interactions-playwright-build.tar.gz . | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: interactions-playwright-build | ||
| path: /tmp/interactions-playwright-build.tar.gz | ||
| retention-days: 1 | ||
|
|
||
| test: | ||
| needs: build | ||
| timeout-minutes: 60 | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # interactions-playwright-matrix-start | ||
| - php_version: '8.5' | ||
| wp_version: '7.0.1' | ||
| - php_version: '8.0' | ||
| wp_version: '7.0.1' | ||
| - php_version: '8.0' | ||
| wp_version: '6.8.5' | ||
| - php_version: '8.0' | ||
| wp_version: '6.9.4' | ||
| # interactions-playwright-matrix-end | ||
| name: PHP ${{ matrix.php_version }} and WP ${{ matrix.wp_version || 'latest' }} | ||
| steps: | ||
| - name: Restore plugin build | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: interactions-playwright-build | ||
| - name: Extract plugin build | ||
| run: tar -xzf interactions-playwright-build.tar.gz | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| check-latest: true | ||
| cache: npm | ||
| cache-dependency-path: package-lock.json | ||
| - name: Install dependencies | ||
| run: npm ci --legacy-peer-deps | ||
| - name: Set the version suffix for the output | ||
| run: echo VERSION_SUFFIX=${GITHUB_REF_NAME//\//-} >> $GITHUB_ENV | ||
| - name: Set WP Version and create .wp-env.json | ||
| run: | | ||
| WP_VERSION="${{ matrix.wp_version }}" | ||
| core='"Wordpress/Wordpress#'${{ matrix.wp_version }}'"' | ||
|
|
||
| if [[ -z "$WP_VERSION" || "$WP_VERSION" == "null" ]]; then | ||
| WP_VERSION="latest" | ||
| core=null | ||
| fi | ||
|
|
||
| echo "WP_VERSION=$WP_VERSION" >> $GITHUB_ENV | ||
|
|
||
| echo '{ | ||
| "core": '$core', | ||
| "phpVersion": "${{ matrix.php_version }}", | ||
| "plugins": [ ".", "https://downloads.wordpress.org/plugin/elementor.zip" ], | ||
| "config": { | ||
| "SCRIPT_DEBUG": false | ||
| } | ||
| }' > .wp-env.json | ||
|
|
||
| cat .wp-env.json | ||
| - name: Cache Playwright Browsers | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/ms-playwright | ||
| key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-playwright- | ||
| - name: Install Playwright Browsers | ||
| timeout-minutes: 15 | ||
| run: | | ||
| for attempt in 1 2 3; do | ||
| npx playwright install chromium --with-deps && exit 0 | ||
| echo "Playwright install failed on attempt $attempt" | ||
| sleep $((attempt * 30)) | ||
| done | ||
| exit 1 | ||
| - name: Start wp-env | ||
| run: npx @wordpress/env start | ||
| - name: Print current WP version | ||
| run: npx @wordpress/env run tests-cli wp core version | ||
| - name: Run playwright tests | ||
| id: run-playwright-tests | ||
| env: | ||
| WP_BASE_URL: http://localhost:8889 | ||
| WP_AUTH_STORAGE: wp-auth.json | ||
| WP_USERNAME: admin | ||
| WP_PASSWORD: password | ||
| INTERACTIONS_SLUG: Interactions/interactions | ||
| ELEMENTOR_SLUG: elementor/elementor | ||
| run: npm run test | ||
| - uses: actions/upload-artifact@v4 | ||
| if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }} | ||
| id: artifact-upload-step | ||
| with: | ||
| name: playwright-report-php_${{ matrix.php_version }}-wp_${{ env.WP_VERSION }}-${{ env.VERSION_SUFFIX }} | ||
| path: playwright-report/ | ||
| overwrite: true | ||
| retention-days: 30 | ||
| - uses: markpatterson27/markdown-to-output@v1 | ||
| id: mto | ||
| if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }} | ||
| with: | ||
| filepath: ./playwright-interact/errors.md | ||
| - name: Add test results to summary | ||
| if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }} | ||
| env: | ||
| SUMMARY_BODY: ${{ steps.mto.outputs.body }} | ||
| REPORT_NAME: playwright-report-php_${{ matrix.php_version }}-wp_${{ env.WP_VERSION }}-${{ env.VERSION_SUFFIX }} | ||
| ARTIFACT_ID: ${{ steps.artifact-upload-step.outputs.artifact-id }} | ||
|
Comment on lines
+138
to
+141
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
file=".github/workflows/playwright.yml"
rg -n 'GITHUB_ENV|env\.(WP_VERSION|VERSION_SUFFIX)|name: playwright-report' "$file"
# Confirm artifact names include both matrix dimensions.
rg -n 'matrix\.(php_version|wp_version)' "$file"Repository: gambitph/Interactions Length of output: 1030 🏁 Script executed: #!/bin/bash
set -euo pipefail
file=".github/workflows/playwright.yml"
nl -ba "$file" | sed -n '60,150p'Repository: gambitph/Interactions Length of output: 199 🏁 Script executed: #!/bin/bash
set -euo pipefail
file=".github/workflows/playwright.yml"
awk 'NR>=60 && NR<=150 { printf "%4d %s\n", NR, $0 }' "$file"Repository: gambitph/Interactions Length of output: 4055 🌐 Web query:
💡 Result: In GitHub Actions, there are distinct mechanisms for managing data within a workflow, depending on whether you are using the env context, the GITHUB_ENV environment file, or step outputs [1][2][3]. The env context is used for variables defined in the workflow file (at the workflow, job, or step level) [4][5]. It is processed before the job is sent to the runner, meaning it is suitable for expressions in conditional statements [2][6]. GITHUB_ENV is a file on the runner used to persist environment variables for subsequent steps within the same job [5][3]. When you append a variable to this file (e.g., echo "VAR_NAME=value" >> Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
file=".github/workflows/playwright.yml"
awk 'NR>=1 && NR<=70 { printf "%4d %s\n", NR, $0 }' "$file"Repository: gambitph/Interactions Length of output: 2600 Use step outputs for the artifact name. 🤖 Prompt for AI Agents |
||
| run: | | ||
| echo "$SUMMARY_BODY" >> $GITHUB_STEP_SUMMARY | ||
| echo "Report: [${REPORT_NAME}.zip](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${ARTIFACT_ID})" >> $GITHUB_STEP_SUMMARY | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 22 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "core": null, | ||
| "phpVersion": "8.0", | ||
| "plugins": [ | ||
| ".", | ||
| "https://downloads.wordpress.org/plugin/elementor.zip" | ||
| ], | ||
| "config": { | ||
| "SCRIPT_DEBUG": false | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { request } from '@playwright/test' | ||
|
|
||
| import { ExtendedRequestUtils } from 'e2e/test-utils' | ||
|
|
||
| async function globalSetup() { | ||
| const requestContext = await request.newContext( { | ||
| baseURL: process.env.WP_BASE_URL, | ||
| ignoreHTTPSErrors: true, | ||
| } ) | ||
| const requestUtils = new ExtendedRequestUtils( requestContext, { | ||
| storageStatePath: process.env.WP_AUTH_STORAGE, | ||
| user: { | ||
| username: process.env.WP_USERNAME, | ||
| password: process.env.WP_PASSWORD, | ||
| }, | ||
| } ) | ||
|
|
||
| await requestUtils.setupRest() | ||
|
|
||
| const plugins = await requestUtils.getActivePlugins() | ||
|
|
||
| for ( const slug of Object.keys( plugins ) ) { | ||
| await requestUtils.deactivatePlugin( slug ) | ||
| } | ||
|
|
||
| await requestUtils.activatePlugin( process.env.INTERACTIONS_SLUG ) | ||
|
|
||
| if ( process.env.ELEMENTOR_SLUG ) { | ||
| await requestUtils.activatePlugin( process.env.ELEMENTOR_SLUG ) | ||
| } | ||
|
|
||
| await requestContext.dispose() | ||
| } | ||
|
|
||
| export default globalSetup |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,129 @@ | ||||||||||||||||||||||||||||||||||||||||||
| /* eslint-disable no-console */ | ||||||||||||||||||||||||||||||||||||||||||
| import type { | ||||||||||||||||||||||||||||||||||||||||||
| FullConfig, TestResult, | ||||||||||||||||||||||||||||||||||||||||||
| Reporter, Suite, TestCase, | ||||||||||||||||||||||||||||||||||||||||||
| } from '@playwright/test/reporter' | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import { ms } from 'e2e/test-utils' | ||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Import Playwright's You can utilize the 🐛 Proposed fix to sanitize error outputs-import { ms } from 'e2e/test-utils'
+import { ms, ansiRegex } from 'e2e/test-utils'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import fs from 'fs' | ||||||||||||||||||||||||||||||||||||||||||
| import path from 'path' | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| class InteractReporter implements Reporter { | ||||||||||||||||||||||||||||||||||||||||||
| outputFolder: string; | ||||||||||||||||||||||||||||||||||||||||||
| failedTestErrors: Array<string>; | ||||||||||||||||||||||||||||||||||||||||||
| totalTestCount: number; | ||||||||||||||||||||||||||||||||||||||||||
| suite: Suite; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| constructor( options: { outputFolder?: string } = {} ) { | ||||||||||||||||||||||||||||||||||||||||||
| this.outputFolder = options.outputFolder || 'playwright-interact' | ||||||||||||||||||||||||||||||||||||||||||
| this.cleanupFolder() | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| this.totalTestCount = 0 | ||||||||||||||||||||||||||||||||||||||||||
| this.failedTestErrors = [] | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| cleanupFolder() { | ||||||||||||||||||||||||||||||||||||||||||
| const folderPath = path.resolve( this.outputFolder ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if ( fs.existsSync( folderPath ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| const files = fs.readdirSync( folderPath ) | ||||||||||||||||||||||||||||||||||||||||||
| for ( const file of files ) { | ||||||||||||||||||||||||||||||||||||||||||
| const filePath = path.join( folderPath, file ) | ||||||||||||||||||||||||||||||||||||||||||
| if ( fs.lstatSync( filePath ).isFile() ) { | ||||||||||||||||||||||||||||||||||||||||||
| fs.unlinkSync( filePath ) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `All files removed from: ${ folderPath }` ) | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| fs.mkdirSync( folderPath, { recursive: true } ) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| onBegin( config: FullConfig, suite: Suite ): void { | ||||||||||||||||||||||||||||||||||||||||||
| this.totalTestCount = suite.allTests().length | ||||||||||||||||||||||||||||||||||||||||||
| this.suite = suite | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `Running ${ this.totalTestCount } tests:` ) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| onTestEnd( test: TestCase, result: TestResult ) { | ||||||||||||||||||||||||||||||||||||||||||
| const resultMark = test.ok() ? '✓' : '✘' | ||||||||||||||||||||||||||||||||||||||||||
| const titlePath = test.titlePath().filter( t => t !== '' ).join( ' › ' ) | ||||||||||||||||||||||||||||||||||||||||||
| const retryLabel = test.results.length > 1 ? `(retry #${ test.results.length - 1 }) ` : '' | ||||||||||||||||||||||||||||||||||||||||||
| const duration = `[${ ms( result.duration ) }]` | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `${ resultMark } ${ titlePath } ${ retryLabel }${ duration }` ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if ( result.status !== test.expectedStatus ) { | ||||||||||||||||||||||||||||||||||||||||||
| let testResult = `${ titlePath } ${ retryLabel }${ duration }` + '\n\n' | ||||||||||||||||||||||||||||||||||||||||||
| if ( result.errors.length >= 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| result.errors.forEach( error => { | ||||||||||||||||||||||||||||||||||||||||||
| if ( error.message ) { | ||||||||||||||||||||||||||||||||||||||||||
| testResult += `${ error.message }` + '\n\n' | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if ( error.snippet ) { | ||||||||||||||||||||||||||||||||||||||||||
| testResult += `${ error.snippet }` + `\n\n` | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } ) | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Strip ANSI codes from error messages and snippets. Applying the imported ♻️ Proposed refactor if ( result.errors.length >= 1 ) {
result.errors.forEach( error => {
if ( error.message ) {
- testResult += `${ error.message }` + '\n\n'
+ testResult += `${ error.message.replace( ansiRegex, '' ) }` + '\n\n'
}
if ( error.snippet ) {
- testResult += `${ error.snippet }` + `\n\n`
+ testResult += `${ error.snippet.replace( ansiRegex, '' ) }` + `\n\n`
}
} )
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| this.failedTestErrors.push( testResult ) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| getSummary() { | ||||||||||||||||||||||||||||||||||||||||||
| let skipped = 0 | ||||||||||||||||||||||||||||||||||||||||||
| let expected = 0 | ||||||||||||||||||||||||||||||||||||||||||
| let unexpected = 0 | ||||||||||||||||||||||||||||||||||||||||||
| let flaky = 0 | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const unexpectedTestTitles : Array<string> = [] | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| this.suite.allTests().forEach( test => { | ||||||||||||||||||||||||||||||||||||||||||
| switch ( test.outcome() ) { | ||||||||||||||||||||||||||||||||||||||||||
| case 'skipped': skipped++; break | ||||||||||||||||||||||||||||||||||||||||||
| case 'expected': expected++; break | ||||||||||||||||||||||||||||||||||||||||||
| case 'unexpected': | ||||||||||||||||||||||||||||||||||||||||||
| unexpected++ | ||||||||||||||||||||||||||||||||||||||||||
| unexpectedTestTitles.push( '- ' + test.titlePath().filter( t => t !== '' ).join( ' › ' ) ) | ||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||
| case 'flaky': flaky++; break | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if ( unexpected ) { | ||||||||||||||||||||||||||||||||||||||||||
| console.log( '\nSummary:' ) | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `${ expected } passed` ) | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `${ flaky } flaky` ) | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `${ skipped } skipped` ) | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `${ unexpected } failed` ) | ||||||||||||||||||||||||||||||||||||||||||
| console.log( `---\n\nFailed Tests:` ) | ||||||||||||||||||||||||||||||||||||||||||
| console.log( this.failedTestErrors.join( '' ) ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const md = ` | ||||||||||||||||||||||||||||||||||||||||||
| | PASSED | FLAKY | SKIPPED | FAILED | | ||||||||||||||||||||||||||||||||||||||||||
| | ------ | ----- | ------- | ------ | | ||||||||||||||||||||||||||||||||||||||||||
| | ${ expected } | ${ flaky } | ${ skipped } | ${ unexpected } | | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Failed Tests: | ||||||||||||||||||||||||||||||||||||||||||
| ${ unexpectedTestTitles.join( '\n' ) } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const folderPath = path.resolve( this.outputFolder ) | ||||||||||||||||||||||||||||||||||||||||||
| if ( ! fs.existsSync( folderPath ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| fs.mkdirSync( folderPath, { recursive: true } ) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const reportPath = path.join( folderPath, 'errors.md' ) | ||||||||||||||||||||||||||||||||||||||||||
| fs.writeFileSync( reportPath, md ) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| async onEnd() { | ||||||||||||||||||||||||||||||||||||||||||
| process.stdout.write( '\n' ) | ||||||||||||||||||||||||||||||||||||||||||
| this.getSummary() | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export default InteractReporter | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: gambitph/Interactions
Length of output: 6443
🏁 Script executed:
Repository: gambitph/Interactions
Length of output: 6167
🌐 Web query:
GitHub Actions upload-artifact permissions actions: write artifact-metadata write workflow permissions docs💡 Result:
As of July 15, 2026, the artifact-metadata: write permission is a fine-grained GitHub Actions permission specifically required for interacting with artifact metadata APIs, such as creating artifact metadata storage records [1]. Key points regarding this permission: 1. Function: The artifact-metadata: write permission allows a workflow to create and manage artifact-related metadata [1]. It replaced the broader contents: write permission for these specific API operations as of early 2026 [1]. 2. Usage: It is primarily used by actions that generate or persist metadata for build artifacts, such as the actions/attest-build-provenance action when creating storage records [2][3][4]. 3. Requirements: If you are using an action that requires this capability (e.g., to create storage records for linked artifacts), you must explicitly define the permission in your workflow job configuration [2][3]: permissions: artifact-metadata: write # Other necessary permissions (e.g., id-token: write, attestations: write) 4. Context: Note that the standard actions/upload-artifact action does not require the artifact-metadata: write permission to upload artifacts themselves [5][6][7]. The artifact-metadata permission is specifically for advanced metadata operations accessed via the REST API [1][8]. If you encounter errors like Failed to create storage record, ensure the permission is correctly scoped within your workflow job permissions block [9].
Citations:
artifact-metadata: writeset, yetFailed to create storage recordactions/attest-build-provenance#781Remove the workflow-wide
actions: writepermission.github/workflows/playwright.yml:7-9actions/upload-artifactandactions/download-artifactdon’t need it, so this can stay atcontents: readunless another step actually needs the Actions API.🧰 Tools
🪛 zizmor (1.26.1)
[error] 9-9: overly broad permissions (excessive-permissions): actions: write is overly broad at the workflow level
(excessive-permissions)
🤖 Prompt for AI Agents
Source: Linters/SAST tools