|
| 1 | +name: Integration Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions |
| 7 | +permissions: |
| 8 | + # NOTE: actions/upload-artifact makes no use of permissions |
| 9 | + # See https://github.com/actions/upload-artifact/issues/197#issuecomment-832279436 |
| 10 | + contents: read # for "git clone" |
| 11 | + |
| 12 | +defaults: |
| 13 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun |
| 14 | + run: |
| 15 | + # Enable fail-fast behavior using set -eo pipefail |
| 16 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference |
| 17 | + shell: bash |
| 18 | + |
| 19 | +jobs: |
| 20 | + run-integration-tests: |
| 21 | + name: Integration Tests |
| 22 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on |
| 23 | + runs-on: ubuntu-20.04 |
| 24 | + steps: |
| 25 | + |
| 26 | + - name: Clone source code |
| 27 | + uses: actions/[email protected] # https://github.com/actions/checkout |
| 28 | + with: |
| 29 | + # Whether to configure the token or SSH key with the local git config. Default: true |
| 30 | + persist-credentials: false |
| 31 | + |
| 32 | + - name: Install Hurl |
| 33 | + run: | |
| 34 | + DEB=hurl_4.2.0_amd64.deb |
| 35 | + curl --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/4.2.0/$DEB |
| 36 | + dpkg --install $DEB |
| 37 | +
|
| 38 | + - name: Show tools versions |
| 39 | + run: | |
| 40 | + hurl --version |
| 41 | + docker compose version |
| 42 | + docker version |
| 43 | +
|
| 44 | + - name: Start containers |
| 45 | + working-directory: docker |
| 46 | + run: >- |
| 47 | + docker compose up \ |
| 48 | + --build \ |
| 49 | + --detach \ |
| 50 | + --wait \ |
| 51 | + express-js |
| 52 | +
|
| 53 | + - name: Show container statuses |
| 54 | + working-directory: docker |
| 55 | + run: docker compose ps |
| 56 | + |
| 57 | + - name: Run integration tests |
| 58 | + run: >- |
| 59 | + hurl \ |
| 60 | + --error-format long \ |
| 61 | + --report-html hurl-reports \ |
| 62 | + --variable SERVER_URL=http://127.0.0.1:3010 \ |
| 63 | + --test \ |
| 64 | + tests/crud.hurl |
| 65 | +
|
| 66 | + - name: Save container logs |
| 67 | + if: failure() |
| 68 | + working-directory: docker |
| 69 | + run: >- |
| 70 | + docker compose logs | tee containers-logs.txt |
| 71 | +
|
| 72 | + - name: Stop containers |
| 73 | + if: always() |
| 74 | + working-directory: docker |
| 75 | + run: >- |
| 76 | + docker compose down \ |
| 77 | + --volumes \ |
| 78 | + --remove-orphans \ |
| 79 | + --rmi all |
| 80 | +
|
| 81 | + - name: Save report |
| 82 | + if: failure() |
| 83 | + uses: actions/[email protected] # https://github.com/actions/upload-artifact |
| 84 | + with: |
| 85 | + name: report-and-logs |
| 86 | + path: | |
| 87 | + containers-logs.txt |
| 88 | + hurl-reports/ |
0 commit comments