Skip to content

Commit

Permalink
Merge branch 'jak103:main' into feature/user-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraingo authored Jun 18, 2024
2 parents 7116f6e + 601c0e0 commit cfe2f0c
Show file tree
Hide file tree
Showing 159 changed files with 11,061 additions and 1,715 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Site Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: site/package-lock.json
- run: npm ci
- run: npm run build --if-present
- run: npm test

defaults:
run:
working-directory: ./site
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@ dist
go.work

/.vscode
/.idea
/.idea
local.env
23 changes: 23 additions & 0 deletions Dockerfile.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1
FROM node:20-alpine AS site
WORKDIR /app/site
COPY ./site .
RUN npm install
ENV NODE_ENV production
RUN npm run build

FROM golang:1.22.3 AS backend
WORKDIR /app
COPY ./backend .
RUN CGO_ENABLED=0 go build -o powerplay ./main.go

FROM alpine:latest as certs
RUN apk --update add ca-certificates

FROM scratch
WORKDIR /app
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=backend /app/powerplay /app/powerplay
COPY ./static /app/static
COPY --from=site /app/site/dist/spa /app/static
CMD ["/app/powerplay"]
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

migrate:
@echo "🚀 Running app in detached mode and applying migrations"
@docker-compose -f docker-compose.yml up -d
@docker-compose -f docker-compose.yml exec backend bash -c "cd /powerplay/backend && go run . -migrate" || (echo "Migration failed, halting" && exit 1)
@docker compose -f docker-compose.yml up -d
@docker compose -f docker-compose.yml exec backend bash -c "cd /powerplay/backend && go run . -migrate" || (echo "Migration failed, halting" && exit 1)

nuke-migrations:
@echo "💥 Truncating migrations table"
@docker-compose -f docker-compose.yml exec database bash -c "psql -d powerplay -c 'TRUNCATE migrations';"
@docker compose -f docker-compose.yml exec database bash -c "psql -d powerplay -c 'TRUNCATE migrations';"
@$(MAKE) migrate

production_image:
Expand All @@ -20,6 +20,12 @@ production_debug:
run_local_image:
docker run -p 127.0.0.1:9001:9001/tcp powerplay:latest

seed_test_data:
@echo "🌱 Running backend in detached mode and seeding test data"
@docker compose -f docker-compose.yml up -d
@docker compose -f docker-compose.yml exec backend bash -c "cd /powerplay/backend && go run . -seed-test" || (echo "Seeding failed, halting" && exit 1)


test:
@echo "🚀 Testing code: Running go test inside the backend container"
@docker-compose -f docker-compose.yml exec -T backend bash -c "cd /powerplay/backend && go test -v ./..."
@docker compose -f docker-compose.yml exec -T backend bash -c "cd /powerplay/backend && go test -v ./..."
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@


[![Go](https://github.com/jak103/powerplay/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/jak103/powerplay/actions/workflows/go.yml)
[![Site Node.js CI](https://github.com/jak103/powerplay/actions/workflows/node.js.yml/badge.svg)](https://github.com/jak103/powerplay/actions/workflows/node.js.yml)

## Table of Contents
- [Adding and Updating API Endpoints](#adding-and-updating-api-endpoints)
- [Team Specific Pages](#team-specific-pages)
- [Helpful Commands](#helpful-commands)
- [Clear and Re-run Migrations](#clear-and-re-run-migrations)
- [Run All Go Tests](#run-all-go-tests)

## Team Specific Pages
- [Frontend Site](/site/README.md)
- [Frontend App](/app/README.md)
- [Chat Functions]()
- [Scoreboard]()
- [Scheduling]()
- [Backend](/backend/README.md)

## Helpful Commands

### Environment Variables
We use dotenv and a local.env to store all environment variables.
Please copy config/local.env.example to config/local.env and update
any environment variables.

### Clear and Re-run Migrations
Sometimes you need to clear out migrations due to a model change.
While we are in early development we've decided to drop and recreate
Expand All @@ -31,21 +49,3 @@ pass all tests before committing code.
```shell
make test
```

## Adding and Updating API Endpoints

### Ensure Model is Created and Up to Date
1. Navigate to the models directory: \
`backend/internal/models`

### Add API Endpoint
1. Navigate to the server directory: \
`backend/internal/server/apis`

### Add DB methods used in API endpoint
1. Navigate to the db directory: \
`backend/internal/db`

### Update Open API docs**
1. Navigate to the open api spec directory: \
`static/oas/v1`
2 changes: 2 additions & 0 deletions app/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/.quasar
/node_modules
.eslintrc.cjs
**/.eslintrc.js
**/sw.js
/quasar.config.*.temporary.compiled*
Loading

0 comments on commit cfe2f0c

Please sign in to comment.