Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/_shared-docs-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
with:
build-script: ${{ steps.init-base.outputs.build-script }}
build-html: ${{ steps.init-base.outputs.build-html }}
move-build: ${{ github.workspace }}/docsbuild/base
copy-build: ${{ github.workspace }}/docsbuild/base
artifact-upload: 'false'

- name: Checkout HEAD
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:
with:
build-script: ${{ steps.init-head.outputs.build-script }}
build-html: ${{ steps.init-head.outputs.build-html }}
move-build: ${{ github.workspace }}/docsbuild/head
copy-build: ${{ github.workspace }}/docsbuild/head
artifact-name: ${{ inputs.artifact-name }}

- name: Get a diff of the changes
Expand Down
146 changes: 146 additions & 0 deletions .github/workflows/test-action-build-html.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
name: test - action/build-html
on:
push:
branches: [main]
paths:
- .test/**
- .github/workflows/test-action-build-html.yml
- actions/ansibe-docs-build-html/**
pull_request:
paths:
- .test/**
- .github/workflows/test-action-build-html.yml
- actions/ansibe-docs-build-html/**

jobs:
tests:
name: Simple tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Simple 1 invoke - no copy, no artifact
id: simple1
uses: ./actions/ansible-docs-build-html
with:
build-script: .test/simple-build/build.sh
build-html: .test/simple-build/build/html
artifact-upload: false

- name: Simple 1 - Download artifacts
uses: actions/download-artifact@v2
id: simple1-artifact
with:
path: .artifacts/simple1

- name: Simple 1 - assert
shell: python
run: |
expected_hash = r'${{ hashFiles('.test/simple-build/src') }}'
output_hash = r'${{ steps.simple1.outputs.hash }}'
output_build_html = r'${{ steps.simple1.outputs.build-html }}'
artifact_hash = r'${{ hashFiles(steps.simple1-artifact.outputs.download-path) }}'

assert output_build_html == '.test/simple-build/build/html'
assert output_hash == expected_hash
assert artifact_hash != output_hash

- name: Simple 2 invoke - with copy, no artifact
id: simple2
uses: ./actions/ansible-docs-build-html
with:
build-script: .test/simple-build/build.sh
build-html: .test/simple-build/build/html
copy-build: .copies/simple2/html
artifact-upload: false

- name: Simple 2 - Download artifacts
uses: actions/download-artifact@v2
id: simple2-artifact
with:
path: .artifacts/simple2

- name: Simple 2 - assert
shell: python
run: |
expected_hash = r'${{ hashFiles('.test/simple-build/src') }}'
output_hash = r'${{ steps.simple2.outputs.hash }}'
output_build_html = r'${{ steps.simple2.outputs.build-html }}'
artifact_hash = r'${{ hashFiles(steps.simple2-artifact.outputs.download-path) }}'
original_build_hash = r'${{ hashFiles('.test/simple-build/build/html') }}'

assert output_build_html == '.copies/simple2/html'
assert output_hash == expected_hash
assert output_hash == original_build_hash
assert artifact_hash != output_hash

- name: Simple 3 invoke - no copy, with artifact
id: simple3
uses: ./actions/ansible-docs-build-html
with:
build-script: .test/simple-build/build.sh
build-html: .test/simple-build/build/html
artifact-retention-days: 1
artifact-name: tests-simple3

- name: Simple 3 - Download artifacts
uses: actions/download-artifact@v2
id: simple3-artifact
with:
name: ${{ steps.simple3.outputs.artifact-name }}
path: .artifacts/simple3

- name: Simple 3 - assert
shell: python
run: |
expected_hash = r'${{ hashFiles('.test/simple-build/src') }}'
output_hash = r'${{ steps.simple3.outputs.hash }}'
output_build_html = r'${{ steps.simple3.outputs.build-html }}'
artifact_hash = r'${{ hashFiles(steps.simple3-artifact.outputs.download-path) }}'

assert output_build_html == '.test/simple-build/build/html'
assert output_hash == expected_hash
assert artifact_hash == output_hash

- name: Simple 3 - assert artifact url
# this URL only goes to the run page, not to an individual artifact
# so all we're really checking here is that it's a valid URL that's accessible
run: wget '${{ steps.simple3.outputs.artifact-url }}'

- name: Simple 4 invoke - with copy, with artifact
id: simple4
uses: ./actions/ansible-docs-build-html
with:
build-script: .test/simple-build/build.sh
build-html: .test/simple-build/build/html
copy-build: .copies/simple4/html
artifact-retention-days: 1
artifact-name: tests-simple4

- name: Simple 4 - Download artifacts
uses: actions/download-artifact@v2
id: simple4-artifact
with:
name: ${{ steps.simple4.outputs.artifact-name }}
path: .artifacts/simple4

- name: Simple 4 - assert
shell: python
run: |
expected_hash = r'${{ hashFiles('.test/simple-build/src') }}'
output_hash = r'${{ steps.simple4.outputs.hash }}'
output_build_html = r'${{ steps.simple4.outputs.build-html }}'
artifact_hash = r'${{ hashFiles(steps.simple4-artifact.outputs.download-path) }}'
original_build_hash = r'${{ hashFiles('.test/simple-build/build/html') }}'

assert output_build_html == '.copies/simple4/html'
assert output_hash == expected_hash
assert output_hash == original_build_hash
assert artifact_hash == output_hash

- name: Simple 4 - assert artifact url
# this URL only goes to the run page, not to an individual artifact
# so all we're really checking here is that it's a valid URL that's accessible
run: wget '${{ steps.simple4.outputs.artifact-url }}'
9 changes: 9 additions & 0 deletions .test/simple-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
pushd "${BASH_SOURCE%/*}"

rm -rf build/html
mkdir -p build/html
cp -R src/* build/html/

popd
8 changes: 8 additions & 0 deletions .test/simple-build/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Test Index</title>
</head>
<body>
<h1>Test Index</h1>
</body>
</html>
8 changes: 8 additions & 0 deletions .test/simple-build/src/other.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Other HTML</title>
</head>
<body>
<h1>Other HTML</h1>
</body>
</html>
17 changes: 9 additions & 8 deletions actions/ansible-docs-build-html/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ inputs:
description: The path where the build script will output the HTML.
required: false
default: ${{ runner.temp }}/docsbuild/build/html
move-build:
copy-build:
description: |
If set, move the built HTML to this path after building, and set the build-html output to this path instead.
If set, copy the built HTML files to this path after building, and set the build-html output to this path instead.
This is useful if you need to do multiple builds from the same environment, or otherwise need the files to be elsewhere.
Note: files in the destination that do not exist in the source will be deleted!
required: false
artifact-upload:
description: If true then upload the rendered docs as a build artifact.
Expand Down Expand Up @@ -52,13 +53,13 @@ runs:
echo "::endgroup::"

HTML="${{ inputs.build-html }}"
MOVE_BUILD="${{ inputs.move-build }}"
COPY_BUILD="${{ inputs.copy-build }}"

if [[ "$MOVE_BUILD" != "" ]] ; then
echo "::group::Move the build files"
mkdir -p "$MOVE_BUILD"
rsync -avc --delete-after "$HTML" "$MOVE_BUILD"
echo "::set-output name=build-html::$MOVE_BUILD"
if [[ "$COPY_BUILD" != "" ]] ; then
echo "::group::Copy the build files"
mkdir -p "$COPY_BUILD"
rsync -avc --delete-after "$HTML" "$COPY_BUILD"
echo "::set-output name=build-html::$COPY_BUILD"
echo "::endgroup::"
else
echo "::set-output name=build-html::$HTML"
Expand Down