Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/sqlx refactor #170

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1efa2ca
Bumped deps and deno
halvardssm Sep 24, 2023
f37aa79
Updated changelog
halvardssm Sep 24, 2023
c985a93
Bumped nessie version and fixed issues
halvardssm Sep 24, 2023
ad55888
removed dockerfile and image building
halvardssm Mar 17, 2024
8fa8cca
removed nest
halvardssm Mar 17, 2024
a84389d
Added docker compose for testing dbs
halvardssm Mar 17, 2024
d73341c
moved commands from makefile to deno.json, and added deps from jsr
halvardssm Mar 17, 2024
086de55
removed scripts
halvardssm Mar 17, 2024
6867765
Refactored file structure, migration client implementation and cli st…
halvardssm Mar 17, 2024
9ba86b0
Fixed tests
halvardssm Mar 17, 2024
04dd982
fixed examples
halvardssm Mar 17, 2024
729b4f2
fixed ci
halvardssm Mar 17, 2024
1caca3c
edited readme
halvardssm Mar 17, 2024
bc2db73
merged main
halvardssm Mar 17, 2024
2cfb970
updated cli test
halvardssm Mar 19, 2024
21349f0
added vendor
halvardssm Mar 19, 2024
0ad87dc
updated Migration signature and cleaned up
halvardssm Mar 19, 2024
5315aa1
updated examples
halvardssm Mar 19, 2024
6a72a81
updated config file
halvardssm Mar 19, 2024
41bcb42
updated examples
halvardssm Mar 20, 2024
a7f5e99
updated gitignore
halvardssm Mar 21, 2024
275420e
updated cli test
halvardssm Mar 21, 2024
52eea32
cleaned up commands
halvardssm Mar 21, 2024
8e0eccd
added assertFsExists
halvardssm Mar 21, 2024
c60a2d1
Updated CI
halvardssm Mar 21, 2024
ac5ef3b
Fixed tests
halvardssm Mar 21, 2024
900032c
fixed ci
halvardssm Mar 21, 2024
8aebc3d
cleanup
halvardssm Mar 21, 2024
309b768
fixed coverage
halvardssm Mar 21, 2024
bcf3b47
added vendor
halvardssm Mar 28, 2024
878dd1e
updated clients, examples, imports
halvardssm Mar 28, 2024
66edd34
removed vendor
halvardssm Apr 10, 2024
209f915
updated cli usage
halvardssm Apr 10, 2024
b844844
Updated according to sqlx
halvardssm Apr 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .dockerignore

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/ci-canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI

on:
schedule:
- cron: "24 8 * * 0,3,5"

env:
DENO_VERSION: "canary"

jobs:
check:
name: Check format and lint
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{env.DENO_VERSION}}

- name: Check
run: deno task check

tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{env.DENO_VERSION}}

- name: Run unit tests
run: deno task test

- name: Generate lcov
run: deno task coverage:lcov

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
files: coverage.lcov
flags: tests-canary

publish:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{env.DENO_VERSION}}

- name: Publish (dry run)
run: deno publish --dry-run
215 changes: 25 additions & 190 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,240 +1,75 @@
name: CI

env:
DENO_VERSION: 1.37.0

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "24 8 * * 0,3,5"

env:
DENO_VERSION: vx.x.x

jobs:
fmt:
name: Test format and lint
check:
name: Check format and lint
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v1
with:
with:
deno-version: ${{env.DENO_VERSION}}

- name: Check fmt
run: deno fmt --check

- name: Check lint
run: deno lint
- name: Check
run: deno task check

unit:
name: Test unit
tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{env.DENO_VERSION}}

- name: Run unit tests
run: deno task test:unit
run: deno task test

- name: Generate lcov
run: deno coverage --unstable --lcov ./coverage > coverage.lcov
run: deno task coverage:lcov

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
files: coverage.lcov
flags: unit
flags: tests-stable

cli:
name: Test CLI
publish:
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
with:
deno-version: ${{env.DENO_VERSION}}

- name: Nessie Init
run: deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts init --dialect sqlite

- run: sed -i "s|from \".*\"|from \"https://raw.githubusercontent.com/$URL_PATH/mod.ts\"|" nessie.config.ts && cat nessie.config.ts

- name: Create migration
run: deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts make test

- name: Create migration
run: deno run -A --unstable https://raw.githubusercontent.com/$URL_PATH/cli.ts make:migration test2

- name: Create seed
run: deno run -A --unstable 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
permissions:
contents: read
id-token: write

steps:
- name: Clone repo
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{env.DENO_VERSION}}

- name: Create databases
run: make db_sqlite_start

- name: Run tests
run: make test_integration_cli

- 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

cli-update-timestamps:
name: Test CLI Update timestamps
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@v3

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{env.DENO_VERSION}}

- name: Create databases
run: make db_sqlite_start

- name: Run tests
run: make test_integration_update_timestamps

- 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-update-timestamps

image-test:
name: Test Docker image build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build image
run: make image_build
env:
DENO_VERSION: latest

- name: Test image
run: make image_test
- name: Publish (dry run)
run: deno publish --dry-run
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish

on:
release:
types: [published]

env:
DENO_VERSION: vx.x.x

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{env.DENO_VERSION}}

- name: Publish
if: github.event_name == 'release'
run: deno publish
Loading
Loading