Skip to content

Commit

Permalink
251 nim v2 support (#256)
Browse files Browse the repository at this point in the history
* nin v2

* create v2 directory

* v1 and v2 test

* fix v1 test

* update readme

* nimble docs

* fix nim yaml
  • Loading branch information
itsumura-h authored Oct 2, 2023
1 parent 946ca17 commit a21601f
Show file tree
Hide file tree
Showing 823 changed files with 36,142 additions and 5,973 deletions.
55 changes: 16 additions & 39 deletions .github/workflows/nim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Build and test Nim
# テストはPRだけ
on: [pull_request]

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "test"
cancel-in-progress: false

jobs:
# WIP でジョブがスキップされてもCIが失敗した扱いにならないようにするため
skip:
Expand All @@ -17,51 +23,22 @@ jobs:
steps:
- run: echo "no WIP"

# build:
# runs-on: ${{ matrix.os }}
# needs: before
# strategy:
# matrix:
# os:
# - ubuntu-latest
# # - macOS-latest
# # Need sqlite3_64.dll
# # - windows-latest
# env:
# NIM_VERSION: 1.2.0
# steps:
# - uses: actions/checkout@v1
# - name: Cache choosenim
# id: cache-choosenim
# uses: actions/cache@v1
# with:
# path: ~/.choosenim
# key: ${{ runner.os }}-choosenim-${{ env.NIM_VERSION }}
# - name: Cache nimble
# id: cache-nimble
# uses: actions/cache@v1
# with:
# path: ~/.nimble
# key: ${{ runner.os }}-nimble-${{ env.NIM_VERSION }}
# - uses: jiro4989/setup-nim-action@v1
# with:
# nim-version: ${{ env.NIM_VERSION }}
# - name: Build
# run: nimble install -Y
test-on-docker-nim-v1:
runs-on: ubuntu-latest
needs: before
steps:
- uses: actions/checkout@v1
- name: Test
run: docker compose -f compose.test.yaml run app-ubuntu-v1 nimble test_v1

test-on-docker:
test-on-docker-nim-v2:
runs-on: ubuntu-latest
needs: before
steps:
- uses: actions/checkout@v1
- name: Test
run: docker-compose run app-ubuntu nimble test
# マルチスレッドは使わない
# - name: Test multi-thread
# run: |
# echo '' >> tests/config.nims
# echo 'switch("threads", "on")' >> tests/config.nims
# docker-compose run app-ubuntu nimble test
run: docker compose -f compose.test.yaml run app-ubuntu nimble test


# アプリケーションの方を使うことにした
# https://github.com/marketplace/actions/release-drafter
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ allographer


An asynchronous query builder library inspired by [Laravel/PHP](https://readouble.com/laravel/6.0/en/queries.html) and [Orator/Python](https://orator-orm.com) for Nim.
Supported Databases are [Sqlite3](https://www.sqlite.org/index.html), [PostgreSQL](https://www.postgresql.org/), [MySQL](https://www.mysql.com/), [MariaDB](https://mariadb.org/) and [SurrealDB](https://surrealdb.com/).
Supported Databases are [Sqlite3](https://www.sqlite.org/index.html), [PostgreSQL](https://www.postgresql.org/), [MySQL](https://www.mysql.com/), [MariaDB](https://mariadb.org/) and [SurrealDB](https://surrealdb.com/).
Supported Nim for both `1.6.14` and `2.0.0`

## Easy to access Rdb
### Query Builder
Expand Down
14 changes: 11 additions & 3 deletions allographer.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ srcDir = "src"

requires "nim >= 1.2.0"
when (NimMajor, NimMinor) > (1, 6):
requires "db_connector"
requires "db_connector >= 0.1.0"
requires "checksums >= 0.1.0"


import strformat, os

task test, "run testament test":
exec "testament p 'tests/*/test_*.nim'"
task test, "run testament test v2":
exec "testament p 'tests/v2/*/test_*.nim'"
for kind, path in walkDir(getCurrentDir() / "tests"):
if not path.contains(".") and path.fileExists():
exec "rm -f " & path

task test_v1, "run testament test v1":
exec "testament p 'tests/v1/*/test_*.nim'"
for kind, path in walkDir(getCurrentDir() / "tests"):
if not path.contains(".") and path.fileExists():
exec "rm -f " & path
Expand Down
67 changes: 67 additions & 0 deletions compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: '3'
services:
app-ubuntu-v1:
build:
context: .
dockerfile: ./docker/ubuntu/Dockerfile
args:
VERSION: 1.6.14
tty: true
volumes:
- .:/root/project
depends_on:
- postgres
- mysql
- mariadb
- surreal

app-ubuntu:
build:
context: .
dockerfile: ./docker/ubuntu/Dockerfile
args:
VERSION: 2.0.0
tty: true
volumes:
- .:/root/project
depends_on:
- postgres
- mysql
- mariadb
- surreal

mysql:
image: mysql:8
tty: true
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: pass

mariadb:
image: mariadb
tty: true
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: pass

postgres:
image: postgres:alpine
tty: true
environment:
POSTGRES_DB: database
POSTGRES_USER: user
POSTGRES_PASSWORD: pass

surreal:
image: surrealdb/surrealdb:1.0.0-beta.9
tty: true
# command: start --log TRACE --user user --pass pass memory # like redis
# command: start --log TRACE --user user --pass pass file://root/.surrealdb # like mongo
command: start --strict --log TRACE --user user --pass pass memory # like in-memory sqlite
# command: start --strict --log TRACE --user user --pass pass file://root/.surrealdb # like rdb
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ services:
build:
context: .
dockerfile: ./docker/ubuntu/Dockerfile
args:
VERSION: 1.6.14
tty: true
environment:
TZ: Asia/Tokyo
volumes:
- .:/root/project
depends_on:
Expand Down
17 changes: 7 additions & 10 deletions docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ RUN apt install -y \
libmariadb-dev

# ===== Nim =====
ARG VERSION="1.6.10"
ARG VERSION="2.0.0"
WORKDIR /root
RUN wget --inet4-only https://nim-lang.org/download/nim-${VERSION}-linux_x64.tar.xz && \
tar -Jxf nim-${VERSION}-linux_x64.tar.xz && \
rm -f nim-${VERSION}-linux_x64.tar.xz && \
mv nim-${VERSION} .nimble

RUN rm -rf /var/lib/apt/lists/*
RUN curl https://nim-lang.org/choosenim/init.sh -o init.sh
RUN sh init.sh -y
RUN rm -f init.sh
ENV PATH $PATH:/root/.nimble/bin
RUN choosenim ${VERSION}

WORKDIR /root/project
COPY ./allographer.nimble .
RUN nimble install -y -d
RUN nimble install -y \
bcrypt \
progress
RUN git config --global --add safe.directory /root/project
6 changes: 3 additions & 3 deletions docs/connection.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ <h1 class="title">src/allographer/connection</h1>
<div class="section" id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="env.html">env</a>, <a class="reference external" href="query_builder/models/sqlite/sqlite_types.html">query_builder/models/sqlite/sqlite_types</a>, <a class="reference external" href="query_builder/models/sqlite/sqlite_open.html">query_builder/models/sqlite/sqlite_open</a>, <a class="reference external" href="query_builder/models/postgres/postgres_types.html">query_builder/models/postgres/postgres_types</a>, <a class="reference external" href="query_builder/models/postgres/postgres_open.html">query_builder/models/postgres/postgres_open</a>, <a class="reference external" href="query_builder/models/mariadb/mariadb_types.html">query_builder/models/mariadb/mariadb_types</a>, <a class="reference external" href="query_builder/models/mariadb/mariadb_open.html">query_builder/models/mariadb/mariadb_open</a>, <a class="reference external" href="query_builder/models/mysql/mysql_types.html">query_builder/models/mysql/mysql_types</a>, <a class="reference external" href="query_builder/models/mysql/mysql_open.html">query_builder/models/mysql/mysql_open</a>, <a class="reference external" href="query_builder/models/surreal/surreal_types.html">query_builder/models/surreal/surreal_types</a>, <a class="reference external" href="query_builder/models/surreal/surreal_open.html">query_builder/models/surreal/surreal_open</a>
<a class="reference external" href="env.html">env</a>, <a class="reference external" href="v1/query_builder/models/sqlite/sqlite_types.html">v1/query_builder/models/sqlite/sqlite_types</a>, <a class="reference external" href="v1/query_builder/models/sqlite/sqlite_open.html">v1/query_builder/models/sqlite/sqlite_open</a>, <a class="reference external" href="v1/query_builder/models/postgres/postgres_types.html">v1/query_builder/models/postgres/postgres_types</a>, <a class="reference external" href="v1/query_builder/models/postgres/postgres_open.html">v1/query_builder/models/postgres/postgres_open</a>, <a class="reference external" href="v1/query_builder/models/mariadb/mariadb_types.html">v1/query_builder/models/mariadb/mariadb_types</a>, <a class="reference external" href="v1/query_builder/models/mariadb/mariadb_open.html">v1/query_builder/models/mariadb/mariadb_open</a>, <a class="reference external" href="v1/query_builder/models/mysql/mysql_types.html">v1/query_builder/models/mysql/mysql_types</a>, <a class="reference external" href="v1/query_builder/models/mysql/mysql_open.html">v1/query_builder/models/mysql/mysql_open</a>, <a class="reference external" href="v1/query_builder/models/surreal/surreal_types.html">v1/query_builder/models/surreal/surreal_types</a>, <a class="reference external" href="v1/query_builder/models/surreal/surreal_open.html">v1/query_builder/models/surreal/surreal_open</a>
</dl></div>
<div class="section" id="19">
<h1><a class="toc-backref" href="#19">Exports</a></h1>
<dl class="item">
<a href="query_builder/models/sqlite/sqlite_types.html#SQLite3"><span class="Identifier">SQLite3</span></a>, <a href="query_builder/models/sqlite/sqlite_open.html#dbOpen,typeSQLite3,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="query_builder/models/postgres/postgres_types.html#PostgreSQL"><span class="Identifier">PostgreSQL</span></a>, <a href="query_builder/models/postgres/postgres_open.html#dbOpen,typePostgreSQL,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="query_builder/models/mariadb/mariadb_types.html#MariaDB"><span class="Identifier">MariaDB</span></a>, <a href="query_builder/models/mariadb/mariadb_open.html#dbOpen,typeMariaDB,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="query_builder/models/mysql/mysql_types.html#MySQL"><span class="Identifier">MySQL</span></a>, <a href="query_builder/models/mysql/mysql_open.html#dbOpen,typeMySQL,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="query_builder/models/surreal/surreal_types.html#SurrealDB"><span class="Identifier">SurrealDB</span></a>, <a href="query_builder/models/surreal/surreal_open.html#dbOpen,typeSurrealDB,string,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>
<a href="v1/query_builder/models/sqlite/sqlite_types.html#SQLite3"><span class="Identifier">SQLite3</span></a>, <a href="v1/query_builder/models/sqlite/sqlite_open.html#dbOpen,typeSQLite3,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="v1/query_builder/models/postgres/postgres_types.html#PostgreSQL"><span class="Identifier">PostgreSQL</span></a>, <a href="v1/query_builder/models/postgres/postgres_open.html#dbOpen,typePostgreSQL,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="v1/query_builder/models/mariadb/mariadb_types.html#MariaDB"><span class="Identifier">MariaDB</span></a>, <a href="v1/query_builder/models/mariadb/mariadb_open.html#dbOpen,typeMariaDB,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="v1/query_builder/models/mysql/mysql_types.html#MySQL"><span class="Identifier">MySQL</span></a>, <a href="v1/query_builder/models/mysql/mysql_open.html#dbOpen,typeMySQL,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>, <a href="v1/query_builder/models/surreal/surreal_types.html#SurrealDB"><span class="Identifier">SurrealDB</span></a>, <a href="v1/query_builder/models/surreal/surreal_open.html#dbOpen,typeSurrealDB,string,string,string,string,string,int32,int,int,string"><span class="Identifier">dbOpen</span></a>
</dl></div>

</div>
Expand All @@ -137,7 +137,7 @@ <h1><a class="toc-backref" href="#19">Exports</a></h1>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2023-09-25 03:39:37 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2023-10-02 11:28:08 UTC</small>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/env.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ <h1><a class="toc-backref" href="#10">Consts</a></h1>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2023-09-25 03:39:43 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2023-10-02 11:28:15 UTC</small>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/query_builder.html

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions docs/query_builder/enums.idx

This file was deleted.

2 changes: 0 additions & 2 deletions docs/query_builder/error.idx

This file was deleted.

11 changes: 0 additions & 11 deletions docs/query_builder/libs/mariadb/mariadb_impl.idx

This file was deleted.

7 changes: 0 additions & 7 deletions docs/query_builder/libs/mariadb/mariadb_lib.idx

This file was deleted.

Loading

0 comments on commit a21601f

Please sign in to comment.