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
78 changes: 78 additions & 0 deletions .github/workflows/test-action-build-init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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

# 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
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
env:
output_build_script: ${{ steps.init.outputs.build-script }}
output_build_html: ${{ steps.init.outputs.build-html }}
run: |
# 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
# 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
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
10 changes: 10 additions & 0 deletions .test/simple-build/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
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>