Test latest DB weekly #164
This file contains 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: Test latest DB weekly | |
# Notes: | |
# * secrets.CACHE_VERSION: Is a defined secret with a UUIDv4 as version, | |
# the reason for this is because there is currently no other way of resetting the cache. | |
on: | |
schedule: | |
- cron: "0 8 * * 1" | |
env: | |
MYSQL_USER: mysql | |
MYSQL_PASSWORD: mysql | |
MYSQL_DATABASE: ecto_mysql_extras_test | |
MYSQL_HOST: localhost | |
MYSQL_ROOT_PASSWORD: mysql_root_password | |
jobs: | |
setup: | |
name: Setup / OTP ${{ matrix.otp }} / Elixir ${{ matrix.elixir }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
otp: ["27"] | |
elixir: ["1.17"] | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v4 | |
- uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{matrix.otp}} | |
elixir-version: ${{matrix.elixir}} | |
- name: Retrieve dependencies cache | |
uses: actions/cache@v4 | |
id: mix-cache | |
with: | |
path: | | |
deps | |
_build | |
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
- name: Install dependencies | |
if: steps.mix-cache.outputs.cache-hit != 'true' | |
run: | | |
mix deps.get | |
mix deps.compile | |
test: | |
name: Test ${{ matrix.db }} / OTP ${{ matrix.otp }} / Elixir ${{ matrix.elixir }} | |
runs-on: ubuntu-latest | |
needs: setup | |
strategy: | |
fail-fast: false | |
matrix: | |
db: ["mysql:latest", "mariadb:latest"] | |
otp: ["27"] | |
elixir: ["1.17"] | |
env: | |
MIX_ENV: test | |
services: | |
database: | |
image: ${{ matrix.db }} | |
env: | |
MYSQL_USER: ${{ env.MYSQL_USER }} | |
MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }} | |
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} | |
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | |
MYSQL_ROOT_HOST: "%" | |
options: >- | |
--health-cmd="${{ matrix.db == 'mysql:latest' && 'mysqladmin ping' || 'healthcheck.sh --connect --innodb_initialized' }}" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 3306:3306 | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v4 | |
- name: Initialize database | |
run: | | |
mysql -uroot -p${{ env.MYSQL_ROOT_PASSWORD }} -h127.0.0.1 < docker/init/init.sql | |
- name: Setup Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ matrix.otp }} | |
elixir-version: ${{ matrix.elixir }} | |
- name: Retrieve dependencies cache | |
uses: actions/cache@v4 | |
id: mix-cache | |
with: | |
path: | | |
deps | |
_build | |
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
- name: Run tests | |
run: mix test |