Skip to content

Commit

Permalink
Merge pull request #4 from GenerateNU/cleanup-things
Browse files Browse the repository at this point in the history
Some repo fixes! + actions
  • Loading branch information
leoRysing authored Jan 15, 2024
2 parents b88e585 + f420ce6 commit c22b823
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 27 deletions.
9 changes: 2 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

[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! If its a frontend ticket,
screenshots are important, if its a backend ticket, please add pictures of
relevant postman screenshots or console printouts.
Please include a summary of the changes and the related issue. Please also include relevant motivation, context, and images! If its a frontend ticket, screenshots are important, if its a backend ticket, please add pictures of relevant postman screenshots or console printouts.

# 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.
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

Expand Down
30 changes: 21 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: 'Create env file'
run: |
touch .env
cat .env
- name: Set up Node
uses: actions/setup-node@v3
Expand All @@ -36,8 +40,13 @@ jobs:
- name: Lint Go code
run: make backend-lint

- name: Install frontend linters
run: |
cd frontend
yarn install
- name: Lint Frontend code
run: make frontent-lint
run: make frontend-lint
test:
name: Test
runs-on: ubuntu-latest
Expand All @@ -49,7 +58,7 @@ jobs:

services:
postgres:
image: postgres:latest
image: postgres:14.1-alpine
env:
POSTGRES_PASSWORD: pwd
POSTGRES_USER: user
Expand All @@ -66,6 +75,10 @@ jobs:
apt-get install --yes postgresql-client
- name: Check out repository code
uses: actions/checkout@v4
- name: 'Create env file'
run: |
touch .env
cat .env
- name: Import DB seed data
run:
Expand All @@ -77,15 +90,9 @@ jobs:
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
make backend-test
build:
name: Build
runs-on: ubuntu-latest
Expand All @@ -97,6 +104,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: 'Create env file'
run: |
touch .env
cat .env
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include .env

# Installing frontend dependencies
.PHONY: frontend-dep
frontend-dep:
Expand Down Expand Up @@ -33,7 +35,23 @@ backend-lint:
backend-format:
cd backend && go fmt

# Build the docker db
.PHONY: backend-docker
backend-docker:
docker-compose up

# Run backend
.PHONY: backend-run
backend-run:
cd backend && go run main.go

# convert the backend link to an ngrok link
.PHONY: backend-ngrok
backend-ngrok:
@echo ${EXPO_PUBLIC_API_DOMAIN}
cd backend && ngrok http --domain=${EXPO_PUBLIC_API_DOMAIN} 8080

# Test the backend
.PHONY: backend-test
backend-test:
cd backend
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ The installation process can vary, so follow the instructions for each item belo
- Afterwards, install all go dependencies using `make backend-dep`.
- [yarn](https://classic.yarnpkg.com/en/docs/install#mac-stable) - our package manager in the frontend
- Afterwards, install all yarn dependencies using `make frontend-dep`.
- [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
- [ngrok](https://ngrok.com/docs/getting-started/) - Allows us to easily connect
- You may need to run this to authenticate; `ngrok config add-authtoken 2ayIx9Z092NTzK4g6iR635XKtp9_XqbpW4vPEZmzxB6nyRqk`

If everything was successful, you can now compile and run the project!

Expand All @@ -33,6 +37,8 @@ We will be using some tools to make development a bit easier.

- [Swagger](https://github.com/swaggo/swag) - Will allow us to visualize the API and query requests from the database.
- [Makefile](https://opensource.com/article/18/8/what-how-makefile) - Will allow us to easily run scripts by consolidating them into Makefile commands. Make sure to read up about each command and ask questions. You should know what you are running!
- [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

### Third party integrations
For this project, we will be using some third-party APIs.
Expand Down
4 changes: 2 additions & 2 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"backend/src/models"
// "backend/src/models" not used yet
"backend/src/routes"

"github.com/gin-gonic/gin"
Expand All @@ -24,7 +24,7 @@ func main() {
panic("Failed to connect to database")
}

db.AutoMigrate(&models.User{})
// db.AutoMigrate(&models.User{})

r := gin.Default()

Expand Down
14 changes: 8 additions & 6 deletions backend/src/db/migrations/init.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
DROP TABLE IF EXISTS users;

CREATE TABLE IF NOT EXISTS users (
user_idid SERIAL PRIMARY KEY,
first_name varchar NOT NULL,
last_name varchar NOT NULL,
user_id SERIAL PRIMARY KEY,
first_name VARCHAR NOT NULL,
last_name VARCHAR NOT NULL,
pass_word VARCHAR NOT NULL,
email VARCHAR NOT NULL
);

-- Insert sample data into "users" table
INSERT INTO users (first_name, last_name)
INSERT INTO users (first_name, last_name, pass_word, email)
VALUES
('Ania', 'Misiorek'),
('Leroy', 'Shaigorodsky'),
('Ania', 'Misiorek', 'password', '[email protected]'),
('Leroy', 'Shaigorodsky', 'password', '[email protected]');
2 changes: 1 addition & 1 deletion backend/src/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ type User struct {
types.Model
FirstName string `gorm:"type:varchar(255);unique" json:"first_name" validate:"required"`
LastName string `gorm:"type:varchar(255);unique" json:"last_name" validate:"required"`
Password string `gorm:"type:text" json:"password" validate:"required"`
Password string `gorm:"type:text" json:"pass_word" validate:"required"`
Email string `gorm:"type:varchar(255);unique" json:"email" validate:"required,email"`
}
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@react-navigation/native": "^6.1.9",
"autoprefixer": "^10.4.16",
"axios": "^1.6.4",
"dotenv": "^16.3.1",
"eslint-plugin-typescript": "^0.14.0",
"expo": "~49.0.15",
"expo-status-bar": "~1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion frontend/services/CommonURLS.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const API_LINK = "http://localhost:8080"
export const API_LINK = `https://${process.env.EXPO_PUBLIC_API_DOMAIN}`;
5 changes: 4 additions & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "@tsconfig/react-native/tsconfig.json"
"extends": "@tsconfig/react-native/tsconfig.json",
"compilerOptions": {
"types": ["node"]
}
}
5 changes: 5 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3489,6 +3489,11 @@ dotenv-expand@~10.0.0:
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-10.0.0.tgz#12605d00fb0af6d0a592e6558585784032e4ef37"
integrity sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==

dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

dotenv@~16.0.3:
version "16.0.3"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07"
Expand Down

0 comments on commit c22b823

Please sign in to comment.