mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
fix: composite action input pollution (#818)
refuses to use the default for an nodejs input when an composite action has an input with the same name. clean cherry-pick (except for trivial context conflict) of two related pull requests - https://github.com/nektos/act/pull/2348 - https://github.com/nektos/act/pull/2473 <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/818): <!--number 818 --><!--line 0 --><!--description Zml4OiBjb21wb3NpdGUgYWN0aW9uIGlucHV0IHBvbGx1dGlvbg==-->fix: composite action input pollution<!--description--> <!--end release-notes-assistant--> Co-authored-by: ChristopherHX <christopher.homberger@web.de> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/818 Reviewed-by: Gusted <gusted@noreply.code.forgejo.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
931c2c0ac3
commit
b236cb64f9
18 changed files with 267 additions and 4 deletions
16
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/action.yml
vendored
Normal file
16
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/action.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
name: "Action with pre and post"
|
||||
description: "Action with pre and post"
|
||||
|
||||
inputs:
|
||||
step:
|
||||
description: "step"
|
||||
required: true
|
||||
cache:
|
||||
required: false
|
||||
default: false
|
||||
|
||||
runs:
|
||||
using: "node16"
|
||||
pre: pre.js
|
||||
main: main.js
|
||||
post: post.js
|
14
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/main.js
vendored
Normal file
14
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/main.js
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
const { appendFileSync } = require('fs');
|
||||
const step = process.env['INPUT_STEP'];
|
||||
appendFileSync(process.env['GITHUB_ENV'], `TEST=${step}`, { encoding:'utf-8' })
|
||||
|
||||
var cache = process.env['INPUT_CACHE']
|
||||
try {
|
||||
var cache = JSON.parse(cache)
|
||||
} catch {
|
||||
|
||||
}
|
||||
if(typeof cache !== 'boolean') {
|
||||
console.log("Input Polluted boolean true/false expected, got " + cache)
|
||||
process.exit(1);
|
||||
}
|
14
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/post.js
vendored
Normal file
14
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/post.js
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
const { appendFileSync } = require('fs');
|
||||
const step = process.env['INPUT_STEP'];
|
||||
appendFileSync(process.env['GITHUB_ENV'], `TEST=${step}-post`, { encoding:'utf-8' })
|
||||
|
||||
var cache = process.env['INPUT_CACHE']
|
||||
try {
|
||||
var cache = JSON.parse(cache)
|
||||
} catch {
|
||||
|
||||
}
|
||||
if(typeof cache !== 'boolean') {
|
||||
console.log("Input Polluted boolean true/false expected, got " + cache)
|
||||
process.exit(1);
|
||||
}
|
12
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/pre.js
vendored
Normal file
12
act/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/pre.js
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
console.log('pre');
|
||||
|
||||
var cache = process.env['INPUT_CACHE']
|
||||
try {
|
||||
var cache = JSON.parse(cache)
|
||||
} catch {
|
||||
|
||||
}
|
||||
if(typeof cache !== 'boolean') {
|
||||
console.log("Input Polluted boolean true/false expected, got " + cache)
|
||||
process.exit(1);
|
||||
}
|
18
act/runner/testdata/uses-composite-check-for-input-shadowing/composite_action/action.yml
vendored
Normal file
18
act/runner/testdata/uses-composite-check-for-input-shadowing/composite_action/action.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
name: "Test Composite Action"
|
||||
description: "Test action uses composite"
|
||||
|
||||
inputs:
|
||||
cache:
|
||||
default: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: ./uses-composite-check-for-input-shadowing/action-with-pre-and-post
|
||||
with:
|
||||
step: step1
|
||||
cache: ${{ inputs.cache || 'none' }}
|
||||
- uses: ./uses-composite-check-for-input-shadowing/action-with-pre-and-post
|
||||
with:
|
||||
step: step2
|
||||
cache: ${{ inputs.cache || 'none' }}
|
12
act/runner/testdata/uses-composite-check-for-input-shadowing/push.yml
vendored
Normal file
12
act/runner/testdata/uses-composite-check-for-input-shadowing/push.yml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
name: uses-composite-with-pre-and-post-steps
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: https://data.forgejo.org/actions/checkout@v4
|
||||
- run: echo -n "STEP_OUTPUT_TEST=empty" >> $GITHUB_ENV
|
||||
- uses: ./uses-composite-check-for-input-shadowing/composite_action
|
||||
# with:
|
||||
# cache: other
|
Loading…
Add table
Add a link
Reference in a new issue