Skip to content

Commit

Permalink
Merge pull request #3 from GenerateNU/github-items
Browse files Browse the repository at this point in the history
GitHub items + Frontend cleanup
  • Loading branch information
aniamisiorek authored Jan 11, 2024
2 parents a569539 + 4deed83 commit aa9f48d
Show file tree
Hide file tree
Showing 16 changed files with 1,561 additions and 45 deletions.
16 changes: 16 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# More details are here: https://help.github.com/articles/about-codeowners/

# The '*' pattern is global owners.

# Order is important. The last matching pattern has the most precedence.
# The folders are ordered as follows:

# In each subsection folders are ordered first by depth, then alphabetically.
# This should make it easy to add new rules without breaking existing ones.

# Global rule:
* @aniamisiorek
* @leoRysing
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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! 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.

# 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
113 changes: 113 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
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@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install Linters
run: |
cd backend
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Lint Go code
run: make backend-lint

- name: Lint Frontend code
run: make frontent-lint
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: algo
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/algo -f init.sql
working-directory: ./backend/src/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: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Build Go app
run: |
cd backend
go build -v
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
frontend-dep:
cd frontend && yarn install

# running the frontend
.PHONY: frontend-run
frontend-run:
cd frontend && yarn start

# Lint the frontend source code
.PHONY: frontend-lint
frontend-lint:
cd frontend && yarn lint

# Format the frontend source code
.PHONY: frontend-format
frontend-format:
cd frontend && yarn format

# Installing backend dependencies
.PHONY: backend-dep
backend-dep:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The installation process can vary, so follow the instructions for each item belo
If everything was successful, you can now compile and run the project!

### Extra Dependencies
Install these in the backend directory
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install github.com/cosmtrek/air@latest

Expand Down
2 changes: 1 addition & 1 deletion backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// @BasePath /api
func main() {
dsn := "host=localhost user=user password=pwd dbname=algo port=5432 sslmode=disable"
db, _ := gorm.Open(postgres.Open(dsn), &gorm.Config{})
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
panic("Failed to connect to database")
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-env node */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
};
12 changes: 12 additions & 0 deletions frontend/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"bracketSameLine": true,
"printWidth": 80,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false

}
14 changes: 14 additions & 0 deletions frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import { getAllUsers } from './services/users';
import { useEffect, useState } from 'react';
import { User } from './types/types';

export default function App() {
const [users, setUsers] = useState<User[]>();
useEffect(() => {
getAllUsers().then((data) => setUsers(data))
})
return (
<View style={styles.container}>
<Text className="font-bold">Open up App.js to start working on your app!</Text>
{
users &&
users.map((user, index) => (
<Text key={index} className="pb-2">
{`FirstName: ${user.firstName} LastName: ${user.lastName}`}
</Text>
))}
<StatusBar style="auto" />
</View>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function(api) {
export default function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ["nativewind/babel"],
};
};
}
7 changes: 7 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"lint": "npx eslint .",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
Expand All @@ -12,6 +13,7 @@
"@react-navigation/native": "^6.1.9",
"autoprefixer": "^10.4.16",
"axios": "^1.6.4",
"eslint-plugin-typescript": "^0.14.0",
"expo": "~49.0.15",
"expo-status-bar": "~1.6.0",
"nativewind": "^2.0.11",
Expand All @@ -26,6 +28,11 @@
"@types/jest": "^29.5.11",
"@types/react": "^18.2.46",
"@types/react-test-renderer": "^18.0.7",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"eslint": "^8.56.0",
"eslint-config-universe": "^12.0.0",
"prettier": "^3.1.1",
"tailwindcss": "3.3.2",
"typescript": "^5.3.3"
},
Expand Down
1 change: 1 addition & 0 deletions frontend/services/CommonURLS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const API_LINK = "http://localhost:8080"
8 changes: 8 additions & 0 deletions frontend/services/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import axios, { AxiosResponse } from 'axios';
import { API_LINK } from './CommonURLS';
import { User } from '../types/types';

export const getAllUsers = async (): Promise<User[]> => {
const response: AxiosResponse<User[]> = await axios.get<User[]>(`${API_LINK}/users`);
return response.data;
}
24 changes: 11 additions & 13 deletions frontend/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/** @type {import('tailwindcss').Config} */

module.exports = {
content: [
"./App.{js,jsx,ts,tsx}",
"./components/**/*.{js,jsx,ts,tsx}",
"./public/**/*.{js,jsx,ts,tsx}",
"./screens/**/*.{js,jsx,ts,tsx}",
"./services/**/*.{js,jsx,ts,tsx}"
],
theme: {
extend: {},
},
plugins: [],
}
export const content = [
"./App.{js,jsx,ts,tsx}",
"./components/**/*.{js,jsx,ts,tsx}",
"./public/**/*.{js,jsx,ts,tsx}",
"./screens/**/*.{js,jsx,ts,tsx}",
"./services/**/*.{js,jsx,ts,tsx}"
];
export const theme = {
extend: {},
};
export const plugins = [];
6 changes: 6 additions & 0 deletions frontend/types/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface User {
firstName: string;
lastName: string;
password: string;
email: string;
}
Loading

0 comments on commit aa9f48d

Please sign in to comment.