Skip to content

Commit 5ad50fa

Browse files
build-html - ensure artifact root matches build html root (#25)
* try trailing slash * fix workflow trigger path typos * try again with no slash * test for artifact download structure * add trailing slash to rsync * add a test with trailing slash in input too * more trailings * Update actions/ansible-docs-build-html/action.yml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
1 parent 899f794 commit 5ad50fa

File tree

3 files changed

+67
-13
lines changed

3 files changed

+67
-13
lines changed

.github/workflows/test-action-build-html.yml

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ on:
66
paths:
77
- .test/**
88
- .github/workflows/test-action-build-html.yml
9-
- actions/ansibe-docs-build-html/**
9+
- actions/ansible-docs-build-html/**
1010
pull_request:
1111
paths:
1212
- .test/**
1313
- .github/workflows/test-action-build-html.yml
14-
- actions/ansibe-docs-build-html/**
14+
- actions/ansible-docs-build-html/**
1515

1616
jobs:
1717
tests:
@@ -104,10 +104,16 @@ jobs:
104104
assert output_hash == expected_hash
105105
assert artifact_hash == output_hash
106106
107-
- name: Simple 3 - assert artifact url
108-
# this URL only goes to the run page, not to an individual artifact
109-
# so all we're really checking here is that it's a valid URL that's accessible
110-
run: wget '${{ steps.simple3.outputs.artifact-url }}'
107+
- name: Simple 3 - bash asserts
108+
run: |
109+
set -eu
110+
111+
# this URL only goes to the run page, not to an individual artifact
112+
# so all we're really checking here is that it's a valid URL that's accessible
113+
wget '${{ steps.simple3.outputs.artifact-url }}'
114+
115+
# ensure that the html directory is not present in the downloaded artifact
116+
test ! -d "${{ steps.simple3-artifact.outputs.download-path }}/html"
111117
112118
- name: Simple 4 invoke - with copy, with artifact
113119
id: simple4
@@ -140,7 +146,55 @@ jobs:
140146
assert output_hash == original_build_hash
141147
assert artifact_hash == output_hash
142148
143-
- name: Simple 4 - assert artifact url
144-
# this URL only goes to the run page, not to an individual artifact
145-
# so all we're really checking here is that it's a valid URL that's accessible
146-
run: wget '${{ steps.simple4.outputs.artifact-url }}'
149+
- name: Simple 4 - bash asserts
150+
run: |
151+
set -eu
152+
153+
# this URL only goes to the run page, not to an individual artifact
154+
# so all we're really checking here is that it's a valid URL that's accessible
155+
wget '${{ steps.simple4.outputs.artifact-url }}'
156+
157+
# ensure that the html directory is not present in the downloaded artifact
158+
test ! -d "${{ steps.simple4-artifact.outputs.download-path }}/html"
159+
160+
- name: Simple 5 invoke - with copy, with artifact, trailing slash in input
161+
id: simple5
162+
uses: ./actions/ansible-docs-build-html
163+
with:
164+
build-script: .test/simple-build/build.sh
165+
build-html: .test/simple-build/build/html/
166+
copy-build: .copies/simple5/html/
167+
artifact-retention-days: 1
168+
artifact-name: tests-simple5
169+
170+
- name: Simple 5 - Download artifacts
171+
uses: actions/download-artifact@v2
172+
id: simple5-artifact
173+
with:
174+
name: ${{ steps.simple5.outputs.artifact-name }}
175+
path: .artifacts/simple5
176+
177+
- name: Simple 5 - assert
178+
shell: python
179+
run: |
180+
expected_hash = r'${{ hashFiles('.test/simple-build/src') }}'
181+
output_hash = r'${{ steps.simple5.outputs.hash }}'
182+
output_build_html = r'${{ steps.simple5.outputs.build-html }}'
183+
artifact_hash = r'${{ hashFiles(steps.simple5-artifact.outputs.download-path) }}'
184+
original_build_hash = r'${{ hashFiles('.test/simple-build/build/html/') }}'
185+
186+
assert output_build_html == '.copies/simple5/html/'
187+
assert output_hash == expected_hash
188+
assert output_hash == original_build_hash
189+
assert artifact_hash == output_hash
190+
191+
- name: Simple 5 - bash asserts
192+
run: |
193+
set -eu
194+
195+
# this URL only goes to the run page, not to an individual artifact
196+
# so all we're really checking here is that it's a valid URL that's accessible
197+
wget '${{ steps.simple5.outputs.artifact-url }}'
198+
199+
# ensure that the html directory is not present in the downloaded artifact
200+
test ! -d "${{ steps.simple5-artifact.outputs.download-path }}/html"

.github/workflows/test-action-build-init.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ on:
55
paths:
66
- .test/**
77
- .github/workflows/test-action-build-init.yml
8-
- actions/ansibe-docs-build-init/**
8+
- actions/ansible-docs-build-init/**
99
pull_request:
1010
paths:
1111
- .test/**
1212
- .github/workflows/test-action-build-init.yml
13-
- actions/ansibe-docs-build-init/**
13+
- actions/ansible-docs-build-init/**
1414

1515
jobs:
1616
tests:

actions/ansible-docs-build-html/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ runs:
5858
if [[ "$COPY_BUILD" != "" ]] ; then
5959
echo "::group::Copy the build files"
6060
mkdir -p "$COPY_BUILD"
61-
rsync -avc --delete-after "$HTML" "$COPY_BUILD"
61+
rsync -avc --delete-after "$HTML/" "$COPY_BUILD/"
6262
echo "::set-output name=build-html::$COPY_BUILD"
6363
echo "::endgroup::"
6464
else

0 commit comments

Comments
 (0)