3232 cache : ' npm'
3333
3434 - run : |
35- sudo apt-get install -y powershell
36-
3735 git submodule update --init actions-toolkit
3836 cd actions-toolkit/packages/artifact
3937 npm install
@@ -95,16 +93,10 @@ jobs:
9593
9694 - name : ' Verify Artifact #1'
9795 run : |
98- $file = "some/new/path/file1.txt"
99- if(!(Test-Path -path $file))
100- {
101- Write-Error "Expected file does not exist"
102- }
103- if(!((Get-Content $file) -ceq "Lorem ipsum dolor sit amet"))
104- {
105- Write-Error "File contents of downloaded artifact are incorrect"
106- }
107- shell : pwsh
96+ str="Lorem ipsum dolor sit amet"
97+ if [[ $(< some/new/path/file1.txt) != "$str" ]]; then
98+ exit 1
99+ fi
108100
109101 # Download Artifact #2 and verify the correctness of the content
110102 - name : ' Download artifact #2'
@@ -115,17 +107,15 @@ jobs:
115107
116108 - name : ' Verify Artifact #2'
117109 run : |
118- $file1 = "some/other/path/to/dir-1/file1.txt"
119- $file2 = "some/other/path/to/dir-2/file2.txt"
120- if(!(Test-Path -path $file1) -or !(Test-Path -path $file2))
121- {
122- Write-Error "Expected files do not exist"
123- }
124- if(!((Get-Content $file1) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $file2) -ceq "Hello world from file #2"))
125- {
126- Write-Error "File contents of downloaded artifacts are incorrect"
127- }
128- shell : pwsh
110+ str="Lorem ipsum dolor sit amet"
111+ if [[ $(< some/other/path/to/dir-1/file1.txt) != "$str" ]]; then
112+ exit 1
113+ fi
114+
115+ str="Hello world from file #2"
116+ if [[ $(< some/other/path/to/dir-2/file2.txt) != "$str" ]]; then
117+ exit 1
118+ fi
129119
130120 # Download Artifact #4 and verify the correctness of the content
131121 - name : ' Download artifact #4'
@@ -136,17 +126,15 @@ jobs:
136126
137127 - name : ' Verify Artifact #4'
138128 run : |
139- $file1 = "multi/artifact/dir-1/file1.txt"
140- $file2 = "multi/artifact/dir-2/file2.txt"
141- if(!(Test-Path -path $file1) -or !(Test-Path -path $file2))
142- {
143- Write-Error "Expected files do not exist"
144- }
145- if(!((Get-Content $file1) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $file2) -ceq "Hello world from file #2"))
146- {
147- Write-Error "File contents of downloaded artifacts are incorrect"
148- }
149- shell : pwsh
129+ str="Lorem ipsum dolor sit amet"
130+ if [[ $(< multi/artifact/dir-1/file1.txt) != "$str" ]]; then
131+ exit 1
132+ fi
133+
134+ str="Hello world from file #2"
135+ if [[ $(< multi/artifact/dir-2/file2.txt) != "$str" ]]; then
136+ exit 1
137+ fi
150138
151139 - name : ' Alter file 1 content'
152140 run : |
@@ -169,90 +157,7 @@ jobs:
169157
170158 - name : ' Verify Artifact #1 again'
171159 run : |
172- $file = "overwrite/some/new/path/file1.txt"
173- if(!(Test-Path -path $file))
174- {
175- Write-Error "Expected file does not exist"
176- }
177- if(!((Get-Content $file) -ceq "This file has changed"))
178- {
179- Write-Error "File contents of downloaded artifact are incorrect"
180- }
181- shell : pwsh
182- merge :
183- name : Merge
184- needs : build
185- runs-on : ubuntu-latest
186-
187- steps :
188- - name : Checkout
189- uses : actions/checkout@v4
190-
191- # Merge all artifacts from previous jobs
192- - name : Merge all artifacts in run
193- uses : ./merge/
194- with :
195- # our matrix produces artifacts with the same file, this prevents "stomping" on each other, also makes it
196- # easier to identify each of the merged artifacts
197- separate-directories : true
198- - name : ' Download merged artifacts'
199- uses : namespace-actions/download-artifact@v0
200- with :
201- name : merged-artifacts
202- path : all-merged-artifacts
203- - name : ' Check merged artifact has directories for each artifact'
204- run : |
205- $artifacts = @(
206- "Artifact-A-ubuntu-latest",
207- "Artifact-A-macos-latest",
208- "Artifact-A-windows-latest",
209- "Artifact-Wildcard-ubuntu-latest",
210- "Artifact-Wildcard-macos-latest",
211- "Artifact-Wildcard-windows-latest",
212- "Multi-Path-Artifact-ubuntu-latest",
213- "Multi-Path-Artifact-macos-latest",
214- "Multi-Path-Artifact-windows-latest"
215- )
216-
217- foreach ($artifact in $artifacts) {
218- $path = "all-merged-artifacts/$artifact"
219- if (!(Test-Path $path)) {
220- Write-Error "$path does not exist."
221- }
222- }
223- shell : pwsh
224-
225- # Merge Artifact-A-* from previous jobs
226- - name : Merge all Artifact-A
227- uses : ./merge/
228- with :
229- name : Merged-Artifact-As
230- pattern : ' Artifact-A-*'
231- separate-directories : true
232-
233- # Download merged artifacts and verify the correctness of the content
234- - name : ' Download merged artifacts'
235- uses : namespace-actions/download-artifact@v0
236- with :
237- name : Merged-Artifact-As
238- path : merged-artifact-a
239-
240- - name : ' Verify merged artifacts'
241- run : |
242- $files = @(
243- "merged-artifact-a/Artifact-A-ubuntu-latest/file1.txt",
244- "merged-artifact-a/Artifact-A-macos-latest/file1.txt",
245- "merged-artifact-a/Artifact-A-windows-latest/file1.txt"
246- )
247-
248- foreach ($file in $files) {
249- if (!(Test-Path $file)) {
250- Write-Error "$file does not exist."
251- }
252-
253- if (!((Get-Content $file) -ceq "This file has changed")) {
254- Write-Error "$file has incorrect content."
255- }
256- }
257- shell : pwsh
258-
160+ str="This file has changed"
161+ if [[ $(< overwrite/some/new/path/file1.txt) != "$str" ]]; then
162+ exit 1
163+ fi
0 commit comments