-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: start to full stack dev code (#10)
* feat: full stack dev code config files, db setup, BE connection to FE, swagger, github workflow, pull request template BREAKING CHANGE: * refactor: folder structure, file simplification, and tons of readme stuffs * docs: readme badge fix * test: db test now uses connect database function and pings that connection * ci: various clean up things with ci * refactor: remove go/prettier precommit hooks so go can go into backend * ci: fix lint * ci: updates to work better with windows * ci: fix build task failing * ci: add configuration env file support for ngrok domain name * style: rename types folder to models in the be, put the env file setup in a before running section in readme * docs: mention commitizen installation in readme
- Loading branch information
1 parent
47e4702
commit 1af4d33
Showing
39 changed files
with
1,311 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Description | ||
|
||
[Link to Ticket](insert the link to your ticket inside the parenthesis here) | ||
|
||
Please include a summary of the changes and the related issue. Please also | ||
include relevant motivation, context, and images! | ||
|
||
# How Has This Been Tested? | ||
|
||
Please describe the tests that you ran to verify your changes. If they are unit | ||
tests, provide the file name the tests are in. If they are not unit tests, | ||
describe how you tested the change. | ||
|
||
# Checklist | ||
|
||
- [ ] I have performed a self-review of my code | ||
- [ ] I have reached out to another developer to review my code | ||
- [ ] I have commented my code, particularly in hard-to-understand areas | ||
- [ ] New and existing unit tests pass locally with my changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: CI (Linting, Testing, Building) | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
branches: ['main'] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
go-version: [1.21.x] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Lint Go code | ||
run: | | ||
cd backend | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
golangci-lint run ./... | ||
- name: Format Frontend | ||
run: | | ||
cd client | ||
npm install | ||
npm run format | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
go-version: [1.21.x] | ||
container: node:latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_PASSWORD: pwd | ||
POSTGRES_USER: user | ||
POSTGRES_DB: carewallet | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Install PostgreSQL client | ||
run: | | ||
apt-get update | ||
apt-get install --yes postgresql-client | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Import DB seed data | ||
run: | ||
psql -d postgresql://user:[email protected]:5432/carewallet -f init.sql | ||
working-directory: ./backend/db/migrations | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
version: 3.x | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run Go tests | ||
run: | | ||
task test-all | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
go-version: [1.21.x] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
version: 3.x | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build app | ||
run: | | ||
task build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
*.DS_Store | ||
*package-lock.json | ||
vendor | ||
*.expo | ||
*node_modules | ||
|
||
*.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
default_stages: [commit, push] | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
exclude: 'backend/docs/' | ||
- id: trailing-whitespace | ||
- id: no-commit-to-branch | ||
args: ['--branch', 'main'] | ||
- repo: https://github.com/commitizen-tools/commitizen | ||
rev: v3.13.0 | ||
hooks: | ||
- id: commitizen | ||
stages: [commit-msg] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "none", | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"endOfLine": "auto", | ||
"bracketSpacing": true, | ||
"proseWrap": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,113 @@ | ||
# CareWallet | ||
<div align="center"> | ||
<h1>Care-Wallet</h1> | ||
<div> | ||
A fullstack application for the Care-Wallet project | ||
</div> | ||
<br/> | ||
<!-- Github Actions --> | ||
<a href="https://github.com/GenerateNU/Care-Wallet/actions/workflows/CI.yml"> | ||
<img src="https://github.com/GenerateNU/Care-Wallet/actions/workflows/CI.yml/badge.svg" | ||
alt="Workflow Status" /> | ||
</a> | ||
<br/> | ||
</div> | ||
|
||
## Set Up Your Development Environment | ||
|
||
First, understand the tech stack: | ||
|
||
- The database is [PostGreSQL](https://www.postgresql.org/) and will be | ||
containerized using [Docker](https://www.docker.com/). | ||
- The backend is [Golang](https://go.dev/) | ||
- The frontend is [TypeScript](https://www.typescriptlang.org/) with | ||
[ReactNative](https://reactnative.dev/) and | ||
[NativeWind](https://www.nativewind.dev) and uses [Expo](https://expo.dev/) as | ||
a build tool | ||
|
||
Before compiling and running our application, we need to install/setup several | ||
languages, package managers, and various tools. The installation process can | ||
vary, so follow the instructions for each item below! | ||
|
||
- [Go](https://go.dev/doc/install) - our primary backend language | ||
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) - our | ||
package manager in the frontend | ||
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) - useful for | ||
running docker | ||
- [ngrok](https://ngrok.com/docs/getting-started/) - Allows us to easily connect | ||
the frontend to backend code | ||
- [expo-go](https://docs.expo.dev/get-started/expo-go/) - Expo allows mobile | ||
devices to scan a QR code and view the code running on a mobile device | ||
|
||
If you wish to simulate a phone from your computer either below will work: | ||
|
||
- [xcode](https://docs.expo.dev/workflow/ios-simulator/) - A simulator to view | ||
the code on an iphone from a laptop | ||
- [android studio](https://docs.expo.dev/workflow/android-studio-emulator/) - An | ||
emulator to view the code on an android device from a laptop | ||
|
||
If everything was successful, you can now compile and run the project! | ||
|
||
Next, understand the development tools that will make our lives easier: | ||
|
||
- [Pre-commit](https://pre-commit.com) - standardizing code style and commits | ||
- [Swagger](https://github.com/swaggo/swag) - visualizing the api and return | ||
types of requests from the database | ||
- [Task](https://taskfile.dev) - speeding up development by running long | ||
commands in quick phrases | ||
|
||
Before committing anything, we need to install several tools. The installation | ||
process can vary, so follow the instructions for each item below! | ||
|
||
- [pre-commit](https://pre-commit.com/#installation) - our development tool to | ||
standardize development and ensure every file follows the same styling | ||
guidelines. | ||
- [commitizen](https://commitizen-tools.github.io/commitizen/#installation) - | ||
This allows us to organize commits! By typing `cz c` instead of | ||
`git commit -m ""`, we can organize each of our commits into one of nine | ||
categories: | ||
- **fix**: A bug fix. Correlates with PATCH in SemVer | ||
- **feat**: A new feature. Correlates with MINOR in SemVer | ||
- **docs**: Documentation only changes | ||
- **style**: Changes that do not affect the meaning of the code (white-space, | ||
formatting, missing semi-colons, etc) | ||
- **refactor**: A code change that neither fixes a bug nor adds a feature | ||
- **perf**: A code change that improves performance | ||
- **test**: Adding missing or correcting existing tests | ||
- **build**: Changes that affect the build system or external dependencies | ||
(example scopes: pip, docker, npm) | ||
- **ci**: Changes to our CI configuration files and scripts (example scopes: | ||
GitLabCI) | ||
- [Task](https://taskfile.dev/installation/) - our development tool to quickly | ||
run commands that run, test, and clean files. | ||
|
||
## Before Running | ||
|
||
1. Create a .env file in the root directory with a single line: | ||
`EXPO_PUBLIC_API_DOMAIN=your-ngrok-static-domain-here` | ||
- this will be used by the frontend services as well as the task file to | ||
launch ngrok! | ||
|
||
## Running the project | ||
|
||
1. Launch Docker Desktop | ||
2. In the base of the repo: run `task start-docker` | ||
|
||
- This will run `docker-compose down` then `docker-compose up` | ||
|
||
3. To build all of the dependencies of the project: run `task build` | ||
|
||
- This will install both frontend and backend dependencies | ||
|
||
4. Then, open a new tab to run commands in: run `task start-backend` | ||
|
||
- This will generate the swagger docs as well as start the backend | ||
- You can now view swagger: http://localhost:8080/swagger/index.html | ||
|
||
5. Next, in a new tab run `task start-ngrok` | ||
|
||
6. Finally, open one last new tab: run `task start-frontend` | ||
|
||
- This will start the frontend | ||
|
||
7. From here follow the prompt in step 6 to launch the frontend on your device | ||
of choice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
version: '3' | ||
dotenv: ['.env'] | ||
tasks: | ||
build: | ||
- | | ||
cd client | ||
npm install | ||
cd ../backend | ||
go mod tidy | ||
go install . | ||
format: | ||
- | | ||
cd client | ||
npm run format | ||
cd ../backend | ||
go fmt | ||
go vet | ||
swag f | ||
start-backend: | ||
- | | ||
cd backend | ||
swag i --parseDependency | ||
go run main.go | ||
start-frontend: | ||
- | | ||
cd client | ||
npm start | ||
start-ngrok: | ||
dotenv: ['.env'] | ||
cmds: | ||
- | | ||
cd backend | ||
ngrok http --domain=$EXPO_PUBLIC_API_DOMAIN 8080 | ||
start-docker: | ||
- | | ||
docker-compose down | ||
docker-compose up | ||
test-all: | ||
- | | ||
cd backend | ||
go test -count=1 carewallet/... | ||
pre-commit: | ||
- | | ||
pre-commit install | ||
pre-commit run --all-files |
Oops, something went wrong.