-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: composite action input pollution #2348
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7bd9aea
fix: composite action input pollution
ChristopherHX f9e0e51
fix run steps
ChristopherHX 19338df
fix missing defaults in post after env cleanup
ChristopherHX ef8f565
fix test to make more sense
ChristopherHX b67251b
Add tests and simplify change
ChristopherHX 885a7b9
Merge branch 'master' into fix-composite-input-pollution
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,6 +242,8 @@ func TestRunEvent(t *testing.T) { | |
// Uses | ||
{workdir, "uses-composite", "push", "", platforms, secrets}, | ||
{workdir, "uses-composite-with-error", "push", "Job 'failing-composite-action' failed", platforms, secrets}, | ||
{workdir, "uses-composite-check-for-input-collision", "push", "", platforms, secrets}, | ||
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. This test only passes via changes made here |
||
{workdir, "uses-composite-check-for-input-shadowing", "push", "", platforms, secrets}, | ||
{workdir, "uses-nested-composite", "push", "", platforms, secrets}, | ||
{workdir, "remote-action-composite-js-pre-with-defaults", "push", "", platforms, secrets}, | ||
{workdir, "remote-action-composite-action-ref", "push", "", platforms, secrets}, | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,7 @@ func TestSetupEnv(t *testing.T) { | |
JobContainer: cm, | ||
} | ||
step := &model.Step{ | ||
Uses: "./", | ||
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. See |
||
With: map[string]string{ | ||
"STEP_WITH": "with-value", | ||
}, | ||
|
16 changes: 16 additions & 0 deletions
16
...ner/testdata/uses-composite-check-for-input-collision/action-with-pre-and-post/action.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 14 additions & 0 deletions
14
...runner/testdata/uses-composite-check-for-input-collision/action-with-pre-and-post/main.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 14 additions & 0 deletions
14
...runner/testdata/uses-composite-check-for-input-collision/action-with-pre-and-post/post.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 12 additions & 0 deletions
12
pkg/runner/testdata/uses-composite-check-for-input-collision/action-with-pre-and-post/pre.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
16 changes: 16 additions & 0 deletions
16
pkg/runner/testdata/uses-composite-check-for-input-collision/composite_action/action.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: "Test Composite Action" | ||
description: "Test action uses composite" | ||
|
||
inputs: | ||
cache: | ||
default: none | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: ./uses-composite-check-for-input-collision/action-with-pre-and-post | ||
with: | ||
step: step1 | ||
- uses: ./uses-composite-check-for-input-collision/action-with-pre-and-post | ||
with: | ||
step: step2 |
10 changes: 10 additions & 0 deletions
10
pkg/runner/testdata/uses-composite-check-for-input-collision/push.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: uses-composite-with-pre-and-post-steps | ||
on: push | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: echo -n "STEP_OUTPUT_TEST=empty" >> $GITHUB_ENV | ||
- uses: ./uses-composite-check-for-input-collision/composite_action |
16 changes: 16 additions & 0 deletions
16
...ner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/action.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 14 additions & 0 deletions
14
...runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/main.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 14 additions & 0 deletions
14
...runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/post.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 12 additions & 0 deletions
12
pkg/runner/testdata/uses-composite-check-for-input-shadowing/action-with-pre-and-post/pre.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 18 additions & 0 deletions
18
pkg/runner/testdata/uses-composite-check-for-input-shadowing/composite_action/action.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 12 additions & 0 deletions
12
pkg/runner/testdata/uses-composite-check-for-input-shadowing/push.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: uses-composite-with-pre-and-post-steps | ||
on: push | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: echo -n "STEP_OUTPUT_TEST=empty" >> $GITHUB_ENV | ||
- uses: ./uses-composite-check-for-input-shadowing/composite_action | ||
# with: | ||
# cache: other |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
cleaning up env caused missing default values in post steps