Skip to content

Commit a8c255b

Browse files
Merge pull request #20 from ocochelin/fix_clixml_captures_in_build_logs
Fix CLIXML captures in build logs
2 parents 17d0f15 + 83c056c commit a8c255b

3 files changed

Lines changed: 83 additions & 43 deletions

File tree

.github/workflows/test.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ jobs:
3636
image: ${{ matrix.docker_container }}
3737
mapping_path: 'c:\map'
3838
entrypoint: powershell.exe
39+
entrypoint_args: '-NoLogo -NonInteractive -NoProfile'
3940
env_names: TEST_MAPPING_PATH
40-
run: >-
41+
run: |
4142
c:\map\test\run_test.ps1 -testPath "c:\map\test\run_default.Tests.ps1";
4243
4344
- name: Test_ExtraArgs
@@ -47,27 +48,28 @@ jobs:
4748
mapping_path: 'c:\map'
4849
workspace_path: ${{ github.workspace }}
4950
extra_args: --entrypoint cmd.exe
50-
run: >-
51-
echo "Hello world";
52-
exit %ERRORLEVEL%;
51+
run: |
52+
echo Hello world & exit %ERRORLEVEL%
5353
5454
- name: Test_Environment
5555
uses: ./
5656
with:
5757
image: ${{ matrix.docker_container }}
5858
entrypoint: powershell.exe
59+
entrypoint_args: '-NoLogo -NonInteractive -NoProfile'
5960
mapping_path: 'c:\map'
6061
env_names: TEST1, TEST2, TEST3
61-
run: >-
62+
run: |
6263
c:\map\test\run_test.ps1 -testPath "c:\map\test\environment.Tests.ps1";
6364
6465
- name: Test_Default_Environment
6566
uses: ./
6667
with:
6768
image: ${{ matrix.docker_container }}
6869
entrypoint: powershell.exe
70+
entrypoint_args: '-NoLogo -NonInteractive -NoProfile'
6971
mapping_path: 'c:\map'
70-
run: >-
72+
run: |
7173
c:\map\test\run_test.ps1 -testPath "c:\map\test\default_environment.Tests.ps1";
7274
7375
- name: Test_WorkPath
@@ -77,8 +79,9 @@ jobs:
7779
mapping_path: 'c:\map'
7880
work_path: 'c:\temp'
7981
entrypoint: powershell.exe
82+
entrypoint_args: '-NoLogo -NonInteractive -NoProfile'
8083
memory: 3GB
81-
run: >-
84+
run: |
8285
c:\map\test\run_test.ps1 -testPath "c:\map\test\work_path.Tests.ps1";
8386
8487
- name: Test_MappingPath
@@ -88,8 +91,9 @@ jobs:
8891
mapping_path: 'c:\mapping'
8992
work_path: 'c:\temp'
9093
entrypoint: powershell.exe
94+
entrypoint_args: '-NoLogo -NonInteractive -NoProfile'
9195
memory: 3GB
92-
run: >-
96+
run: |
9397
c:\mapping\test\run_test.ps1 -testPath "c:\mapping\test\mapping_path.Tests.ps1";
9498
9599
- name: Test_WorkSpacePath
@@ -99,9 +103,10 @@ jobs:
99103
mapping_path: 'c:\map'
100104
workspace_path: ${{ github.workspace }}/test
101105
entrypoint: powershell.exe
106+
entrypoint_args: '-NoLogo -NonInteractive -NoProfile'
102107
memory: 3GB
103108
env_names: TEST_MAPPING_PATH
104-
run: >-
109+
run: |
105110
c:\map\run_test.ps1 -testPath "c:\map\workspace_path.Tests.ps1";
106111
107112
validate:
@@ -112,25 +117,25 @@ jobs:
112117
steps:
113118
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
114119
- name: Install
115-
shell: pwsh
116-
run: >-
120+
shell: pwsh -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
121+
run: |
117122
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted;
118123
Install-Module -Name Pester -Force -SkipPublisherCheck;
119124
Update-Module -Name Pester -Force;
120125
Install-Module -Name PSScriptAnalyzer -Force;
121126
Import-Module PSScriptAnalyzer -ErrorAction Stop
122127
- name: Linter src
123-
shell: pwsh
124-
run: >-
128+
shell: pwsh -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
129+
run: |
125130
Invoke-ScriptAnalyzer -Path src -EnableExit;
126131
- name: Linter test
127-
shell: pwsh
128-
run: >-
132+
shell: pwsh -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
133+
run: |
129134
Invoke-ScriptAnalyzer -Path test -EnableExit;
130135
- name: Test-Action-Scripts
131-
shell: pwsh
132-
run: >-
133-
cd src;
136+
shell: pwsh -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
137+
run: |
138+
Set-Location src;
134139
$config=New-PesterConfiguration;
135140
$config.Run.Exit=$true;
136141
Invoke-Pester -Configuration $config;

README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,24 @@ Composite action for running commands in windows docker containers.
1111

1212
## Usage
1313

14-
Very simple hello world example:
14+
Simple 'Hello world' example using the default `cmd.exe` ENTRYPOINT with the `/C` option:
15+
```
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Test_Run
22+
uses: philips-software/run-windows-docker-container-action@<version>
23+
with:
24+
image: mcr.microsoft.com/windows/servercore:20H2
25+
entrypoint_args: /C
26+
run: >-
27+
echo Hello world &
28+
call run-test-script.bat;
29+
```
1530

31+
Simple 'Hello world' example overriding the default ENTRYPOINT:
1632
```
1733
steps:
1834
- name: Checkout
@@ -25,7 +41,7 @@ Very simple hello world example:
2541
image: mcr.microsoft.com/windows/servercore:20H2
2642
entrypoint: powershell.exe
2743
run: >-
28-
echo "Hello world";
44+
Write-Output "Hello world";
2945
./run-test-script.ps1;
3046
```
3147

@@ -44,25 +60,27 @@ and work path.
4460
| parameter | description | required | default |
4561
| - | - | - | - |
4662
| image | Docker image. | `true` | |
47-
| run | Command to execute. | `true` | |
63+
| run | Command to execute. Must be single line for cmd.exe entry point (use &, && or \|\| operators to aggregate multiple commands). Can be multiline for entry points that support it, like powershell.exe. | `true` | |
4864
| workspace_path | Workspace path. Default is root workspace path. | `false` | |
4965
| mapping_path | Mapping path, i.e. path to where the workspace path is mapped in the docker container. Defaults to workspace_path. | `false` | |
5066
| work_path | Work path, i.e. path where the command in the docker container is executed. Defaults to workspace_path. | `false` | |
5167
| memory | Memory limit. See docker documentation on --memory. | `false` | 4GB |
5268
| entrypoint | Overrides the default ENTRYPOINT in docker image. | `false` | |
69+
| entrypoint_args | Optional arguments for the ENTRYPOINT (default or overriden). For instance, `/S /C` for cmd.exe or `-NoLogo -NonInteractive -NoProfile` for powershell.exe. | `false` | |
5370
| env_names | Environment variable names passed to docker image as comma separated list, for example: NAME1, NAME2, NAME3 | `false` | |
5471
| extra_args | Extra arguments for docker run command. | `false` | |
5572
| pre-warm | Run a warming-up container (which might crash due to first time use failure) | `false` | true |
56-
| pre-warm-cmd | Pre warm command to run inside the container | `false` | echo "warming up!" |
73+
| pre-warm-cmd | Pre warm command to run inside the container | `false` | Write-Output "warming up!" |
5774
| registry_authentication | Authenticate against registry server | `false` | false |
5875
| registry_username | Docker registry username. | `false` | |
5976
| registry_token | Docker registry token | `false` | |
6077
| registry_repository | Docker registry repository | `false` | |
6178

6279

80+
<!-- action-docs-outputs -->
81+
## Outputs
6382

64-
<!-- action-docs-inputs -->
65-
83+
N/A
6684

6785
<!-- action-docs-runs -->
6886
## Runs

action.yml

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
description: 'Docker image.'
1111
required: true
1212
run:
13-
description: 'Command to execute.'
13+
description: 'Command to execute. Must be single line for cmd.exe entry point (use &, && or \|\| operators to aggregate multiple commands). Can be multiline for entry points that support it, like powershell.exe.'
1414
required: true
1515
workspace_path:
1616
description: 'Workspace path. Default is root workspace path.'
@@ -29,6 +29,10 @@ inputs:
2929
description: "Overrides the default ENTRYPOINT in docker image."
3030
required: false
3131
default: ''
32+
entrypoint_args:
33+
description: "Optional arguments for the ENTRYPOINT (default or overriden). For instance, `/S /C` for cmd.exe or `-NoLogo -NonInteractive -NoProfile` for powershell.exe."
34+
required: false
35+
default: ''
3236
env_names:
3337
description: 'Environment variable names passed to docker image as comma separated list, for example: NAME1, NAME2, NAME3'
3438
required: false
@@ -44,7 +48,7 @@ inputs:
4448
pre-warm-cmd:
4549
description: 'Pre warm command to run inside the container'
4650
required: false
47-
default: 'echo "warming up!"'
51+
default: 'Write-Output "warming up!"'
4852
registry_authentication:
4953
description : 'Authenticate against registry server'
5054
required : false
@@ -70,31 +74,41 @@ runs:
7074
shell: bash
7175
- name: settings
7276
id: settings
73-
run: >-
77+
run: |
7478
${{ github.action_path }}/src/parse_input_paths.ps1 -githubWorkSpace "${{ github.workspace }}" -workspacePath "@${{ inputs.workspace_path }}" -mappingPath "@${{ inputs.mapping_path }}" -workPath "@${{ inputs.work_path }}";
7579
${{ github.action_path }}/src/parse_input_extra_args.ps1 -envNames "@${{ inputs.env_names }}" -entryPoint "@${{ inputs.entrypoint }}" -extraArgs "@${{ inputs.extra_args }}";
7680
${{ github.action_path }}/src/assign_default_environment_variables.ps1;
77-
shell: powershell
81+
shell: powershell -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
7882
- name: docker_login
7983
id: docker_login
8084
if: inputs.registry_authentication == 'true'
81-
shell: powershell
82-
run: >-
85+
shell: powershell -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
86+
run: |
8387
docker login ${{ inputs.registry_repository }} -u ${{ inputs.registry_username }} -p ${{ inputs.registry_token }}
8488
- name: Pre-warm
8589
if: inputs.pre-warm == 'true'
86-
run: |
87-
docker run ${{ steps.settings.outputs.extra_args }} `
88-
--rm --memory=${{ inputs.memory }} `
89-
-v ${{ steps.settings.outputs.workspace_path }}:${{ steps.settings.outputs.mapping_path }} `
90-
-w ${{ steps.settings.outputs.work_path }} `
91-
${{ inputs.image }} { ${{ inputs.pre-warm-cmd }} }
90+
run: >-
91+
docker run
92+
${{ steps.settings.outputs.extra_args }}
93+
--rm
94+
--memory=${{ inputs.memory }}
95+
-v ${{ steps.settings.outputs.workspace_path }}:${{ steps.settings.outputs.mapping_path }}
96+
-w ${{ steps.settings.outputs.work_path }}
97+
${{ inputs.image }}
98+
${{ inputs.entrypoint_args }}
99+
@"
100+
101+
${{ inputs.pre-warm-cmd }}
102+
103+
"@
104+
92105
exit 0
93-
shell: powershell
106+
shell: powershell -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
94107
- name: Run
95108
run: >-
96109
$runnerPathSource = Split-Path -Path "${env:RUNNER_TEMP}" -Parent;
97-
$runnerPathTarget = $runnerPathSource.replace('D:', 'C:')
110+
111+
$runnerPathTarget = $runnerPathSource.replace('D:', 'C:');
98112
99113
docker run
100114
${{ steps.settings.outputs.default_environment_variables }}
@@ -105,13 +119,16 @@ runs:
105119
-v ${{ steps.settings.outputs.workspace_path }}:${{ steps.settings.outputs.mapping_path }}
106120
-w ${{ steps.settings.outputs.work_path }}
107121
${{ inputs.image }}
108-
{
122+
${{ inputs.entrypoint_args }}
123+
@"
124+
109125
${{ inputs.run }}
110-
}
111-
shell: powershell
126+
127+
"@
128+
shell: powershell -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
112129
- name: docker_logout
113130
id: docker_logout
114131
if: inputs.registry_authentication == 'true'
115-
shell: powershell
116-
run: >-
132+
shell: powershell -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
133+
run: |
117134
docker logout ${{ inputs.registry_repository }}

0 commit comments

Comments
 (0)