Skip to content

Commit c222145

Browse files
authored
ansible-docs-build-init - first tests (#19)
* add tests for build-init action * add .test path from #18 * add a requirements.txt * flesh out the init tests * fix defaulted * fix defaults again * round 3
1 parent 5375959 commit c222145

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: test - action/build-init
2+
on:
3+
push:
4+
branches: [main]
5+
paths:
6+
- .test/**
7+
- .github/workflows/test-action-build-init.yml
8+
- actions/ansibe-docs-build-init/**
9+
pull_request:
10+
paths:
11+
- .test/**
12+
- .github/workflows/test-action-build-init.yml
13+
- actions/ansibe-docs-build-init/**
14+
15+
jobs:
16+
tests:
17+
name: Init tests
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
skip-init: [false]
23+
collections:
24+
- ''
25+
- 'fake.collection'
26+
- 'first.collection second.collection'
27+
dest: ['']
28+
include:
29+
- skip-init: true
30+
dest: .test/simple-build
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v2
35+
36+
- name: Install Python
37+
uses: actions/setup-python@v2
38+
with:
39+
python-version: 3.9
40+
41+
# if we pass an empty string to dest-dir, it will override the default.
42+
# we can't copy the default into the matrix because it uses a templating
43+
# context (runner) that's unavailable in matrix.
44+
# We can't use two steps with opposing conditionals because we can't re-use
45+
# the id (and we need it in later steps).
46+
- name: Init
47+
id: init
48+
uses: ./actions/ansible-docs-build-init
49+
with:
50+
collections: ${{ matrix.collection }}
51+
# combining runner.temp and /docsbuild copies the default from the action
52+
# please keep in sync!
53+
dest-dir: ${{ matrix.dest || format('{0}/{1}', runner.temp, '/docsbuild') }}
54+
skip-init: ${{ matrix.skip-init }}
55+
56+
- name: assert
57+
env:
58+
output_build_script: ${{ steps.init.outputs.build-script }}
59+
output_build_html: ${{ steps.init.outputs.build-html }}
60+
run: |
61+
# check that the build script exists
62+
[ -f "$output_build_script" ] || exit 1
63+
64+
# html dir is not guaranteed to exist but it is always at the same relative path
65+
# we'll use this to get to the "root" (dest-dir), even when we used a defaulted dir.
66+
mkdir -p "$output_build_html"
67+
cd "$output_build_html/../.."
68+
69+
# by now, all requirements should have been installed, let's pip freeze
70+
pip freeze > "${{ runner.temp }}/pre-freeze.txt"
71+
72+
# now we'll try to do a pip install again with the requirements file
73+
pip install -r "requirements.txt" --disable-pip-version-check
74+
75+
# and pip freeze again to compare
76+
pip freeze > "${{ runner.temp }}/post-freeze.txt"
77+
78+
cmp "${{ runner.temp }}/pre-freeze.txt" "${{ runner.temp }}/post-freeze.txt" || exit 1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
antsibull
2+
ansible-pygments
3+
sphinx
4+
sphinx-ansible-theme
5+
6+
# This is a package that is not likely to be installed as a dependency
7+
# of antsibull (which is usually used to generate this file),
8+
# so that we can test that the additional requirements install worked.
9+
# Suggestions for a better candidate package are welcome!
10+
hvac

0 commit comments

Comments
 (0)