|
| 1 | +--- |
| 2 | +name: test - action/build-html |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - .test/** |
| 8 | + - .github/workflows/test-action-build-html.yml |
| 9 | + - actions/ansibe-docs-build-html/** |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - .test/** |
| 13 | + - .github/workflows/test-action-build-html.yml |
| 14 | + - actions/ansibe-docs-build-html/** |
| 15 | + |
| 16 | +jobs: |
| 17 | + tests: |
| 18 | + name: Simple tests |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v2 |
| 23 | + |
| 24 | + - name: Simple 1 invoke - no copy, no artifact |
| 25 | + id: simple1 |
| 26 | + uses: ./actions/ansible-docs-build-html |
| 27 | + with: |
| 28 | + build-script: .test/simple-build/build.sh |
| 29 | + build-html: .test/simple-build/build/html |
| 30 | + artifact-upload: false |
| 31 | + |
| 32 | + - name: Simple 1 - Download artifacts |
| 33 | + uses: actions/download-artifact@v2 |
| 34 | + id: simple1-artifact |
| 35 | + with: |
| 36 | + path: .artifacts/simple1 |
| 37 | + |
| 38 | + - name: Simple 1 - assert |
| 39 | + shell: python |
| 40 | + run: | |
| 41 | + expected_hash = r'${{ hashFiles('.test/simple-build/src') }}' |
| 42 | + output_hash = r'${{ steps.simple1.outputs.hash }}' |
| 43 | + output_build_html = r'${{ steps.simple1.outputs.build-html }}' |
| 44 | + artifact_hash = r'${{ hashFiles(steps.simple1-artifact.outputs.download-path) }}' |
| 45 | +
|
| 46 | + assert output_build_html == '.test/simple-build/build/html' |
| 47 | + assert output_hash == expected_hash |
| 48 | + assert artifact_hash != output_hash |
| 49 | +
|
| 50 | + - name: Simple 2 invoke - with copy, no artifact |
| 51 | + id: simple2 |
| 52 | + uses: ./actions/ansible-docs-build-html |
| 53 | + with: |
| 54 | + build-script: .test/simple-build/build.sh |
| 55 | + build-html: .test/simple-build/build/html |
| 56 | + copy-build: .copies/simple2/html |
| 57 | + artifact-upload: false |
| 58 | + |
| 59 | + - name: Simple 2 - Download artifacts |
| 60 | + uses: actions/download-artifact@v2 |
| 61 | + id: simple2-artifact |
| 62 | + with: |
| 63 | + path: .artifacts/simple2 |
| 64 | + |
| 65 | + - name: Simple 2 - assert |
| 66 | + shell: python |
| 67 | + run: | |
| 68 | + expected_hash = r'${{ hashFiles('.test/simple-build/src') }}' |
| 69 | + output_hash = r'${{ steps.simple2.outputs.hash }}' |
| 70 | + output_build_html = r'${{ steps.simple2.outputs.build-html }}' |
| 71 | + artifact_hash = r'${{ hashFiles(steps.simple2-artifact.outputs.download-path) }}' |
| 72 | + original_build_hash = r'${{ hashFiles('.test/simple-build/build/html') }}' |
| 73 | +
|
| 74 | + assert output_build_html == '.copies/simple2/html' |
| 75 | + assert output_hash == expected_hash |
| 76 | + assert output_hash == original_build_hash |
| 77 | + assert artifact_hash != output_hash |
| 78 | +
|
| 79 | + - name: Simple 3 invoke - no copy, with artifact |
| 80 | + id: simple3 |
| 81 | + uses: ./actions/ansible-docs-build-html |
| 82 | + with: |
| 83 | + build-script: .test/simple-build/build.sh |
| 84 | + build-html: .test/simple-build/build/html |
| 85 | + artifact-retention-days: 1 |
| 86 | + artifact-name: tests-simple3 |
| 87 | + |
| 88 | + - name: Simple 3 - Download artifacts |
| 89 | + uses: actions/download-artifact@v2 |
| 90 | + id: simple3-artifact |
| 91 | + with: |
| 92 | + name: ${{ steps.simple3.outputs.artifact-name }} |
| 93 | + path: .artifacts/simple3 |
| 94 | + |
| 95 | + - name: Simple 3 - assert |
| 96 | + shell: python |
| 97 | + run: | |
| 98 | + expected_hash = r'${{ hashFiles('.test/simple-build/src') }}' |
| 99 | + output_hash = r'${{ steps.simple3.outputs.hash }}' |
| 100 | + output_build_html = r'${{ steps.simple3.outputs.build-html }}' |
| 101 | + artifact_hash = r'${{ hashFiles(steps.simple3-artifact.outputs.download-path) }}' |
| 102 | +
|
| 103 | + assert output_build_html == '.test/simple-build/build/html' |
| 104 | + assert output_hash == expected_hash |
| 105 | + assert artifact_hash == output_hash |
| 106 | +
|
| 107 | + - name: Simple 3 - assert artifact url |
| 108 | + # this URL only goes to the run page, not to an individual artifact |
| 109 | + # so all we're really checking here is that it's a valid URL that's accessible |
| 110 | + run: wget '${{ steps.simple3.outputs.artifact-url }}' |
| 111 | + |
| 112 | + - name: Simple 4 invoke - with copy, with artifact |
| 113 | + id: simple4 |
| 114 | + uses: ./actions/ansible-docs-build-html |
| 115 | + with: |
| 116 | + build-script: .test/simple-build/build.sh |
| 117 | + build-html: .test/simple-build/build/html |
| 118 | + copy-build: .copies/simple4/html |
| 119 | + artifact-retention-days: 1 |
| 120 | + artifact-name: tests-simple4 |
| 121 | + |
| 122 | + - name: Simple 4 - Download artifacts |
| 123 | + uses: actions/download-artifact@v2 |
| 124 | + id: simple4-artifact |
| 125 | + with: |
| 126 | + name: ${{ steps.simple4.outputs.artifact-name }} |
| 127 | + path: .artifacts/simple4 |
| 128 | + |
| 129 | + - name: Simple 4 - assert |
| 130 | + shell: python |
| 131 | + run: | |
| 132 | + expected_hash = r'${{ hashFiles('.test/simple-build/src') }}' |
| 133 | + output_hash = r'${{ steps.simple4.outputs.hash }}' |
| 134 | + output_build_html = r'${{ steps.simple4.outputs.build-html }}' |
| 135 | + artifact_hash = r'${{ hashFiles(steps.simple4-artifact.outputs.download-path) }}' |
| 136 | + original_build_hash = r'${{ hashFiles('.test/simple-build/build/html') }}' |
| 137 | +
|
| 138 | + assert output_build_html == '.copies/simple4/html' |
| 139 | + assert output_hash == expected_hash |
| 140 | + assert output_hash == original_build_hash |
| 141 | + assert artifact_hash == output_hash |
| 142 | +
|
| 143 | + - name: Simple 4 - assert artifact url |
| 144 | + # this URL only goes to the run page, not to an individual artifact |
| 145 | + # so all we're really checking here is that it's a valid URL that's accessible |
| 146 | + run: wget '${{ steps.simple4.outputs.artifact-url }}' |
0 commit comments