Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signup/Login Feature + Integration Tests + CI Pipeline setup #14

Merged
merged 22 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4ea0a7e
Preliminary register function
Plebbaroni Nov 7, 2024
7333115
📜integration test setup
Plebbaroni Nov 9, 2024
be16616
📖added test_url to readme.md
Plebbaroni Nov 9, 2024
cf003e6
🐜fixed bug where tests were being run on prod db instead of local db
Plebbaroni Nov 9, 2024
3736ce5
📖added info about .env.test to README
Plebbaroni Nov 9, 2024
cbc1d48
🛁removed some redundant code/added comments
Plebbaroni Nov 9, 2024
346143e
🧪CI pipeline setup
Plebbaroni Nov 10, 2024
a384f41
🧪CI pipeline setup
Plebbaroni Nov 10, 2024
7cc4344
🧪CI pipeline setup
Plebbaroni Nov 10, 2024
8c19d40
🧪CI pipeline setup
Plebbaroni Nov 10, 2024
95a0b68
🧪CI pipeline setup
Plebbaroni Nov 10, 2024
bb2880e
🧪CI pipeline setup
Plebbaroni Nov 10, 2024
bf412b2
🧪added tests to repo and removed unused dependencies
Plebbaroni Nov 11, 2024
6e39975
🧪added tests to repo and removed unused dependencies
Plebbaroni Nov 11, 2024
984a176
🧪added tests to repo and fiddled with the workflows files
Plebbaroni Nov 12, 2024
ab00ff6
🧪added tests to repo and fiddled with the workflows files
Plebbaroni Nov 12, 2024
4be65ea
🧪added tests to repo and fiddled with the workflows files
Plebbaroni Nov 12, 2024
febc361
🧪added tests to repo and fiddled with the workflows files
Plebbaroni Nov 12, 2024
3150f3b
🧪added tests to repo and fiddled with the workflows files
Plebbaroni Nov 12, 2024
0ed7a09
🧪rename test
Plebbaroni Nov 12, 2024
dfe8446
📖updated the readme to include information on running tests locally.
Plebbaroni Nov 12, 2024
6c664fb
Merge branch 'main' into feature/login
lachlanshoesmith Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading