Feat/sqlx refactor #547
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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
fmt: | |
name: Test format and lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
- name: Install deno | |
uses: denoland/setup-deno@v1 | |
- name: Check | |
run: deno task check | |
unit: | |
name: Test unit | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
- name: Install deno | |
uses: denoland/setup-deno@v1 | |
- name: Run unit tests | |
run: deno task test:unit | |
- name: Generate lcov | |
run: deno coverage --unstable --lcov ./coverage > coverage.lcov | |
- name: Upload coverage | |
uses: codecov/codecov-action@v1 | |
with: | |
files: coverage.lcov | |
flags: unit | |
cli: | |
name: Test CLI | |
runs-on: ubuntu-latest | |
env: | |
URL_PATH: ${{github.event.pull_request.head.repo.full_name||github.repository}}/${{github.event.pull_request.head.ref||'main'}} | |
steps: | |
- name: Install deno | |
uses: denoland/setup-deno@v1 | |
- name: Nessie Init | |
run: deno run -A https://raw.githubusercontent.com/$URL_PATH/cli.ts init --dialect sqlite | |
- name: Create migration | |
run: deno run -A https://raw.githubusercontent.com/$URL_PATH/cli.ts make test | |
- name: Create migration | |
run: deno run -A https://raw.githubusercontent.com/$URL_PATH/cli.ts make:migration test2 | |
- name: Create seed | |
run: deno run -A https://raw.githubusercontent.com/$URL_PATH/cli.ts make:seed test | |
- run: echo "test" >> test_template | |
- name: Create migration from custom template | |
run: | | |
deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts make:migration --migrationTemplate test_template test_migration_template | |
TEMPLATE_PATH=$(find db/migrations -type f -name "*test_migration_template.ts") | |
TEMPLATE_CONTENT=$(cat $TEMPLATE_PATH) | |
if [[ $TEMPLATE_CONTENT != "test" ]]; then echo "File $TEMPLATE_PATH was not correct, was:\n$TEMPLATE_CONTENT" && exit 1; fi | |
- name: Create seed from custom template | |
run: | | |
deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts make:seed --seedTemplate test_template test_seed_template | |
TEMPLATE_PATH=$(find db/seeds -type f -name "test_seed_template.ts") | |
TEMPLATE_CONTENT=$(cat $TEMPLATE_PATH) | |
if [[ $TEMPLATE_CONTENT != "test" ]]; then echo "File $TEMPLATE_PATH was not correct, was:\n$TEMPLATE_CONTENT" && exit 1; fi | |
- name: Clean files and folders | |
run: rm -rf db && rm -rf nessie.config.ts | |
- name: Init with mode and pg | |
run: deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts init --mode config --dialect pg | |
- name: Init with mode and mysql | |
run: deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts init --mode config --dialect mysql | |
- name: Init with mode and sqlite | |
run: deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts init --mode config --dialect sqlite | |
- name: Init with folders only | |
run: deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts init --mode folders | |
cli-migrations: | |
name: Test CLI Migrations | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: root | |
POSTGRES_PASSWORD: pwd | |
POSTGRES_DB: nessie | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5000:5432 | |
mysql: | |
image: mysql | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_DATABASE: nessie | |
options: >- | |
--health-cmd="mysqladmin ping" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
ports: | |
- 5001:3306 | |
steps: | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
- name: Install deno | |
uses: denoland/setup-deno@v1 | |
- name: Run tests | |
run: deno task test:integration | |
- name: Generate lcov | |
run: deno coverage --unstable --lcov ./coverage > coverage.lcov | |
- name: Upload coverage | |
uses: codecov/codecov-action@v1 | |
with: | |
files: coverage.lcov | |
flags: integration-cli |