|
| 1 | +name: Integration Tests (MySQL) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions |
| 8 | +permissions: |
| 9 | + # NOTE: actions/upload-artifact makes no use of permissions |
| 10 | + # See https://github.com/actions/upload-artifact/issues/197#issuecomment-832279436 |
| 11 | + contents: read # for "git clone" |
| 12 | + |
| 13 | +defaults: |
| 14 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun |
| 15 | + run: |
| 16 | + # Enable fail-fast behavior using set -eo pipefail |
| 17 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference |
| 18 | + shell: bash |
| 19 | + |
| 20 | +jobs: |
| 21 | + run-integration-tests: |
| 22 | + name: Integration Tests |
| 23 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on |
| 24 | + runs-on: ubuntu-20.04 |
| 25 | + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idservices |
| 26 | + services: |
| 27 | + db: |
| 28 | + # https://hub.docker.com/_/mysql |
| 29 | + # https://github.com/docker-library/mysql/blob/429047ac5e28d59d40a2ac84a189c9d25310f060/5.7/Dockerfile |
| 30 | + # NOTE: it's better to have the same as in infra/docker/postgres.yml |
| 31 | + image: mysql:5.7.20 |
| 32 | + env: |
| 33 | + # NOTE: it's better to have credentials the same as in infra/docker/prod.yml and src/main/resources/application-travis.properties |
| 34 | + # the generated root password will be printed to stdout (GENERATED ROOT PASSWORD: ...) |
| 35 | + MYSQL_RANDOM_ROOT_PASSWORD: 'true' |
| 36 | + MYSQL_USER: mystamps |
| 37 | + MYSQL_PASSWORD: secret |
| 38 | + # the user specified above will be granted superuser access automatically |
| 39 | + MYSQL_DATABASE: mystamps |
| 40 | + options: >- |
| 41 | + --health-cmd "mysqladmin ping --user mystamps --password=secret" |
| 42 | + --health-start-period 1s |
| 43 | + --health-interval 1s |
| 44 | + --health-retries 10 |
| 45 | + --health-timeout 5s |
| 46 | + # https://docs.github.com/en/actions/using-containerized-services/about-service-containers#mapping-docker-host-and-service-container-ports |
| 47 | + ports: |
| 48 | + # <host port>:<container port> |
| 49 | + - '3306:3306' |
| 50 | + steps: |
| 51 | + - name: Clone source code |
| 52 | + uses: actions/[email protected] # https://github.com/actions/checkout |
| 53 | + with: |
| 54 | + # Whether to configure the token or SSH key with the local git config. Default: true |
| 55 | + persist-credentials: false |
| 56 | + - name: Install JDK |
| 57 | + uses: actions/[email protected] # https://github.com/actions/setup-java |
| 58 | + with: |
| 59 | + distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions |
| 60 | + java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax |
| 61 | + cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies |
| 62 | + # This is a workaround for github action limitation: we can't specify command for the service (--character-set-server=utf8) |
| 63 | + # and have to modify database manually. See also: |
| 64 | + # https://github.com/actions/runner/discussions/1872 and https://github.com/orgs/community/discussions/26688 |
| 65 | + # @todo #1154 Set charset of MySQL container by providing a custom my.cnf |
| 66 | + - name: Change character set on database |
| 67 | + run: >- |
| 68 | + docker exec ${{ job.services.db.id }} \ |
| 69 | + mysql \ |
| 70 | + --user mystamps \ |
| 71 | + --password=secret \ |
| 72 | + --execute 'ALTER DATABASE mystamps CHARACTER SET utf8' |
| 73 | + - name: Run integration tests |
| 74 | + env: |
| 75 | + SPRING_PROFILES_ACTIVE: travis |
| 76 | + run: | |
| 77 | + mkdir -p /tmp/uploads /tmp/preview |
| 78 | + cp src/main/resources/test/test.png /tmp/uploads/1.png |
| 79 | + ./src/main/scripts/execute-command.sh integration-tests |
| 80 | + - name: Save RobotFramework reports |
| 81 | + if: ${{ failure() }} |
| 82 | + uses: actions/[email protected] # https://github.com/actions/upload-artifact |
| 83 | + with: |
| 84 | + name: robotframework-reports |
| 85 | + path: target/robotframework-reports/ |
0 commit comments