|
| 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 |
0 commit comments