Skip to content

Commit 41db4c6

Browse files
chore: deprecate set output
1 parent 7998ef3 commit 41db4c6

4 files changed

Lines changed: 72 additions & 30 deletions

File tree

src/parse_input_extra_args.Tests.ps1

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
12
Describe "parse_input_extra_args" {
3+
BeforeEach{
4+
function toGitHub () {
5+
param(
6+
$output_name,
7+
$output_value
8+
)
9+
Write-Output "$output_name=$output_value";
10+
}
11+
Mock toGitHub -MockWith { Write-Output "$output_name=$output_value";}
12+
}
13+
214
Context "when nothing set" {
315
It "it should return nothing" {
416
.\parse_input_extra_args.ps1 | Should -BeNullOrEmpty
@@ -9,23 +21,23 @@ Describe "parse_input_extra_args" {
921
It "it should return envNames" {
1022
$envNames = '@NAME1, NAME2'
1123
.\parse_input_extra_args.ps1 -envNames $envNames | Should -Be `
12-
"::set-output name=extra_args:: --env NAME1 --env NAME2 "
24+
"extra_args= --env NAME1 --env NAME2 "
1325
}
1426
}
1527

1628
Context "when entrypoint set" {
1729
It "it should return entrypoint" {
1830
$entryPoint = '@pwsh.exe'
1931
.\parse_input_extra_args.ps1 -entryPoint $entryPoint | Should -Be `
20-
"::set-output name=extra_args:: --entrypoint pwsh.exe"
32+
"extra_args= --entrypoint pwsh.exe"
2133
}
2234
}
2335

2436
Context "when extra_args set" {
2537
It "it should return extra args" {
2638
$extraArgs = '@--test 123456'
2739
.\parse_input_extra_args.ps1 -extraArgs $extraArgs | Should -Be `
28-
"::set-output name=extra_args::--test 123456 "
40+
"extra_args=--test 123456 "
2941
}
3042
}
3143

@@ -34,7 +46,7 @@ Describe "parse_input_extra_args" {
3446
$entryPoint = '@pwsh.exe'
3547
$extraArgs = '@--test 123456'
3648
.\parse_input_extra_args.ps1 -entryPoint $entryPoint -extraArgs $extraArgs | Should -Be `
37-
"::set-output name=extra_args::--test 123456 --entrypoint pwsh.exe"
49+
"extra_args=--test 123456 --entrypoint pwsh.exe"
3850
}
3951
}
4052

@@ -43,7 +55,7 @@ Describe "parse_input_extra_args" {
4355
$entryPoint = '@pwsh.exe'
4456
$envNames = '@NAME1,NAME2'
4557
.\parse_input_extra_args.ps1 -entryPoint $entryPoint -envNames $envNames | Should -Be `
46-
"::set-output name=extra_args:: --env NAME1 --env NAME2 --entrypoint pwsh.exe"
58+
"extra_args= --env NAME1 --env NAME2 --entrypoint pwsh.exe"
4759
}
4860
}
4961

@@ -53,7 +65,7 @@ Describe "parse_input_extra_args" {
5365
$envNames = '@NAME1,NAME2'
5466
$extraArgs = '@--test 123456'
5567
.\parse_input_extra_args.ps1 -entryPoint $entryPoint -envNames $envNames -extraArgs $extraArgs | Should -Be `
56-
"::set-output name=extra_args::--test 123456 --env NAME1 --env NAME2 --entrypoint pwsh.exe"
68+
"extra_args=--test 123456 --env NAME1 --env NAME2 --entrypoint pwsh.exe"
5769
}
5870
}
5971
}

src/parse_input_paths.Tests.ps1

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
Describe "parse_input_paths" {
2+
BeforeEach{
3+
function toGitHub () {
4+
param(
5+
$output_name,
6+
$output_value
7+
)
8+
Write-Output "$output_name=$output_value";
9+
}
10+
Mock toGitHub -MockWith { Write-Output "$output_name=$output_value";}
11+
}
12+
213
Context "when workspace, mapping, work not set" {
314
It "it should return gitworkspace" {
415
$githubWorkSpace = '@github_work_space'
516
.\parse_input_paths.ps1 -githubWorkSpace $githubWorkSpace | Should -Be `
6-
"::set-output name=workspace_path::github_work_space", `
7-
"::set-output name=mapping_path::github_work_space", `
8-
"::set-output name=work_path::github_work_space"
17+
"workspace_path=github_work_space", `
18+
"mapping_path=github_work_space", `
19+
"work_path=github_work_space"
920
}
1021
}
1122

@@ -14,9 +25,9 @@ Describe "parse_input_paths" {
1425
$githubWorkSpace = '@github_work_space'
1526
$workSpace = '@work_space'
1627
.\parse_input_paths.ps1 -githubWorkSpace $githubWorkSpace -workspacePath $workSpace | Should -Be `
17-
"::set-output name=workspace_path::work_space", `
18-
"::set-output name=mapping_path::work_space", `
19-
"::set-output name=work_path::work_space"
28+
"workspace_path=work_space", `
29+
"mapping_path=work_space", `
30+
"work_path=work_space"
2031
}
2132
}
2233

@@ -26,9 +37,9 @@ Describe "parse_input_paths" {
2637
$workSpace = '@work_space'
2738
$mapping = '@mapping'
2839
.\parse_input_paths.ps1 -githubWorkSpace $githubWorkSpace -workspacePath $workSpace -mappingPath $mapping | Should -Be `
29-
"::set-output name=workspace_path::work_space", `
30-
"::set-output name=mapping_path::mapping", `
31-
"::set-output name=work_path::mapping"
40+
"workspace_path=work_space", `
41+
"mapping_path=mapping", `
42+
"work_path=mapping"
3243
}
3344
}
3445

@@ -39,9 +50,9 @@ Describe "parse_input_paths" {
3950
$mapping = '@mapping'
4051
$work = '@work'
4152
.\parse_input_paths.ps1 -githubWorkSpace $githubWorkSpace -workspacePath $workSpace -mappingPath $mapping -workPath $work | Should -Be `
42-
"::set-output name=workspace_path::work_space", `
43-
"::set-output name=mapping_path::mapping", `
44-
"::set-output name=work_path::work"
53+
"workspace_path=work_space", `
54+
"mapping_path=mapping", `
55+
"work_path=work"
4556
}
4657
}
4758

@@ -51,9 +62,9 @@ Describe "parse_input_paths" {
5162
$workSpace = '@work_space'
5263
$work = '@work'
5364
.\parse_input_paths.ps1 -githubWorkSpace $githubWorkSpace -workspacePath $workSpace -workPath $work | Should -Be `
54-
"::set-output name=workspace_path::work_space", `
55-
"::set-output name=mapping_path::work_space", `
56-
"::set-output name=work_path::work"
65+
"workspace_path=work_space", `
66+
"mapping_path=work_space", `
67+
"work_path=work"
5768
}
5869
}
5970

@@ -63,9 +74,9 @@ Describe "parse_input_paths" {
6374
$mapping = '@mapping'
6475
$work = '@work'
6576
.\parse_input_paths.ps1 -githubWorkSpace $githubWorkSpace -mappingPath $mapping -workPath $work | Should -Be `
66-
"::set-output name=workspace_path::github_work_space", `
67-
"::set-output name=mapping_path::mapping", `
68-
"::set-output name=work_path::work"
77+
"workspace_path=github_work_space", `
78+
"mapping_path=mapping", `
79+
"work_path=work"
6980
}
7081
}
7182

@@ -74,9 +85,9 @@ Describe "parse_input_paths" {
7485
$githubWorkSpace = '@github_work_space'
7586
$mapping = '@mapping'
7687
.\parse_input_paths.ps1 -githubWorkSpace $githubWorkSpace -mappingPath $mapping | Should -Be `
77-
"::set-output name=workspace_path::github_work_space", `
78-
"::set-output name=mapping_path::mapping", `
79-
"::set-output name=work_path::mapping"
88+
"workspace_path=github_work_space", `
89+
"mapping_path=mapping", `
90+
"work_path=mapping"
8091
}
8192
}
8293
}

src/set_output_variable.Tests.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
Describe "set_output_variable" {
2+
BeforeEach{
3+
function toGitHub () {
4+
param(
5+
$output_name,
6+
$output_value
7+
)
8+
Write-Output "$output_name=$output_value";
9+
}
10+
Mock toGitHub -MockWith { Write-Output "$output_name=$output_value";}
11+
}
12+
213
Context "when val is not used" {
314
It "it should return empty" {
415
$name = 'theName'
@@ -18,15 +29,15 @@ Describe "set_output_variable" {
1829
It "it should return output" {
1930
$name = '@theName'
2031
$val = '@value'
21-
.\set_output_variable.ps1 -name $name -val $val | Should -Be "::set-output name=theName::value"
32+
.\set_output_variable.ps1 -name $name -val $val | Should -Be "theName=value"
2233
}
2334
}
2435

2536
Context "when val is value" {
2637
It "it should return output" {
2738
$name = 'theName'
2839
$val = 'value'
29-
.\set_output_variable.ps1 -name $name -val $val | Should -Be "::set-output name=theName::value"
40+
.\set_output_variable.ps1 -name $name -val $val | Should -Be "theName=value"
3041
}
3142
}
3243

src/set_output_variable.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ $trimArg = "$invovationPath" + "\trim_arg.ps1";
1111
$trimmed_name = & $trimArg -arg $name;
1212
$trimmed_val = & $trimArg -arg $val;
1313

14+
function toGitHub {
15+
param(
16+
$output_name,
17+
$output_value
18+
)
19+
"$output_name=$output_value" >> $env:GITHUB_OUTPUT;
20+
}
21+
1422
if ( ${trimmed_val}.Trim(' ') -ne "" )
1523
{
16-
Write-Output "::set-output name=$trimmed_name::$trimmed_val";
24+
toGitHub -output_name "$trimmed_name" -output_value "$trimmed_val";
1725
}

0 commit comments

Comments
 (0)