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

Feature/unsafe query #58

Draft
wants to merge 487 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
487 commits
Select commit Hold shift + click to select a range
99274ff
refactor: replace some fieldObject by field.Object
FrancoLiberali May 26, 2023
be33532
refactor: elemType to fieldType
FrancoLiberali May 26, 2023
1ec7f00
refactor use field methods
FrancoLiberali May 26, 2023
67805d6
named type to field.Object
FrancoLiberali May 26, 2023
dcbc622
field object to field type
FrancoLiberali May 26, 2023
27ad127
object to type
FrancoLiberali May 26, 2023
1a97a64
object to type
FrancoLiberali May 26, 2023
4e174b7
object to type
FrancoLiberali May 26, 2023
913f2fb
move funcs to another file
FrancoLiberali May 26, 2023
34df3b9
more refactor
FrancoLiberali May 26, 2023
d1cd0f7
better method names
FrancoLiberali May 26, 2023
0747255
jen param to another file
FrancoLiberali May 26, 2023
3b05224
remove global variable destPg
FrancoLiberali May 26, 2023
a17337a
Type to type
FrancoLiberali May 26, 2023
cf865ae
fail in the same way in all the commands
FrancoLiberali May 26, 2023
0b8fd13
allow using gen conditions without go generate
FrancoLiberali May 26, 2023
bd5519f
add logs to gen conditions
FrancoLiberali May 26, 2023
4215b5c
avoid dot import
FrancoLiberali May 26, 2023
c8f9c18
add comments to functions
FrancoLiberali May 26, 2023
cddf7f1
fix import
FrancoLiberali May 30, 2023
6268f60
conditions to a different package
FrancoLiberali May 30, 2023
6b63cf3
move constants to correct files
FrancoLiberali May 30, 2023
5f08ec1
fix e2e imports
FrancoLiberali May 30, 2023
885b579
add support for deletedAt quering
FrancoLiberali May 30, 2023
b765da4
export badorm automigrate
FrancoLiberali May 30, 2023
2147182
add badorm in standalone mode
FrancoLiberali May 30, 2023
f5ca8db
remove unnecessary automigrate
FrancoLiberali May 30, 2023
277bfea
rename file
FrancoLiberali May 30, 2023
4d7f548
add unsafe service with the previous version to work with http
FrancoLiberali May 31, 2023
ff51d35
autodetermine id type
FrancoLiberali May 31, 2023
3987b9c
be able to choose between cockroach and postgresql for int tests
FrancoLiberali May 31, 2023
0a230be
make uuidModel usable on mysql (eav not working yet)
FrancoLiberali Jun 1, 2023
9b8e633
pass tests for mysql
FrancoLiberali Jun 1, 2023
4967868
add validation of dialector
FrancoLiberali Jun 1, 2023
b2c1ad6
add mysql support in docker generator
FrancoLiberali Jun 1, 2023
5053953
use binary for mysql uuid
FrancoLiberali Jun 1, 2023
44e9fbc
add strategy matrix to run int test with multiple dbs
FrancoLiberali Jun 1, 2023
047a9b8
fix gosec
FrancoLiberali Jun 1, 2023
f15b9bc
delete test that fails indeterministically
FrancoLiberali Jun 1, 2023
dda121e
fix db dialector for cockroach7
FrancoLiberali Jun 1, 2023
589fbff
fix github ci?
FrancoLiberali Jun 1, 2023
a1258a7
fix github ci? 2
FrancoLiberali Jun 1, 2023
e39352c
fix github ci? 3
FrancoLiberali Jun 1, 2023
6c12325
go sec before sonarcloud
FrancoLiberali Jun 1, 2023
c960e9a
fix test_e2e
FrancoLiberali Jun 1, 2023
24ebb49
fix coverage file names
FrancoLiberali Jun 1, 2023
e669266
fix gitignore
FrancoLiberali Jun 1, 2023
253fa58
Merge branch 'feature/badaas_as_library' into feature/gorm
FrancoLiberali Jun 1, 2023
9826b23
Merge branch 'feature/gorm' into feature/gorm_compilable_queries
FrancoLiberali Jun 1, 2023
440e61b
Merge branch 'feature/eav_2' into feature/badaas_as_library
FrancoLiberali Jun 1, 2023
ddaa65f
fix execute ci on every pr
FrancoLiberali Jun 1, 2023
aebc4e8
fix lint
FrancoLiberali Jun 1, 2023
263c3e5
Merge branch 'feature/security_analysis' into feature/eav_2
FrancoLiberali Jun 1, 2023
5f93fe4
refactor to reduce not tested err != nil
FrancoLiberali Jun 2, 2023
5e5e84f
use version of linter that works
FrancoLiberali Jun 2, 2023
dcc0b5b
Merge branch 'feature/eav' into feature/eav_2
FrancoLiberali Jun 2, 2023
09c547e
Merge branch 'feature/eav_2' into feature/badaas_as_library
FrancoLiberali Jun 2, 2023
02b06a0
go mod tidy
FrancoLiberali Jun 2, 2023
154ff5f
excluse conflictive dockerfile from sonar
FrancoLiberali Jun 2, 2023
2ce8e47
Merge branch 'feature/eav_2' into feature/badaas_as_library
FrancoLiberali Jun 2, 2023
8ad7472
fix sonar
FrancoLiberali Jun 2, 2023
9a9bbcd
badctl run to makefile
FrancoLiberali Jun 5, 2023
b7efda5
badctl run to makefile 2
FrancoLiberali Jun 5, 2023
398f276
add badctl unit tests
FrancoLiberali Jun 5, 2023
3c31181
Merge branch 'feature/badaas_as_library' into feature/gorm
FrancoLiberali Jun 5, 2023
7a68f87
remove failing tests
FrancoLiberali Jun 5, 2023
86c8af0
Merge branch 'feature/gorm' into feature/gorm_compilable_queries
FrancoLiberali Jun 5, 2023
844b681
update name of dockerfile to ignore in sonar·
FrancoLiberali Jun 5, 2023
f301f6a
divide complex function into 2
FrancoLiberali Jun 5, 2023
61f6462
add explanation to empty function
FrancoLiberali Jun 5, 2023
6877c75
run and fix unsafe tests
FrancoLiberali Jun 5, 2023
12a19b2
fix mysql int tests
FrancoLiberali Jun 5, 2023
96faebc
fix unit tests
FrancoLiberali Jun 5, 2023
20ed00e
add getOptionalByID tests
FrancoLiberali Jun 5, 2023
588cc1d
add int tests from uint model
FrancoLiberali Jun 5, 2023
3f2daae
fix dependencies between badctl and badaas
FrancoLiberali Jun 5, 2023
0a1e098
fix dependencies between badctl and badaas 2
FrancoLiberali Jun 5, 2023
5369ed4
add badaas unit test report
FrancoLiberali Jun 6, 2023
0c0ab7b
install gotestsum
FrancoLiberali Jun 6, 2023
f5bcded
unit test report include badctl
FrancoLiberali Jun 7, 2023
89faeed
integration tests report
FrancoLiberali Jun 7, 2023
e328590
change test result file name
FrancoLiberali Jun 7, 2023
349f05b
make install dependencies
FrancoLiberali Jun 7, 2023
c2e64ce
add test for conditions generation
FrancoLiberali Jun 7, 2023
b2d8ed7
support naming strategy
FrancoLiberali Jun 7, 2023
1603503
fix ci int test report name
FrancoLiberali Jun 7, 2023
a214d45
add badctl tests to sonar tests
FrancoLiberali Jun 7, 2023
3071229
fix conditions file names in snake case
FrancoLiberali Jun 7, 2023
ded438a
fix add badctl tests to sonar tests
FrancoLiberali Jun 7, 2023
14f17ba
fix tests e2e?
FrancoLiberali Jun 8, 2023
7a6ae9e
fix test e2e? 2
FrancoLiberali Jun 8, 2023
b73aaf2
run tests over sqlite
FrancoLiberali Jun 8, 2023
ea9ebba
fix sqlite int tests no need docker
FrancoLiberali Jun 8, 2023
da8f73f
fix sqlite int tests no need docker on stop also
FrancoLiberali Jun 8, 2023
1af8507
add support for mssqlserver
FrancoLiberali Jun 8, 2023
126c834
avoid be root in mssqlserver container
FrancoLiberali Jun 8, 2023
510ab2a
remove TODO
FrancoLiberali Jun 8, 2023
3759b21
fix not use root user in sqlserver
FrancoLiberali Jun 8, 2023
cf3141d
update docs
FrancoLiberali Jun 8, 2023
fb8bdaa
update lint config and lint badaas and badorm
FrancoLiberali Jun 9, 2023
1646b29
add linting for teste2e
FrancoLiberali Jun 9, 2023
b1bd857
add linting for badctl
FrancoLiberali Jun 9, 2023
c3a9b3a
more linting for badaas
FrancoLiberali Jun 9, 2023
bdfdd53
add lint for all packages in ci
FrancoLiberali Jun 9, 2023
3cf8b37
re remove old code
FrancoLiberali Jun 9, 2023
833fd04
add more linters
FrancoLiberali Jun 9, 2023
71be7d6
go sec is inside golangci-lint
FrancoLiberali Jun 9, 2023
f106cb5
add vscode settings template
FrancoLiberali Jun 9, 2023
9559eb8
run gofumpt with badctl gen
FrancoLiberali Jun 9, 2023
4266cae
allow last version of golangci lint
FrancoLiberali Jun 12, 2023
c2d82f4
remove todos
FrancoLiberali Jun 12, 2023
72126c9
remove todo
FrancoLiberali Jun 12, 2023
da6194c
remove repeted code
FrancoLiberali Jun 12, 2023
7472452
Merge branch 'feature/gorm_compilable_queries' into improvement/lint
FrancoLiberali Jun 12, 2023
1212b94
first version of expressions with any
FrancoLiberali Jun 12, 2023
527fd56
add generics on expresions
FrancoLiberali Jun 12, 2023
dedde05
update conditions generation to work with expressions
FrancoLiberali Jun 14, 2023
9f2feab
is distinct and is null
FrancoLiberali Jun 14, 2023
cf8a41d
boolean comparison predicates + fix bug in isCustomGorm
FrancoLiberali Jun 14, 2023
67b1050
in and not in
FrancoLiberali Jun 14, 2023
e3faf22
add array and comparison mysql compatible expressions
FrancoLiberali Jun 14, 2023
9d0bc52
fix: add forgoten test file
FrancoLiberali Jun 14, 2023
aeec491
fix user email condition
FrancoLiberali Jun 14, 2023
7a6a48b
fix int tests
FrancoLiberali Jun 14, 2023
d7290e8
fix lint
FrancoLiberali Jun 14, 2023
9ea48f8
fix unit tests
FrancoLiberali Jun 14, 2023
4253233
add interface verification method
FrancoLiberali Jun 15, 2023
c3d27fd
between and not between
FrancoLiberali Jun 15, 2023
ab64bce
refactor: arrayExpression can be valueExpression
FrancoLiberali Jun 15, 2023
25dcc86
now pointers are compared aganist the pointed type (isNull must be us…
FrancoLiberali Jun 15, 2023
3d92085
EqOrIsNull and NotEqOrIsNotNull
FrancoLiberali Jun 15, 2023
cc45d5d
check that the value is not null for corresponding expressions
FrancoLiberali Jun 15, 2023
ecb974e
add sqlserver operators
FrancoLiberali Jun 15, 2023
02a278f
add sqlserver array operators
FrancoLiberali Jun 15, 2023
6aa2619
fix tests for sqlite
FrancoLiberali Jun 15, 2023
0ae879b
add sqlite folder
FrancoLiberali Jun 15, 2023
8ba4132
add expressions on strings
FrancoLiberali Jun 16, 2023
b4c6850
refactor: escape as method
FrancoLiberali Jun 16, 2023
2dcc915
add and, or, not, xor
FrancoLiberali Jun 16, 2023
e7b17e6
move logical operators to condition level
FrancoLiberali Jun 19, 2023
93864fc
fix lint
FrancoLiberali Jun 19, 2023
098d138
remove unnecesary type method
FrancoLiberali Jun 19, 2023
c6941ae
fix sqlite int tests
FrancoLiberali Jun 19, 2023
5f70324
use strings.Join in place of +
FrancoLiberali Jun 19, 2023
450252d
fix todos in tests
FrancoLiberali Jun 19, 2023
50c8224
remove not compatible sqlserver xor
FrancoLiberali Jun 19, 2023
2f4613d
unsafe condition for unsopported conditions
FrancoLiberali Jun 19, 2023
99c6adf
remove unsopported operators with cockroachdb
FrancoLiberali Jun 19, 2023
ed2f744
fix lint
FrancoLiberali Jun 19, 2023
903c963
TODO to issue
FrancoLiberali Jun 20, 2023
40cc0d4
remove todos
FrancoLiberali Jun 20, 2023
34a7e64
put all coverage exit files in the same folder
FrancoLiberali Jun 20, 2023
c00982b
add more comments to functions
FrancoLiberali Jun 20, 2023
456daa5
fix line coverage report upload
FrancoLiberali Jun 20, 2023
4c9acd8
fix int line coverage report upload
FrancoLiberali Jun 20, 2023
6a60fb3
add tests for empty conditions
FrancoLiberali Jun 20, 2023
337f91f
coverage results to a folder
FrancoLiberali Jun 20, 2023
ad183ee
add test reports to gitigore
FrancoLiberali Jun 20, 2023
52348b6
coverage reports to artifact with name
FrancoLiberali Jun 20, 2023
ef4b668
use all .out files for coverage
FrancoLiberali Jun 20, 2023
2b4bb50
add test for case sensitive of regex
FrancoLiberali Jun 20, 2023
19c8fd5
remove unused code
FrancoLiberali Jun 20, 2023
2d61a77
add possibility to do preload
FrancoLiberali Jun 20, 2023
216f557
test that embedded also work with preload
FrancoLiberali Jun 20, 2023
f411c19
always add base model fields to preload conditions
FrancoLiberali Jun 20, 2023
9117ef0
left join if we only want to do the preload
FrancoLiberali Jun 21, 2023
b8d9b6a
add relation field to the condition auto generation
FrancoLiberali Jun 21, 2023
10f2f7b
reuse field identifier in field conditions
FrancoLiberali Jun 21, 2023
78a3ec4
auto generation of preload conditions
FrancoLiberali Jun 21, 2023
3a0a625
support attributes named in the same way inside embedded structs
FrancoLiberali Jun 21, 2023
14e90d7
fix lint
FrancoLiberali Jun 21, 2023
b155625
autogenerate Preload relations + remove inverse Join because its not …
FrancoLiberali Jun 21, 2023
fcc6b2d
add test of preload in other types of relations
FrancoLiberali Jun 21, 2023
7ab5479
add a way to know if a relation was loaded or not
FrancoLiberali Jun 23, 2023
53eb8f7
preload attributes if a relation is preload or any nested preload
FrancoLiberali Jun 26, 2023
c597913
generate conditions for UIntID
FrancoLiberali Jun 26, 2023
4240a04
use badorm model in place of any
FrancoLiberali Jun 26, 2023
13362c0
remove old mock files
FrancoLiberali Jun 26, 2023
4bd5ef2
automatic generation of relation getters
FrancoLiberali Jun 27, 2023
588453b
refactor relation getters generation to generator
FrancoLiberali Jun 27, 2023
a51f524
generate getters for embedded structs
FrancoLiberali Jun 27, 2023
94e1dda
add logging to relation getters generation
FrancoLiberali Jun 27, 2023
ab30674
verify pointer with id only if id is badorm model id
FrancoLiberali Jun 27, 2023
35cdf04
list and nested attributes preload
FrancoLiberali Jun 28, 2023
8758556
allow multiple preloads inside collection preload
FrancoLiberali Jun 28, 2023
3dee16e
generated join conditions return ijoincondition
FrancoLiberali Jun 28, 2023
0d07549
automatic generation of collection preload
FrancoLiberali Jun 28, 2023
c03753e
collection getter and automatic generation
FrancoLiberali Jun 29, 2023
dca05b7
verify that nested collection preloads not filter
FrancoLiberali Jun 29, 2023
f1e3118
fix lint
FrancoLiberali Jun 29, 2023
dd981ec
update badctl unit tests results
FrancoLiberali Jun 29, 2023
a1f3aa3
add verifications of relation getters
FrancoLiberali Jun 29, 2023
f650a91
do not renegare relations preload if no relations
FrancoLiberali Jun 29, 2023
cc1bb4c
fix posible nil reference in int tests
FrancoLiberali Jun 29, 2023
fc7afa2
add self referencial preload tests
FrancoLiberali Jun 29, 2023
f4d72e6
remove not necesary code
FrancoLiberali Jun 29, 2023
84d5c87
add more comments to conditions
FrancoLiberali Jun 29, 2023
6b92ce4
change utils package name
FrancoLiberali Jun 29, 2023
8bc041d
refactor: gorm.db to query
FrancoLiberali Jul 3, 2023
28b81c3
add possibility to do dynamic conditions
FrancoLiberali Jul 3, 2023
0e8175d
automatic generation of new fields
FrancoLiberali Jul 4, 2023
2abb3ff
field identifier to generics to make verify at compilation time
FrancoLiberali Jul 4, 2023
72b2645
refactor dynamic to package + select join posibility
FrancoLiberali Jul 5, 2023
52668c6
add dynamic multivalue expressions
FrancoLiberali Jul 5, 2023
b7fd30e
multitype multivalue expressions
FrancoLiberali Jul 5, 2023
f9d6f3e
refactor: only one value expression
FrancoLiberali Jul 5, 2023
dc99fad
refactor: expression to operator
FrancoLiberali Jul 5, 2023
382bb46
add unsafe operators + refactor unsafe condition
FrancoLiberali Jul 6, 2023
ae22e1d
refactor string to sql.Connector
FrancoLiberali Jul 6, 2023
af226e6
add each db dynamic, multitype and unsafe operator
FrancoLiberali Jul 6, 2023
51c2d79
remove old todos
FrancoLiberali Jul 6, 2023
0b6ba7d
add more information to conditions and operators errors
FrancoLiberali Jul 6, 2023
6e20fed
add info to posix error
FrancoLiberali Jul 7, 2023
b170c82
fix incorrect change of relative badctl path
FrancoLiberali Jul 7, 2023
1c65e99
always add field name to field identifier
FrancoLiberali Jul 7, 2023
459a3d7
fix lint
FrancoLiberali Jul 7, 2023
279693e
fix unit tests
FrancoLiberali Jul 7, 2023
5d190b8
fix mysql tests
FrancoLiberali Jul 7, 2023
476179f
fix sqlite tests
FrancoLiberali Jul 7, 2023
77bbe40
fix sqlserver tests
FrancoLiberali Jul 7, 2023
03eca64
fix cockroach tests
FrancoLiberali Jul 7, 2023
eab3c04
add comments inside empty function again
FrancoLiberali Jul 7, 2023
4052bdb
allow choosing join number for each operation or value
FrancoLiberali Jul 7, 2023
d6a9f38
fix lint
FrancoLiberali Jul 10, 2023
6509622
readme docs to readthedocs
FrancoLiberali Jul 12, 2023
910e564
2
FrancoLiberali Jul 13, 2023
9ca0e8f
refactor unsafe + finish badorm docs
FrancoLiberali Jul 18, 2023
0b7e308
readthedocs -> .readthedocs
FrancoLiberali Jul 18, 2023
ae94ff6
change docs theme
FrancoLiberali Jul 19, 2023
54f7f94
fix unit tests
FrancoLiberali Jul 19, 2023
f3d7a6f
exclude docs from sonarcloud
FrancoLiberali Jul 19, 2023
a7237d6
add contributing to the docs
FrancoLiberali Jul 19, 2023
84f72fa
better contributing guideline
FrancoLiberali Jul 20, 2023
40c967c
refactor: change crud methods name
FrancoLiberali Jul 20, 2023
76065c3
fix method name in docs
FrancoLiberali Jul 20, 2023
b9ad726
(prs) remove unsafe query system
FrancoLiberali Jul 24, 2023
b547c00
(prs) remove eav model
FrancoLiberali Jul 24, 2023
5bf2b97
remove link to badaas example from badorm
FrancoLiberali Jul 24, 2023
0c14e2f
remove old todos
FrancoLiberali Jul 24, 2023
c4e02a0
add CONTRIBUTING.md to work in github
FrancoLiberali Jul 24, 2023
6732efe
(prs) remove eav model 2
FrancoLiberali Jul 24, 2023
4359f0a
add tests for commands initializer
FrancoLiberali Jul 24, 2023
8c1a812
add docs to dockerignore
FrancoLiberali Jul 24, 2023
526da61
add all the possible dialectors
FrancoLiberali Jul 24, 2023
af728ba
remove old mock
FrancoLiberali Jul 24, 2023
4b2ce9f
remove unused files
FrancoLiberali Jul 24, 2023
8526288
fix badaas quickstart docs
FrancoLiberali Jul 24, 2023
0ca513b
add again unsafe query system and badaas functionality
FrancoLiberali Jul 24, 2023
dfd287e
fix int test clean
FrancoLiberali Jul 24, 2023
b7b57a6
Merge branch 'feature/badorm' into feature/unsafe_query
FrancoLiberali Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 14 additions & 9 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
.editorconfig
.git
.gitignore
.github
sonar-project.properties
AUTHORS.md
CONTRIBUTING.md
*.md
LICENSE
Makefile
NOTICE
README.md
arm/
powerpc/
mips/
.golangci.yml
_temp
.vscode
node1
node2
node3
.gitignore
changelog.md
go.work
go.work.sum
tools/
test_integration/
test_e2e/
!test_e2e/test_api.go
!test_e2e/go.mod
!test_e2e/go.sum
mocks/
docker/
**/*_test.go
docs/
19 changes: 12 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,38 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: Bug
labels: bug
---

**Describe the bug**
## Describe the bug

A clear and concise description of what the bug is.

**To Reproduce**
## To Reproduce

Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
## Expected behavior

A clear and concise description of what you expected to happen.

**Screenshots**
## Screenshots

If applicable, add screenshots to help explain your problem.

**Application (please complete the following information):**
## Application

Please complete the following information:

- badaas version [X.X.X] or commit hash
- go version
- database vendor and version (in case of bugs related with BaDORM)

**Additional context**
## Additional context

Add any other context about the problem here.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/discussion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Discussion
about: Start a discussion for BaDaaS
title: ''
labels: question
---
<!-- Please join the DitRit discord server https://discord.gg/zkKfj9gj2C to ask questions and troubleshoot (use the BADAAS channel). For all other design discussions please continue. -->
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/user_story.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: User Story, To be verify
labels: enhancement
---

## Description
Expand All @@ -26,7 +26,7 @@ labels: User Story, To be verify

`[Put all others constraints here, like list of acceptances values or other]`

## Resources:
## Resources

`[Put all your resources here, like mockups, diagrams or other here]`

Expand All @@ -37,4 +37,3 @@ labels: User Story, To be verify
## Links

`[Only use by the team, to link this feature with epic, technical tasks or bugs]`

5 changes: 3 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:information_source: Don't forget to modify the changelog.md before merging this branch.

:information_source: Don't forget to modify config files:
- `badaas.example.yml`: the example file.
- `/scripts/e2e/api/ci-conf.yml`: otherwise you will probably break the CI. (*For local testing please use [act](https://github.com/nektos/act)*).

- `badaas.example.yml`: the example file.
- `tools/badctl/cmd/config/badaas.yml`: the default config file generated by badctl.
138 changes: 113 additions & 25 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
branch-naming-rules:
name: Check branch name
Expand All @@ -18,6 +19,41 @@ jobs:
min_length: 5
max_length: 50

check-style:
name: Code style
needs: [branch-naming-rules]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '^1.18'
cache: true
- name: badaas lint
uses: golangci/golangci-lint-action@v3
with:
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
- name: teste2e lint
uses: golangci/golangci-lint-action@v3
with:
working-directory: test_e2e
args: --config=../.golangci.yml
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
- name: badctl lint
uses: golangci/golangci-lint-action@v3
with:
working-directory: tools/badctl
args: --config=../../.golangci.yml
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true

unit-tests:
name: Unit tests
needs: [branch-naming-rules]
Expand All @@ -30,17 +66,35 @@ jobs:
with:
go-version: '^1.18'
cache: true
- name: Run test
run: go test $(go list ./... | sed 1d) -coverprofile=coverage.out -v
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Run BaDaaS tests
run: gotestsum --junitfile unit-tests-badaas.xml $(go list ./... | tail -n +2 | grep -v testintegration) -coverpkg=./... -coverprofile=coverage_unit.out
- uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage.out
path: coverage_unit.out
- name: Run BaDctl tests
run: gotestsum --junitfile unit-tests-badctl.xml ./tools/badctl/... -coverprofile=coverage_badctl.out
- uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage_badctl.out
- name: Test Report
uses: dorny/test-reporter@v1
if: always() # run this step even if previous steps failed
with:
name: Unit Tests Report # Name of the check run which will be created
path: unit-tests-*.xml # Path to test results
reporter: java-junit # Format of test results

check-style:
name: Code style
needs: [branch-naming-rules]
integration-tests:
name: Integration tests
needs: [unit-tests]
runs-on: ubuntu-latest
strategy:
matrix:
db: [postgresql, cockroachdb, mysql, sqlite, sqlserver]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -49,18 +103,54 @@ jobs:
with:
go-version: '^1.18'
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Start containers
run: docker compose -f "docker/${{ matrix.db }}/docker-compose.yml" up -d
if: ${{ matrix.db != 'sqlite' }}
- uses: kanga333/variable-mapper@master
id: export
with:
version: latest
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
key: ${{ matrix.db }}
map: |
{
"postgresql": {
"dialector": "postgresql"
},
"cockroachdb": {
"dialector": "postgresql"
},
"mysql": {
"dialector": "mysql"
},
"sqlite": {
"dialector": "sqlite"
},
"sqlserver": {
"dialector": "sqlserver"
}
}
export_to: env
- name: Run test
run: DB=${{ env.dialector }} gotestsum --junitfile integration-tests-${{ matrix.db }}.xml ./testintegration -tags=${{ matrix.db }} -coverpkg=./... -coverprofile=coverage_int_${{ matrix.db }}.out
- name: Test Report
uses: dorny/test-reporter@v1
if: always() # run this step even if previous steps failed
with:
name: ${{ matrix.db }} Integration Tests Report # Name of the check run which will be created
path: integration-tests-${{ matrix.db }}.xml # Path to test results
reporter: java-junit # Format of test results
- uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage_int_${{ matrix.db }}.out
- name: Stop containers
if: ${{ matrix.db != 'sqlite' }}
run: docker stop badaas-test-db

e2e-tests:
name: E2E Tests
needs: [unit-tests, check-style]
needs: [integration-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -71,41 +161,39 @@ jobs:
go-version: '^1.18'
cache: true
- name: Start containers
run: docker compose -f "scripts/e2e/docker-compose.yml" up -d --build
run: docker compose -f "docker/cockroachdb/docker-compose.yml" -f "docker/test_api/docker-compose.yml" up -d --build
- name: Wait for API server to be up
uses: mydea/action-wait-for-api@v1
with:
url: "http://localhost:8000/info"
timeout: 20
timeout: 60
- name: Run test
run: go test -v
run: go test ./test_e2e -v
- name: Get logs
if: always()
run: docker compose -f "scripts/e2e/docker-compose.yml" logs --no-color 2>&1 | tee app.log &
run: docker compose -f "docker/cockroachdb/docker-compose.yml" -f "docker/test_api/docker-compose.yml" logs --no-color 2>&1 | tee app.log &
- name: Stop containers
if: always()
run: docker compose -f "scripts/e2e/docker-compose.yml" down
run: docker compose -f "docker/cockroachdb/docker-compose.yml" -f "docker/test_api/docker-compose.yml" down
- uses: actions/upload-artifact@v3
with:
name: docker-compose-e2e-logs
path: app.log

sonarcloud:
name: SonarCloud
needs: [unit-tests, check-style]
needs: [check-style, integration-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download line coverage report
- name: Download line coverage reports
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage.out
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
22 changes: 17 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,33 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*-tests-*.xml

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

# Go workspace file
go.work
# go.work

# cockroach files
node*

#Vscode conf
# sqlite files
testintegration/sqlite:*

# vscode conf
.vscode

# binary output
badaas
!docs/badaas/
badctl
!tools/badctl/
!docs/badctl/

# test results
tools/badctl/cmd/gen/conditions/*_conditions.go
tools/badctl/cmd/gen/conditions/tests/**/badorm.go

# temporary directories
_temp
# Sphinx documentation
docs/_build/
Loading