Skip to content

Commit

Permalink
style: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye committed Oct 3, 2023
1 parent aace9d7 commit 20beeda
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 42 deletions.
74 changes: 38 additions & 36 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go and Node.js
uses: ./.github/actions/setup-go-node
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
yarn-cache: true
id: setup
cache: "yarn"
cache-dependency-path: "client/yarn.lock"

- name: Install Node.js dependencies
run: |
Expand All @@ -40,55 +44,47 @@ jobs:
- name: Lint Go code
run: |
cd server
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run ./...
build-postgres:
runs-on: ubuntu-latest
needs: lint

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: legacy
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

test:
name: Test
runs-on: ubuntu-latest
needs: [lint, build-postgres]

strategy:
matrix:
node-version: [20.x]
go-version: [1.21.x]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go and Node.js
uses: ./.github/actions/setup-go-node
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
yarn-cache: true
id: setup
cache: "yarn"
cache-dependency-path: "client/yarn.lock"

- name: Install Node.js dependencies
run: |
cd client
yarn install
- name: Start Postgresql
run: |
sudo service postgresql start
task docker
- name: Run React Native tests
run: |
cd client
yarn test
- name: Run PostgreSQL migrations
run: |
cd scripts
./verify_os.sh
- name: Run Go tests
run: |
cd server/tests
Expand All @@ -97,19 +93,25 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, build-postgres, test]

strategy:
matrix:
node-version: [20.x]
go-version: [1.21.x]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go and Node.js
uses: ./.github/actions/setup-go-node
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
yarn-cache: true
id: setup
cache: "yarn"
cache-dependency-path: "client/yarn.lock"

- name: Install Node.js dependencies
run: |
Expand Down
5 changes: 4 additions & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ require (
gorm.io/gorm v1.25.4
)

require gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
require (
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
)

require (
github.com/aws/aws-sdk-go v1.45.14
Expand Down
2 changes: 2 additions & 0 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 h1:FVCohIoYO7IJoDDVpV2pdq7SgrMH6wHnuTyrdrxJNoY=
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
Expand Down
4 changes: 2 additions & 2 deletions server/src/controller/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func SetupControllers(e *echo.Echo, db *gorm.DB) {
// Create a new instance of the controller with the database connection
userController := UserController{db}
personaController := PersonaController{db}
awsController := AwsController{db}
awsController := AwsController{db}

// User routes
e.GET("api/users", userController.GetAllUsers)
Expand All @@ -25,7 +25,7 @@ func SetupControllers(e *echo.Echo, db *gorm.DB) {
e.PUT("api/personas/:id", personaController.UpdatePersona)
e.DELETE("api/personas/:id", personaController.DeletePersona)

// AWS
// AWS
e.GET("v1/api/aws", awsController.dump)

}
2 changes: 1 addition & 1 deletion server/src/migrations/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ CREATE TABLE IF NOT EXISTS persona_tasks (
task_id INTEGER,
FOREIGN KEY (persona_id) REFERENCES personas (id),
FOREIGN KEY (task_id) REFERENCES tasks (id)
);
);
4 changes: 2 additions & 2 deletions server/tests/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func initTestDB() (*echo.Echo, *gorm.DB) {
func TestGetAllUsers(t *testing.T) {
e, db := initTestDB()

req := httptest.NewRequest(http.MethodGet, "/v1/api/users", nil)
req := httptest.NewRequest(http.MethodGet, "/api/users", nil)
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)

Expand All @@ -44,7 +44,7 @@ func TestGetAllUsers(t *testing.T) {
func TestGetUser(t *testing.T) {
e, db := initTestDB()

req := httptest.NewRequest(http.MethodGet, "/v1/api/users/1", nil)
req := httptest.NewRequest(http.MethodGet, "/api/users/1", nil)
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)

Expand Down

0 comments on commit 20beeda

Please sign in to comment.