From 4bef062745dbe9b399b1990dcdb7e3831b71c03e Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:12:51 -0500 Subject: [PATCH 1/7] add tests for build-init action --- .github/workflows/test-action-build-init.yml | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/test-action-build-init.yml diff --git a/.github/workflows/test-action-build-init.yml b/.github/workflows/test-action-build-init.yml new file mode 100644 index 0000000..1484585 --- /dev/null +++ b/.github/workflows/test-action-build-init.yml @@ -0,0 +1,53 @@ +name: test - action/build-init +on: + push: + branches: [main] + paths: + # - .test/** + - .github/workflows/test-action-build-init.yml + - actions/ansibe-docs-build-init/** + pull_request: + paths: + # - .test/** + - .github/workflows/test-action-build-init.yml + - actions/ansibe-docs-build-init/** + +jobs: + tests: + name: Init tests + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + skip-init: [false] + collections: + - '' + - 'fake.collection' + - 'first.collection second.collection' + dest: [''] + include: + - skip-init: true + dest: .test/simple-build + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Init + id: init + uses: ./actions/ansible-docs-build-init + with: + collections: ${{ matrix.collection }} + dest-dir: ${{ matrix.dest }} + skip-init: ${{ matrix.skip-init }} + + - name: assert + shell: python + run: | + output_build_script = r'${{ steps.init.outputs.build-script }}' + output_build_html = r'${{ steps.init.outputs.build-html }}' From d2f6d6fcebef2ec5773254c93a5f7b171b8a3220 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:19:27 -0500 Subject: [PATCH 2/7] add .test path from #18 --- .test/simple-build/build.sh | 9 +++++++++ .test/simple-build/src/index.html | 8 ++++++++ .test/simple-build/src/other.html | 8 ++++++++ 3 files changed, 25 insertions(+) create mode 100755 .test/simple-build/build.sh create mode 100644 .test/simple-build/src/index.html create mode 100644 .test/simple-build/src/other.html diff --git a/.test/simple-build/build.sh b/.test/simple-build/build.sh new file mode 100755 index 0000000..037edaa --- /dev/null +++ b/.test/simple-build/build.sh @@ -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 diff --git a/.test/simple-build/src/index.html b/.test/simple-build/src/index.html new file mode 100644 index 0000000..4cc5a34 --- /dev/null +++ b/.test/simple-build/src/index.html @@ -0,0 +1,8 @@ + + + Test Index + + +

Test Index

+ + diff --git a/.test/simple-build/src/other.html b/.test/simple-build/src/other.html new file mode 100644 index 0000000..9921e3e --- /dev/null +++ b/.test/simple-build/src/other.html @@ -0,0 +1,8 @@ + + + Other HTML + + +

Other HTML

+ + From 4c78e8595ef6737e881aada7446fb9d8c88d4b85 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:29:22 -0500 Subject: [PATCH 3/7] add a requirements.txt --- .test/simple-build/requirements.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .test/simple-build/requirements.txt diff --git a/.test/simple-build/requirements.txt b/.test/simple-build/requirements.txt new file mode 100644 index 0000000..7e16203 --- /dev/null +++ b/.test/simple-build/requirements.txt @@ -0,0 +1,10 @@ +antsibull +ansible-pygments +sphinx +sphinx-ansible-theme + +# This is a package that is not likely to be installed as a dependency +# of antsibull (which is usually used to generate this file), +# so that we can test that the additional requirements install worked. +# Suggestions for a better candidate package are welcome! +hvac From 2825fe9f1f3b435acb11030fdaa7d62bd18cb874 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:45:46 -0500 Subject: [PATCH 4/7] flesh out the init tests --- .github/workflows/test-action-build-init.yml | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-action-build-init.yml b/.github/workflows/test-action-build-init.yml index 1484585..ff878d0 100644 --- a/.github/workflows/test-action-build-init.yml +++ b/.github/workflows/test-action-build-init.yml @@ -3,12 +3,12 @@ on: push: branches: [main] paths: - # - .test/** + - .test/** - .github/workflows/test-action-build-init.yml - actions/ansibe-docs-build-init/** pull_request: paths: - # - .test/** + - .test/** - .github/workflows/test-action-build-init.yml - actions/ansibe-docs-build-init/** @@ -47,7 +47,25 @@ jobs: skip-init: ${{ matrix.skip-init }} - name: assert - shell: python + env: + output_build_script: ${{ steps.init.outputs.build-script }} + output_build_html: ${{ steps.init.outputs.build-html }} run: | - output_build_script = r'${{ steps.init.outputs.build-script }}' - output_build_html = r'${{ steps.init.outputs.build-html }}' + # check that the vuild script exists + [ -f "$output_build_script" ] || exit 1 + + # html dir is not guaranteed to exist but it is always at the same relative path + # we'll use this to get to the "root" (dest-dir), even when we used a defaulted dir. + mkdir -p "$output_build_html" + cd "$output_build_html/../.." + + # by now, all requirements should have been installed, let's pip freeze + pip freeze > "${{ runner.temp }}/pre-freeze.txt" + + # now we'll try to do a pip install again with the requirements file + pip install -r "requirements.txt" --disable-pip-version-check + + # and pip freeze again to compare + pip freeze > "${{ runner.temp }}/post-freeze.txt" + + cmp "${{ runner.temp }}/pre-freeze.txt" "${{ runner.temp }}/post-freeze.txt" || exit 1 From f5b1f052875d21ea13dc6349b7a7cb7b760336fb Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:55:45 -0500 Subject: [PATCH 5/7] fix defaulted --- .github/workflows/test-action-build-init.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-action-build-init.yml b/.github/workflows/test-action-build-init.yml index ff878d0..efb97db 100644 --- a/.github/workflows/test-action-build-init.yml +++ b/.github/workflows/test-action-build-init.yml @@ -24,7 +24,7 @@ jobs: - '' - 'fake.collection' - 'first.collection second.collection' - dest: [''] + dest: ['${{ runner.temp }}/docsbuild'] # duplicating the action's default, need to keep in sync include: - skip-init: true dest: .test/simple-build @@ -51,7 +51,7 @@ jobs: output_build_script: ${{ steps.init.outputs.build-script }} output_build_html: ${{ steps.init.outputs.build-html }} run: | - # check that the vuild script exists + # check that the build script exists [ -f "$output_build_script" ] || exit 1 # html dir is not guaranteed to exist but it is always at the same relative path From 028b52a6d132d82a15159e133a33d054a2990d8a Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:58:37 -0500 Subject: [PATCH 6/7] fix defaults again --- .github/workflows/test-action-build-init.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-action-build-init.yml b/.github/workflows/test-action-build-init.yml index efb97db..3027000 100644 --- a/.github/workflows/test-action-build-init.yml +++ b/.github/workflows/test-action-build-init.yml @@ -24,7 +24,7 @@ jobs: - '' - 'fake.collection' - 'first.collection second.collection' - dest: ['${{ runner.temp }}/docsbuild'] # duplicating the action's default, need to keep in sync + dest: [''] include: - skip-init: true dest: .test/simple-build @@ -39,6 +39,7 @@ jobs: python-version: 3.9 - name: Init + if: matrix.dest != '' id: init uses: ./actions/ansible-docs-build-init with: @@ -46,6 +47,17 @@ jobs: dest-dir: ${{ matrix.dest }} skip-init: ${{ matrix.skip-init }} + # if we pass the empty string, it will override the default + # we can't copy the default either because it uses a templating + # context (runner) that's unavailable in matrix. + - name: Init + if: matrix.dest == '' + id: init + uses: ./actions/ansible-docs-build-init + with: + collections: ${{ matrix.collection }} + skip-init: ${{ matrix.skip-init }} + - name: assert env: output_build_script: ${{ steps.init.outputs.build-script }} From 77e26518e92fa4aab213a0fc5d8a1ce8bc350b20 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Sat, 15 Jan 2022 17:03:23 -0500 Subject: [PATCH 7/7] round 3 --- .github/workflows/test-action-build-init.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-action-build-init.yml b/.github/workflows/test-action-build-init.yml index 3027000..8c99cba 100644 --- a/.github/workflows/test-action-build-init.yml +++ b/.github/workflows/test-action-build-init.yml @@ -38,24 +38,19 @@ jobs: with: python-version: 3.9 - - name: Init - if: matrix.dest != '' - id: init - uses: ./actions/ansible-docs-build-init - with: - collections: ${{ matrix.collection }} - dest-dir: ${{ matrix.dest }} - skip-init: ${{ matrix.skip-init }} - - # if we pass the empty string, it will override the default - # we can't copy the default either because it uses a templating + # if we pass an empty string to dest-dir, it will override the default. + # we can't copy the default into the matrix because it uses a templating # context (runner) that's unavailable in matrix. + # We can't use two steps with opposing conditionals because we can't re-use + # the id (and we need it in later steps). - name: Init - if: matrix.dest == '' id: init uses: ./actions/ansible-docs-build-init with: collections: ${{ matrix.collection }} + # combining runner.temp and /docsbuild copies the default from the action + # please keep in sync! + dest-dir: ${{ matrix.dest || format('{0}/{1}', runner.temp, '/docsbuild') }} skip-init: ${{ matrix.skip-init }} - name: assert