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

Dev #62

Merged
merged 97 commits into from
Apr 24, 2024
Merged

Dev #62

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
82cff52
feature(#6): add dependencies
talDoFlemis Mar 29, 2024
a129e5d
improvement(#6): update gitignore to remove autogenerated code
talDoFlemis Mar 29, 2024
21cef13
feature(#6): add test helpers
talDoFlemis Mar 29, 2024
efb7296
feature(#6): add config management
talDoFlemis Mar 29, 2024
45b04ce
feature(#6): add auth and logger ports
talDoFlemis Mar 29, 2024
d303545
feature(#6): add postgres adapter for auth port
talDoFlemis Mar 29, 2024
5ba1bf2
feature(#6): add zap logger adapter for logger port
talDoFlemis Mar 29, 2024
25c7728
feature(#6): add local_idp adapter for auth port
talDoFlemis Mar 29, 2024
3d28c6e
feature(#6): add user domain
talDoFlemis Mar 29, 2024
24dfa6b
feature(#6): add validation service
talDoFlemis Mar 29, 2024
8cad6f0
feature(#6): add authentication service
talDoFlemis Mar 29, 2024
0e6bfe1
feature(#6): add fiber http driver
talDoFlemis Mar 29, 2024
55cc174
improvement(#6): update main.go to mount and inject services
talDoFlemis Mar 29, 2024
b6793d6
improvement(#6): update golang ci
talDoFlemis Mar 29, 2024
f851abe
fix(#6): build-web running web
talDoFlemis Mar 29, 2024
a7864e2
improvement(#6): add unprocessable entity in swagger docs
talDoFlemis Mar 30, 2024
b039b74
improvement(#6): move user dtos to service instead of domain
talDoFlemis Mar 31, 2024
b99f2e3
improvement(#6): add get user info endpoint
talDoFlemis Mar 31, 2024
66dbe64
improvement(#6): move create token to service
talDoFlemis Mar 31, 2024
707900b
Merge pull request #9 from talDoFlemis/6-feat-adicionar-autenticação-…
talDoFlemis Mar 31, 2024
539fb76
Merge branch 'main' into dev
talDoFlemis Apr 11, 2024
fffd3b7
improvement(#20): setup shadcn
Lu1z-Gust4v0 Apr 17, 2024
f44022b
improvement(#20): add shadcn form component
Lu1z-Gust4v0 Apr 17, 2024
7ad9361
improvement(#20): add shadcn button variant
Lu1z-Gust4v0 Apr 17, 2024
5c67e68
feature(#20): add login form component
Lu1z-Gust4v0 Apr 17, 2024
7d86f55
feature(#20): add login section component
Lu1z-Gust4v0 Apr 17, 2024
3c3489b
feature(#20): add login page
Lu1z-Gust4v0 Apr 17, 2024
b0456e5
fix(#20): broken generate connection str
talDoFlemis Apr 17, 2024
2d90679
feature(#20): add migration script
talDoFlemis Apr 17, 2024
85e5aa9
improvement(#20): add prettier
Lu1z-Gust4v0 Apr 17, 2024
b7680ff
improvement(#20): add prettier tasks
Lu1z-Gust4v0 Apr 17, 2024
e37aea0
cleanup(#20): format code
Lu1z-Gust4v0 Apr 17, 2024
fa72391
improvement(#20): add formating tast on CI
Lu1z-Gust4v0 Apr 17, 2024
cac0b35
improvement(#20): Add new color scheme
Lu1z-Gust4v0 Apr 18, 2024
df6f178
cleanup(#20): format code
Lu1z-Gust4v0 Apr 18, 2024
b511364
feature(#22): add register form, register section
Lu1z-Gust4v0 Apr 18, 2024
2e74a42
improvement(#22): Update login section, add register page
Lu1z-Gust4v0 Apr 18, 2024
54dae10
Merge pull request #51 from talDoFlemis/20-add-login-page
talDoFlemis Apr 18, 2024
70cae16
feature(#52): add api provider
Lu1z-Gust4v0 Apr 20, 2024
e41f6f3
cleanup(#52): refactor error interceptor
Lu1z-Gust4v0 Apr 20, 2024
50cb7fb
feature(#52): add auth service
Lu1z-Gust4v0 Apr 20, 2024
579cf82
cleanup(#52): remove interceptors, update request path
Lu1z-Gust4v0 Apr 20, 2024
536af06
feature(#52): add token util functions
Lu1z-Gust4v0 Apr 20, 2024
2dc16f9
feature(#52): add next auth provider
Lu1z-Gust4v0 Apr 20, 2024
3c8ccc2
feature(#52): add next auth provider
Lu1z-Gust4v0 Apr 20, 2024
f6e828e
fix(#52): add auth option to getServerSession
Lu1z-Gust4v0 Apr 20, 2024
c90d09c
feature(#52): Add authentication to register form
Lu1z-Gust4v0 Apr 20, 2024
3816c0c
fix(#52): Remove redirect from getServerSession
Lu1z-Gust4v0 Apr 20, 2024
2e7a7a3
feature(#52): Add authentication to login form
Lu1z-Gust4v0 Apr 20, 2024
4068d4f
feature(#52): Add authentication middleware
Lu1z-Gust4v0 Apr 20, 2024
df90fad
feature(#52): Add session with refresh hook
Lu1z-Gust4v0 Apr 20, 2024
90581b7
fix(#52): api auth urls
Lu1z-Gust4v0 Apr 20, 2024
0b01cf4
feature(#52): Add home page
Lu1z-Gust4v0 Apr 20, 2024
adb6ad7
cleanup(#52): format code
Lu1z-Gust4v0 Apr 20, 2024
5f25f62
fix(#52): api auth urls
Lu1z-Gust4v0 Apr 20, 2024
a77300f
docs(#52): update api docs
Lu1z-Gust4v0 Apr 20, 2024
007469e
improvement(#53): update golang ci to run in parallel
talDoFlemis Apr 18, 2024
fd9a825
improvement(#53): update nodejs ci to run in parallel
talDoFlemis Apr 18, 2024
2ef0a69
feature(#53): add vitest as dev dependency
talDoFlemis Apr 19, 2024
ab45146
feature(#53): add vitest setup and utilities
talDoFlemis Apr 19, 2024
d9664e6
improvement(#53): update login-form to be more test friendly
talDoFlemis Apr 19, 2024
7061d2f
tests(#53): add tests to login-form
talDoFlemis Apr 19, 2024
639a908
tests(#53): add tests to login-section
talDoFlemis Apr 19, 2024
0c4b903
improvement(#53): update register-form to be more test friendly
talDoFlemis Apr 20, 2024
70e2c4b
tests(#53): add tests for register-form
talDoFlemis Apr 20, 2024
7a11d8d
feature(#53): add accessibility for eslint
talDoFlemis Apr 20, 2024
63d9989
fix(#53): card header with bad accessibility
talDoFlemis Apr 20, 2024
0fd8cb3
feature(#53): add Dockerfile to backend
talDoFlemis Apr 20, 2024
b34db97
feature(#53): add environment variables read on backend
talDoFlemis Apr 20, 2024
3370122
feature(#53): add migration script
talDoFlemis Apr 20, 2024
4d783b2
feature(#53): add playwright as dev dependency
talDoFlemis Apr 20, 2024
b5bd3a4
tests(#53): add e2e tests for sign-in page
talDoFlemis Apr 20, 2024
c2b5d52
tests(#53): add e2e tests for sign-up page
talDoFlemis Apr 20, 2024
666ba55
fix(#53): broken node ci because of cache
talDoFlemis Apr 20, 2024
ac2e5cf
feature(#53): add testcontainers as dev dependency
talDoFlemis Apr 21, 2024
ac3669a
feature(#53): add containers
talDoFlemis Apr 21, 2024
c6bc9e6
feature(#53): add e2e ci pipeline
talDoFlemis Apr 21, 2024
58c042d
Merge pull request #55 from talDoFlemis/53-test-setup-inicial-dos-tes…
talDoFlemis Apr 21, 2024
b166ea7
Merge branch 'dev' into 52-feat-add-authentication
Lu1z-Gust4v0 Apr 23, 2024
7eb5129
tests(#52): fix forms unit tests
Lu1z-Gust4v0 Apr 23, 2024
b60aa40
cleanup(#52): format code
Lu1z-Gust4v0 Apr 23, 2024
58676b5
improvement(#52): Add dashboard page
Lu1z-Gust4v0 Apr 24, 2024
4fc7ca4
improvement(#52): Standarize submit functions, update tests
Lu1z-Gust4v0 Apr 24, 2024
3d1e252
improvement(#52): add auth secret to constants, and provide default v…
Lu1z-Gust4v0 Apr 24, 2024
9f355bb
fix(#52): type error on mock function
Lu1z-Gust4v0 Apr 24, 2024
b46fceb
fix(#52): package lock
Lu1z-Gust4v0 Apr 24, 2024
8c5b660
improvement(#52): add husky and lint-staged to format commits
Lu1z-Gust4v0 Apr 24, 2024
9a9ec75
feature(#52): Add forgot password page
Lu1z-Gust4v0 Apr 24, 2024
8d0c06d
tests(#52): Fix e2e sign in tests
Lu1z-Gust4v0 Apr 24, 2024
1a59f68
tests(#52): Update e2e tests
Lu1z-Gust4v0 Apr 24, 2024
ca61677
tests(#52): Add envs to e2e CI
Lu1z-Gust4v0 Apr 24, 2024
8cbe31f
tests(#52): update setup comand on playwright
Lu1z-Gust4v0 Apr 24, 2024
04150dc
tests(#52): update worker config in playwright
Lu1z-Gust4v0 Apr 24, 2024
034e8fc
tests(#52): disable safari and firefox playwright env
talDoFlemis Apr 24, 2024
8cbcc6a
improvement(#52): add cache to golang CIs
talDoFlemis Apr 24, 2024
77bf4e9
improvement(#52): add cache to playwright e2e tests
talDoFlemis Apr 24, 2024
43991d7
Merge pull request #54 from talDoFlemis/52-feat-add-authentication
talDoFlemis Apr 24, 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
85 changes: 85 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: E2E Tests
on:
push:
branches: [main]
pull_request:
branches: [main, dev]

env:
NEXTAUTH_URL: "http://localhost:3000"
NEXTAUTH_SECRET: "saidmarinaamoreternoA8GPVSoaK/mUU="

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
cache-dependency-path: "./frontend/package-lock.json"

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
cache-dependency-path: backend/go.sum

- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Up database
run: task db-up -- -d

- name: Migrate database
run: task backend:migrate

- name: Seed database
run: task backend:seed

- name: Run backend
run: task backend:run-web -- &


- name: Get installed Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').dependencies['@playwright/test'].version)")" >> $GITHUB_ENV
working-directory: frontend

- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

- name: Install dependencies
run: npm ci
working-directory: frontend

- run: npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: frontend

- run: npx playwright install-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: frontend

- name: Run Playwright tests
run: npx playwright test
working-directory: frontend

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30
74 changes: 63 additions & 11 deletions .github/workflows/go-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Golang CI

on:
push:
branches: [ "main" ]
branches: ["main"]
paths: ["backend/**"]
pull_request:
branches: ["main", "dev"]
Expand All @@ -11,20 +11,22 @@ on:
permissions:
contents: read

defaults:
run:
working-directory: ./backend

jobs:
ci:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend

steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
go-version: "1.22.x"
cache-dependency-path: backend/go.sum


- name: Install Task
uses: arduino/setup-task@v1
Expand All @@ -33,16 +35,66 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Format Check
run: test -z "$(gofmt -l .)"
run: task check-format

- name: Build
run: task build-web

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
working-directory: backend

- name: Build
run: task build-web
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
cache-dependency-path: backend/go.sum

- name: Install dependencies
run: |
go install gotest.tools/gotestsum@latest

- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Test with the Go CLI
run: task test-light
run: task test-all

check-vuln:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
cache-dependency-path: backend/go.sum

- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest

- name: Check for vulnerabilities
run: task check-vuln
43 changes: 37 additions & 6 deletions .github/workflows/node-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: NodeJS CI

on:
push:
branches: [ "main" ]
branches: ["main"]
paths: ["frontend/**"]
pull_request:
branches: ["main", "dev"]
Expand All @@ -11,20 +11,23 @@ on:
permissions:
contents: read

defaults:
run:
working-directory: frontend

jobs:
ci:
build-ci:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: "20.x"
cache: "npm"
cache-dependency-path: "./frontend/package-lock.json"

- name: Install Task
uses: arduino/setup-task@v1
Expand All @@ -38,8 +41,36 @@ jobs:
- name: Check lint
run: task lint

- name: Check format
run: task check-format

- name: Check types
run: task type-check

- name: Check build
run: task build

unit-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
cache-dependency-path: "./frontend/package-lock.json"

- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Unit tests
run: task unit-test-ci
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tasks:
db-up:
desc: "Up a postgres instance"
cmds:
- docker compose up database
- docker compose up database {{.CLI_ARGS}}

includes:
frontend:
Expand Down
44 changes: 44 additions & 0 deletions backend/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
full_bin = "go run ./cmd/web/main.go"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "test"]
exclude_file = []
exclude_regex = ["_test.go", "_gen.go", "_templ.go"]
exclude_unchanged = false
follow_symlink = false
include_dir = ["internal", "pkg", "cmd", "config", "docs"]
include_ext = ["go", "tpl", "tmpl", "html", "toml"]
include_file = ["config.json"]
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = true
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = false
keep_scroll = true
13 changes: 13 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.dockerignore
.gcloudignore
.gitignore
test/
tmp/
c.out
./brain.test
./Taskfile.yaml
./Dockerfile
./.air.toml
./.task/
./README.md
./config.json
8 changes: 0 additions & 8 deletions backend/.env.example

This file was deleted.

3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ tmp/
main
*_gen.go
/cmd/api/gahoot
coverage.html
docs/*
!docs/docs.go
23 changes: 23 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.22.1-alpine AS builder
WORKDIR /app

RUN apk add --no-cache \
gcc \
musl-dev \
ca-certificates

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o server -ldflags '-s -w -extldflags "-static"' ./cmd/web

FROM scratch
WORKDIR /app

LABEL maintainer="Said Rodrigues"
LABEL email="coderflemis@gmail.com"

COPY --from=builder /app/server ./
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

EXPOSE 42069

CMD ["/app/server"]
Loading
Loading