ci: run integration tests for Chi/Golang/MySQL #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration Tests | |
on: | |
push: | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions | |
permissions: | |
# NOTE: actions/upload-artifact makes no use of permissions | |
# See https://github.com/actions/upload-artifact/issues/197#issuecomment-832279436 | |
contents: read # for "git clone" | |
defaults: | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun | |
run: | |
# Enable fail-fast behavior using set -eo pipefail | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference | |
shell: bash | |
jobs: | |
run-integration-tests: | |
name: Integration Tests | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
runs-on: ubuntu-20.04 | |
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs | |
strategy: | |
matrix: | |
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#example-adding-configurations | |
include: | |
# "docker-service-name" must match "services.$name" from docker-compose.yaml | |
# "application-port" must match "services.$name.environment:PORT" from docker-compose.yaml | |
- docker-service-name: 'express-js' | |
application-port: 3010 | |
- service-name: 'express-ts' | |
application-port: 3020 | |
- service-name: 'chi' | |
application-port: 3030 | |
steps: | |
- name: Clone source code | |
uses: actions/[email protected] # https://github.com/actions/checkout | |
with: | |
# Whether to configure the token or SSH key with the local git config. Default: true | |
persist-credentials: false | |
- name: Install Hurl | |
run: | | |
DEB=hurl_4.2.0_amd64.deb | |
curl --location --no-progress-meter --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/4.2.0/$DEB | |
sudo dpkg --install $DEB | |
- name: Show tools versions | |
run: | | |
hurl --version | |
docker compose version | |
docker version | |
- name: Start containers | |
working-directory: docker | |
run: >- | |
docker compose up \ | |
--build \ | |
--detach \ | |
--wait \ | |
${{ matrix.docker-service-name }} | |
- name: Show container statuses | |
working-directory: docker | |
run: docker compose ps | |
- name: Run integration tests | |
run: >- | |
hurl \ | |
--error-format long \ | |
--report-html hurl-reports \ | |
--variable SERVER_URL=http://127.0.0.1:${{ matrix.application-port }} \ | |
--test \ | |
tests/crud.hurl | |
- name: Save container logs | |
if: failure() | |
working-directory: docker | |
run: docker compose logs --timestamps | tee ../hurl-reports/containers-logs.txt | |
- name: Stop containers | |
if: always() | |
working-directory: docker | |
run: >- | |
docker compose down \ | |
--volumes \ | |
--remove-orphans \ | |
--rmi local | |
- name: Save report | |
if: failure() | |
uses: actions/[email protected] # https://github.com/actions/upload-artifact | |
with: | |
name: report-and-logs | |
path: hurl-reports/ |