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

Tutorial #71

Open
wants to merge 109 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
dc408d6
update mockery version
FrancoLiberali Jul 27, 2023
e2c0776
fix typos in Authentication, resource and constructor
FrancoLiberali Jul 27, 2023
83e1446
fix route for auth unit tests
FrancoLiberali Jul 27, 2023
33e371c
remove error that is always nil
FrancoLiberali Jul 27, 2023
03c876c
add TODO to the changes to be done in the session service
FrancoLiberali Jul 27, 2023
960f598
add error management to middlewareJSON
FrancoLiberali Jul 27, 2023
1f7761f
add CommandInitializer to init configuration keys
FrancoLiberali Jul 27, 2023
28e3ecb
init database configuration keys
FrancoLiberali Jul 27, 2023
63de335
init session configuration keys
FrancoLiberali Jul 27, 2023
807e598
init initialization configuration keys
FrancoLiberali Jul 27, 2023
2de14ef
init server configuration keys
FrancoLiberali Jul 27, 2023
2dc5907
init logger configuration keys
FrancoLiberali Jul 27, 2023
cbb6f5c
remove unused r.md file in commands
FrancoLiberali Jul 27, 2023
d165eec
move time to utils
FrancoLiberali Jul 27, 2023
b80f2e4
create super user when adding the auth controller
FrancoLiberali Jul 27, 2023
88db618
update info controller and routes creation
FrancoLiberali Jul 27, 2023
1730a33
change the way badaas server is created
FrancoLiberali Jul 27, 2023
25f8e57
move test e2e to test_e2e/ and docker to docker/
FrancoLiberali Jul 28, 2023
f1bed03
do not run auto migration on test e2e execution + automigration refactor
FrancoLiberali Jul 28, 2023
f523952
update docs and developers utils
FrancoLiberali Jul 27, 2023
227c9c2
remove unnecesary init.sh for cockroach and add health check
FrancoLiberali Jul 31, 2023
e51325e
move db connection to orm module and make automigration possible by fx
FrancoLiberali Jul 31, 2023
ff2318e
info and auth modules now also provide the corresponding services and…
FrancoLiberali Jul 31, 2023
8ccf49c
use gotestsum to run tests + create tests report + tool to install de…
FrancoLiberali Jul 31, 2023
e3da4cc
add base models to orm
FrancoLiberali Jul 31, 2023
d12b69e
add crud services and repositories in orm module
FrancoLiberali Jul 31, 2023
e61ac47
adapt existing services and controllers to use orm module
FrancoLiberali Jul 31, 2023
ef381b2
add integration tests
FrancoLiberali Jul 31, 2023
319dd73
update documentation
FrancoLiberali Jul 31, 2023
a9c3ead
update changelog
FrancoLiberali Jul 31, 2023
0d23c80
add support for operators in conditions
FrancoLiberali Aug 2, 2023
76ec3ad
add noteq
FrancoLiberali Aug 2, 2023
48acfb0
add lt
FrancoLiberali Aug 2, 2023
50c98cb
add ltoreq
FrancoLiberali Aug 2, 2023
5a1f2a9
add gt
FrancoLiberali Aug 2, 2023
2533e08
add gtoreq
FrancoLiberali Aug 2, 2023
7561db8
add isnull
FrancoLiberali Aug 2, 2023
29104e6
add isnotnull
FrancoLiberali Aug 2, 2023
4a75076
add is true
FrancoLiberali Aug 2, 2023
82e9158
add is not true
FrancoLiberali Aug 2, 2023
0a60e91
add is false
FrancoLiberali Aug 2, 2023
9b9395c
add is not false
FrancoLiberali Aug 2, 2023
e277f57
add is unknown
FrancoLiberali Aug 2, 2023
1b94fbb
add is not unknown
FrancoLiberali Aug 2, 2023
a3e17cf
add is distict
FrancoLiberali Aug 2, 2023
cc33e8d
add is not distict
FrancoLiberali Aug 2, 2023
6fbe12a
add array in
FrancoLiberali Aug 2, 2023
a9e92b5
add array not in
FrancoLiberali Aug 2, 2023
d05e0ad
add like
FrancoLiberali Aug 2, 2023
70954a3
add between
FrancoLiberali Aug 2, 2023
26b9a0a
add not between
FrancoLiberali Aug 2, 2023
db62750
add and
FrancoLiberali Aug 2, 2023
d91f446
add or
FrancoLiberali Aug 2, 2023
b1778eb
add not
FrancoLiberali Aug 2, 2023
4215ea3
add unsafe conditions
FrancoLiberali Aug 2, 2023
28f4d79
use all coverage files in sonar
FrancoLiberali Aug 2, 2023
23ea895
ignore all tests results
FrancoLiberali Aug 2, 2023
e7e8f45
update changelog
FrancoLiberali Aug 2, 2023
9107f17
create mocks for new types
FrancoLiberali Aug 2, 2023
6c6d117
replace inverse join generation by inverse reference in models
FrancoLiberali Aug 3, 2023
18b87e5
table class in place of strings for table name
FrancoLiberali Aug 3, 2023
32b8501
update to conditions generation that fix embedded names
FrancoLiberali Aug 3, 2023
3def06b
refactor: add field identifier
FrancoLiberali Aug 3, 2023
84460cc
add possibility to do preload
FrancoLiberali Aug 3, 2023
b353437
support nested preloads
FrancoLiberali Aug 3, 2023
7fa6b18
add a way to know if a relation was loaded or not
FrancoLiberali Aug 3, 2023
f95f61f
list and nested attributes preload
FrancoLiberali Jun 28, 2023
958f0be
update mocks
FrancoLiberali Aug 3, 2023
4a7beb3
update changelog
FrancoLiberali Aug 3, 2023
0d72fd4
refactor: replace gorm.db by query object
FrancoLiberali Aug 4, 2023
0236a7c
move table to the same file of query
FrancoLiberali Aug 4, 2023
2fc0219
move unsafe condition to unsafe package
FrancoLiberali Aug 4, 2023
95b0dbd
add details to errors
FrancoLiberali Aug 4, 2023
12b8255
add dynamic operators
FrancoLiberali Aug 4, 2023
e5e925e
add unsafe operators
FrancoLiberali Aug 4, 2023
745f13e
update chagelog
FrancoLiberali Aug 7, 2023
948a829
update mocks
FrancoLiberali Aug 7, 2023
6fc1481
add new linting configuration
FrancoLiberali Aug 7, 2023
58744db
fix new lint errors
FrancoLiberali Aug 7, 2023
5ebe2b7
add test e2e to linting
FrancoLiberali Aug 7, 2023
90829cf
fix new linting errors in test e2e
FrancoLiberali Aug 7, 2023
0edd34c
badaas-orm module reorganization
FrancoLiberali Aug 9, 2023
4d51366
add readthedocs files
FrancoLiberali Aug 7, 2023
ab7cca7
add golangci-lint to dependencies
FrancoLiberali Aug 7, 2023
19bd517
move validators to utils
FrancoLiberali Aug 7, 2023
2088aa2
move badaas docs to readthedocs
FrancoLiberali Aug 7, 2023
2205389
move badaas-orm docs to readthedocs
FrancoLiberali Aug 7, 2023
b5eb587
add code of conduct
FrancoLiberali Aug 7, 2023
1de698b
add readme badges
FrancoLiberali Aug 7, 2023
afb964c
move contributing docs to readthedocs
FrancoLiberali Aug 8, 2023
2536cb1
add new default logger and update gormzap
FrancoLiberali Aug 9, 2023
5338d60
add transaction trace
FrancoLiberali Aug 9, 2023
ad6043f
add logger config from config file
FrancoLiberali Aug 9, 2023
c1eb636
move gormdatabase to database and config new logger
FrancoLiberali Aug 9, 2023
f5b7682
update mocks
FrancoLiberali Aug 9, 2023
aaafd70
update docs
FrancoLiberali Aug 9, 2023
cc070a6
add support for other sql databases
FrancoLiberali Aug 10, 2023
34a2251
allow runing int tests over multiple databases
FrancoLiberali Aug 10, 2023
ab4927b
add database specific operators
FrancoLiberali Aug 10, 2023
019a7f2
update docs
FrancoLiberali Aug 10, 2023
2311133
update changelog
FrancoLiberali Aug 10, 2023
2ac2d9c
rename query to gormquery
FrancoLiberali Aug 23, 2023
78ab915
change crud repos to orm query api
FrancoLiberali Aug 23, 2023
e76268f
new conditions api
FrancoLiberali Aug 28, 2023
1f54467
adapt docs to new api
FrancoLiberali Aug 23, 2023
2ec2df2
move gormfx to a independient package
FrancoLiberali Aug 22, 2023
8f74308
add badaas integration tests
FrancoLiberali Aug 23, 2023
1e2dafa
add badaas-orm quickstart docs
FrancoLiberali Aug 16, 2023
83f5e8a
add badaas-orm tutorial docs
FrancoLiberali Aug 16, 2023
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
22 changes: 13 additions & 9 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
.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_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 badaas-orm)

**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]`

4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
: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.
124 changes: 100 additions & 24 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,35 @@ 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:
version: v1.53.3
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
- name: teste2e lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.3
working-directory: test_e2e
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 +60,29 @@ 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 unit tests
run: gotestsum --junitfile unit-tests.xml $(go list ./... | grep -v testintegration) -coverpkg=./... -coverprofile=coverage_unit.out
- uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage.out
path: coverage_unit.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,14 +91,50 @@ 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
Expand All @@ -71,41 +149,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 }}
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@

# 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
# database files
node*
testintegration/sqlite:*

#Vscode conf
# vscode conf
.vscode

# binary output
badaas
!docs/badaas

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