Skip to content

Commit

Permalink
➡️ merge pull request #14 from devsoc-unsw/feature/login
Browse files Browse the repository at this point in the history
Signup/Login Feature + Integration Tests + CI Pipeline setup
  • Loading branch information
lachlanshoesmith authored Nov 12, 2024
2 parents d98ea73 + 6c664fb commit c3b29bc
Show file tree
Hide file tree
Showing 22 changed files with 4,380 additions and 135 deletions.
17 changes: 17 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Build"
description: "Sets up the repository"
runs:
using: "composite"
steps:
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: latest
run_install: |
- cwd: './backend'
- name: Install Node.js
uses: actions/setup-node@v3
- name: Install dependencies
shell: bash
working-directory: ./backend
run: pnpm install
11 changes: 11 additions & 0 deletions .github/actions/docker-compose/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Docker-Compose Setup'
description: 'Sets up docker-compose'
runs:
using: 'composite'
steps:
- name: Download Docker-Compose plugin
shell: bash
run: curl -SL https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
- name: Make plugin executable
shell: bash
run: sudo chmod +x /usr/local/bin/docker-compose
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests
on:
workflow_dispatch:
push:
branches:
- main
- feature/login
pull_request:
branches:
- main
- feature/login
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432
NODE_ENV: test
jobs:
integration-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build
- uses: ./.github/actions/docker-compose
- name: Run tests
run: pnpm run test:int
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ echo "https://api.cloudflare.com/client/v4/pages/webhooks/deploy_hooks/ENDPOINT_

you can now use the `rebuild` script in the root of the repository to initiate manual deployments without having to push changes to `main`.

## testing

To run tests locally, follow the steps below.
1. Create a new file called .env.test in the backend folder. Set the following values:
```
DATABASE_URL="postgres://postgres:postgres@localhost:5432"
DIRECT_URL="postgres://postgres:postgres@localhost:5432"
NODE_ENV=test
```
2. Ensure you have docker installed and make sure you have the docker engine running.

3. Make sure that the tests you've written are in the tests directory. You can then run these tests by running:
```
npm run test:int
```

### setting up the discord bot

if you're not interested in self-hosting, you can invite the pyramids discord bot [here](https://discord.com/oauth2/authorize?client_id=1301423026633445447&permissions=17600776112128&integration_type=0&scope=applications.commands+bot).
Expand Down
3 changes: 3 additions & 0 deletions backend/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL="postgres://postgres:postgres@localhost:5432"
DIRECT_URL="postgres://postgres:postgres@localhost:5432"
NODE_ENV=test
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
# Keep environment variables out of version control
.env
.env
16 changes: 16 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
db:
image: postgres:14.1-alpine
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=local_db
ports:
- '5432:5432'
volumes:
- db:/var/lib/postgresql/data

volumes:
db:
driver: local
16 changes: 11 additions & 5 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node src/index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
"start": "NODE_ENV=dev ts-node src/index.ts",
"test": "vitest",
"test:int": "./scripts/run-integration.sh"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"prisma": "^5.21.1",
"@prisma/client": "^5.21.1",
"bcrypt": "^5.1.1",
"cors": "^2.8.5",
"express": "^4.21.1",
"express-session": "^1.18.1",
"prisma": "^5.21.1",
"zod": "^3.23.8",
"zod-prisma-types": "^3.1.8"
},
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/express": "4",
"@types/express-session": "^1.18.0",
"@types/node": "^22.7.7",
"jest-mock-extended": "2.0.4",
"supertest": "^7.0.0",
"sync-request-curl": "^3.0.0",
"ts-node": "^10.9.2",
"tsx": "^4.19.1",
"typescript": "^5.6.3"
"typescript": "^5.6.3",
"vitest": "^2.1.4",
"vitest-mock-extended": "^2.0.2"
}
}
Loading

0 comments on commit c3b29bc

Please sign in to comment.