-
Notifications
You must be signed in to change notification settings - Fork 9
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
Setup test environment inside CI #9
base: master
Are you sure you want to change the base?
Changes from all commits
dc455d5
05f8d39
a44e9bb
18ac63a
7a1b7a9
bf54b29
28c332b
319764f
4910a4b
594fb90
541e94a
ecd1f91
91e9172
82fef68
c34da91
103ea5a
2506a2d
c81b6a9
962dadd
c9293be
ee66d2f
b245dba
7b3ba2d
5091c33
5c5c0ac
3f7e40b
cbf55bc
63ff491
b9e9535
0df8530
13b8854
6a3537d
c75e172
39404f5
f51a730
3a3e2d5
02c58e2
01847eb
f2c68b0
5f9c55c
9f0f17d
7c24bd8
9747bb8
76bf66d
06cdc97
f06df3a
11827ab
9584707
fcd8337
e4bf3a8
4cef381
62457b7
7071fcd
d970f20
bf8bf00
b16713a
8839aa7
8ab9ce9
439f590
4f4a9f1
5679d6a
3f1fa9a
d569a33
0937725
c8d0b9a
19e090a
c997f8f
1c1d4a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: PostgreSQLAdapter test | ||
on: push | ||
|
||
jobs: | ||
# Label of the container job | ||
container-job: | ||
# Containers must run in Linux based operating systems | ||
runs-on: ubuntu-latest | ||
# Docker Hub image that `container-job` executes in | ||
container: node:10.18-jessie | ||
|
||
# Service containers to run with `container-job` | ||
services: | ||
# Label used to access the service container | ||
postgres: | ||
# Docker Hub image | ||
image: postgres | ||
# Provide the password for postgres | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
# Maps tcp port 5432 on service container to the host | ||
- 5432:5432 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@latest | ||
with: | ||
version: '1.7.1' | ||
arch: 'x64' | ||
- uses: julia-actions/julia-buildpkg@master | ||
- name: Install SearchLight and SearchLightPostgreSQL | ||
run: | | ||
pwd | ||
julia -e 'using Pkg; Pkg.add(url="https://github.com/GenieFramework/SearchLight.jl.git")' | ||
julia -e 'using Pkg; Pkg.add(url="https://github.com/GenieFramework/SearchLightPostgreSQL.jl.git")' | ||
julia -e 'import Pkg; Pkg.add("SafeTestsets")' | ||
julia -e 'using Pkg; Pkg.activate(".")' | ||
julia -e 'using Pkg; Pkg.resolve()' | ||
shell: bash | ||
- uses: julia-actions/julia-runtest@master |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
Manifest.toml | ||
Manifest.toml | ||
tests/db/migrations/* | ||
**/.DS_Store* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also delete the .DS_Store files that were added? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"cmake.configureOnOpen": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,12 @@ version = "2.0.1" | |
|
||
[deps] | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1" | ||
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" | ||
SearchLight = "340e8cb6-72eb-11e8-37ce-c97ebeb32050" | ||
|
||
[compat] | ||
DataFrames = "1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @FrankUrbach You removed the compat entry for DataFrames - pls put it back |
||
LibPQ = "1" | ||
SearchLight = "2" | ||
julia = "1" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,9 +293,14 @@ Runs a SQL DB query that creates the table `table_name` with the structure neede | |
The table should contain one column, `version`, unique, as a string of maximum 30 chars long. | ||
""" | ||
function SearchLight.Migration.create_migrations_table(table_name::String = SearchLight.config.db_migrations_table_name) :: Nothing | ||
SearchLight.query("CREATE TABLE $table_name (version varchar(30))") | ||
|
||
@info "Created table $table_name" | ||
queryString = "SELECT table_name FROM information_schema.tables WHERE table_name = '$table_name'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use naming consistent with the rest of the code base. In SearchLight (and Julia in general) we use |
||
if isempty(SearchLight.query(queryString)) | ||
SearchLight.query("CREATE TABLE $table_name (version varchar(30))") | ||
@info "Created table $table_name" | ||
else | ||
@info "Migration table exists." | ||
end | ||
|
||
nothing | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[deps] | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" | ||
SearchLight = "340e8cb6-72eb-11e8-37ce-c97ebeb32050" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module CreateTableUsers | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:users) do | ||
[ | ||
primary_key() | ||
column(:username, :string, limit = 100) | ||
column(:password, :string, limit = 100) | ||
column(:name, :string, limit = 100) | ||
column(:email, :string, limit = 100) | ||
] | ||
end | ||
|
||
add_index(:users, :username) | ||
end | ||
|
||
function down() | ||
drop_table(:users) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module CreateTableRoles | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:roles) do | ||
[ | ||
primary_key() | ||
column(:name, :string, limit = 100) | ||
] | ||
end | ||
|
||
add_index(:roles, :name) | ||
end | ||
|
||
function down() | ||
drop_table(:roles) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module CreateTableAbilities | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:abilities) do | ||
[ | ||
primary_key() | ||
column(:name, :string, limit = 100) | ||
] | ||
end | ||
|
||
add_index(:abilities, :name) | ||
end | ||
|
||
function down() | ||
drop_table(:abilities) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module CreateTableRolesUsers | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:rolesusers) do | ||
[ | ||
primary_key() | ||
column(:roles_id, :int) | ||
column(:users_id, :int) | ||
] | ||
end | ||
|
||
add_index(:rolesusers, :roles_id) | ||
add_index(:rolesusers, :users_id) | ||
end | ||
|
||
function down() | ||
drop_table(:rolesusers) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module CreateTableAbilitiesRoles | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:abilitiesroles) do | ||
[ | ||
primary_key() | ||
column(:abilities_id, :int) | ||
column(:roles_id, :int) | ||
] | ||
end | ||
|
||
add_index(:abilitiesroles, :abilities_id) | ||
add_index(:abilitiesroles, :roles_id) | ||
end | ||
|
||
function down() | ||
drop_table(:abilitiesroles) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
module TestModels | ||
|
||
using SearchLight | ||
|
||
######## Model from Genie-Searchligth-example-app extracted ############ | ||
export Book, BookWithInterns | ||
using SearchLight, Dates | ||
|
||
######## Model from Genie-Searchligth-example-app extracted ############ | ||
export Callback | ||
export seed, fields_to_store | ||
|
||
mutable struct Book <: AbstractModel | ||
|
||
### FIELDS | ||
id::DbId | ||
title::String | ||
author::String | ||
cover::String | ||
|
||
### VALIDATION | ||
# validator::ModelValidator | ||
|
||
### CALLBACKS | ||
# before_save::Function | ||
# after_save::Function | ||
# on_save::Function | ||
# on_find::Function | ||
# after_find::Function | ||
|
||
### SCOPES | ||
# scopes::Dict{Symbol,Vector{SearchLight.SQLWhereEntity}} | ||
|
||
### constructor | ||
Book(; | ||
### FIELDS | ||
id = DbId(), | ||
title = "", | ||
author = "", | ||
cover = "", | ||
|
||
### VALIDATION | ||
# validator = ModelValidator([ | ||
# ValidationRule(:title, BooksValidator.not_empty) | ||
# ]), | ||
|
||
### CALLBACKS | ||
# before_save = (m::Todo) -> begin | ||
# @info "Before save" | ||
# end, | ||
# after_save = (m::Todo) -> begin | ||
# @info "After save" | ||
# end, | ||
# on_save = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On save" | ||
# end, | ||
# on_find = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On find" | ||
# end, | ||
# after_find = (m::Todo) -> begin | ||
# @info "After find" | ||
# end, | ||
|
||
### SCOPES | ||
# scopes = Dict{Symbol,Vector{SearchLight.SQLWhereEntity}}() | ||
|
||
) = new(id, title, author, cover ### FIELDS | ||
# validator, ### VALIDATION | ||
# before_save, after_save, on_save, on_find, after_find ### CALLBACKS | ||
# scopes ### SCOPES | ||
) | ||
end | ||
|
||
mutable struct BookWithInterns <: AbstractModel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please update/cleanup the model to the latest API? We no longer use the _table_name, _id, _serializable fields. Just so that it's not confusing for the users looking at the tests to learn. |
||
### FIELDS | ||
id::DbId | ||
title::String | ||
author::String | ||
cover::String | ||
|
||
### VALIDATION | ||
# validator::ModelValidator | ||
|
||
### CALLBACKS | ||
# before_save::Function | ||
# after_save::Function | ||
# on_save::Function | ||
# on_find::Function | ||
# after_find::Function | ||
|
||
### SCOPES | ||
# scopes::Dict{Symbol,Vector{SearchLight.SQLWhereEntity}} | ||
|
||
### constructor | ||
BookWithInterns(; | ||
### FIELDS | ||
id = DbId(), | ||
title = "", | ||
author = "", | ||
cover = "", | ||
|
||
### VALIDATION | ||
# validator = ModelValidator([ | ||
# ValidationRule(:title, BooksValidator.not_empty) | ||
# ]), | ||
|
||
### CALLBACKS | ||
# before_save = (m::Todo) -> begin | ||
# @info "Before save" | ||
# end, | ||
# after_save = (m::Todo) -> begin | ||
# @info "After save" | ||
# end, | ||
# on_save = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On save" | ||
# end, | ||
# on_find = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On find" | ||
# end, | ||
# after_find = (m::Todo) -> begin | ||
# @info "After find" | ||
# end, | ||
|
||
### SCOPES | ||
# scopes = Dict{Symbol,Vector{SearchLight.SQLWhereEntity}}() | ||
|
||
) = new("bookwithinterns", "id", Symbol[], ### INTERNALS | ||
id, title, author, cover ### FIELDS | ||
# validator, ### VALIDATION | ||
# before_save, after_save, on_save, on_find, after_find ### CALLBACKS | ||
# scopes ### SCOPES | ||
) | ||
end | ||
|
||
Base.@kwdef mutable struct Callback <: AbstractModel | ||
id::DbId = DbId() | ||
title::String = "" | ||
indicator::Bool = true | ||
created_at::String = string(Dates.now()) | ||
# callbacks | ||
before_save::Function = (m::Callback) -> begin | ||
@info "Do something before saving" | ||
end | ||
after_save::Function = (m::Callback) -> begin | ||
@info "Do something after saving" | ||
end | ||
end | ||
|
||
function seed() | ||
BillGatesBooks = [ | ||
("The Best We Could Do", "Thi Bui"), | ||
("Evicted: Poverty and Profit in the American City", "Matthew Desmond"), | ||
("Believe Me: A Memoir of Love, Death, and Jazz Chickens", "Eddie Izzard"), | ||
("The Sympathizer!", "Viet Thanh Nguyen"), | ||
("Energy and Civilization, A History", "Vaclav Smil") | ||
] | ||
end | ||
|
||
end ### End Module |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
env: dev | ||
|
||
dev: | ||
adapter: PostgreSQL | ||
host: postgres | ||
port: 5432 | ||
database: postgres | ||
username: postgres | ||
password: postgres | ||
|
||
config: | ||
log_queries: true | ||
log_level: :debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove Manifest.toml from .gitignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uups. Added again.