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

Fix/backend/emailing bugs #91

Merged
merged 61 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
355a080
chore: Add MongoDB service for testing and seed database before runni…
waveyboym Jun 25, 2024
bf3708e
Android compatibility done
KamogeloMoeketse Jun 26, 2024
eaf8aa2
refresh functionality for my bookings
KamogeloMoeketse Jun 26, 2024
0b30436
Update README.md
waveyboym Jun 26, 2024
6414a23
Update index.mdx
waveyboym Jun 26, 2024
cb16236
Email formatting fixed and related functions refactored
Rethakgetse-Manaka Jun 26, 2024
b020a70
chore: Added logic for testing with locally ready database instead of…
waveyboym Jun 26, 2024
0957197
Validation implemented on one function
Rethakgetse-Manaka Jun 26, 2024
b3ea34c
Validation done
Rethakgetse-Manaka Jun 26, 2024
4e37a6a
chore: Add /benchmarks to .gitignore
waveyboym Jun 26, 2024
67203b2
Linting errors should be fixed
Rethakgetse-Manaka Jun 26, 2024
934bb31
All errors should be fixed
Rethakgetse-Manaka Jun 26, 2024
457c141
chore: Install mongosh for MongoDB integration testing
waveyboym Jun 26, 2024
3b9e172
chore: Create MongoDB user for testing with environment variables
waveyboym Jun 26, 2024
9310c2c
chore: Update MongoDB connection string for testing environment
waveyboym Jun 26, 2024
0d467ab
chore: Update MongoDB connection string for testing environment by re…
waveyboym Jun 26, 2024
c76932a
Merge pull request #92 from COS301-SE-2024/fix/backend/mongo-test-db
waveyboym Jun 26, 2024
edaf973
Merge pull request #100 from COS301-SE-2024/feat/backend/benchmarking
waveyboym Jun 26, 2024
602613d
Merge pull request #101 from COS301-SE-2024/feat/documentation/adding…
waveyboym Jun 26, 2024
1ff966e
chore: Update occupi documentation theme configuration
waveyboym Jun 26, 2024
f5f54df
Added loaders
KamogeloMoeketse Jun 27, 2024
206c3ea
Merge pull request #104 from COS301-SE-2024/fix/mobile/styling
KamogeloMoeketse Jun 27, 2024
08c7cc6
chore: Update Dockerfile to include environment flag for building the…
waveyboym Jun 27, 2024
ee6ac9a
chore: Update actions to watch yaml config instead of env
waveyboym Jun 27, 2024
67f719d
chore: added gitignore for secret yaml files
waveyboym Jun 27, 2024
90e3ee5
refactor: migrated from using plain .env files to using viper managed…
waveyboym Jun 27, 2024
f7a6138
chore: Fix typo in decrypt default variables step
waveyboym Jun 27, 2024
1619cb5
refactor: Migrate from using plain .env files to using viper managed …
waveyboym Jun 27, 2024
ace60cb
chore: Update SMTP configuration variables to use uppercase naming co…
waveyboym Jun 27, 2024
7471b8e
Merge pull request #105 from COS301-SE-2024/fix/backend/reorganizing-…
waveyboym Jun 27, 2024
1344309
chore: Update Dockerfile to include environment flag for building the…
waveyboym Jun 27, 2024
1d45b27
chore: Update environment variable check for devdeployed in main.go
waveyboym Jun 27, 2024
ddffb98
chore: Update cookie expiration time to use time.Until() instead of i…
waveyboym Jun 27, 2024
01d419f
Merge pull request #108 from COS301-SE-2024/fix/backend/token-expiry-…
waveyboym Jun 27, 2024
d39e5ca
Validation has changed a lot need to update docs heavy
Rethakgetse-Manaka Jun 28, 2024
e4039fd
"Utils unit tests updated"
Rethakgetse-Manaka Jun 28, 2024
69402f1
"Updated unit tests"
Rethakgetse-Manaka Jun 28, 2024
45c6acd
"Commented out merge conflicts"
Rethakgetse-Manaka Jun 28, 2024
e989af3
Updated api-handlers
Rethakgetse-Manaka Jun 28, 2024
e4978a8
Email formatting fixed and related functions refactored
Rethakgetse-Manaka Jun 26, 2024
f8193ee
Validation implemented on one function
Rethakgetse-Manaka Jun 26, 2024
8637efe
Validation done
Rethakgetse-Manaka Jun 26, 2024
8c16a4b
Linting errors should be fixed
Rethakgetse-Manaka Jun 26, 2024
4998ad8
All errors should be fixed
Rethakgetse-Manaka Jun 26, 2024
f5f5f41
Validation has changed a lot need to update docs heavy
Rethakgetse-Manaka Jun 28, 2024
a2afee9
"Utils unit tests updated"
Rethakgetse-Manaka Jun 28, 2024
eff2e9d
"Updated unit tests"
Rethakgetse-Manaka Jun 28, 2024
f333c8b
"Commented out merge conflicts"
Rethakgetse-Manaka Jun 28, 2024
9480f75
Updated api-handlers
Rethakgetse-Manaka Jun 28, 2024
e30fa03
Merge getting fixed
Rethakgetse-Manaka Jun 28, 2024
7b1fdbe
Type checked unmarshal
Rethakgetse-Manaka Jun 28, 2024
ed5ccf3
"Need to integrate tests"
Rethakgetse-Manaka Jun 28, 2024
ae08b4c
All test pass now just need to rewrite integration test
Rethakgetse-Manaka Jun 28, 2024
7dac7fd
Working on integration tests
Rethakgetse-Manaka Jun 28, 2024
9c3c8f6
"Done integration testing"
Rethakgetse-Manaka Jun 28, 2024
3b51dfb
"Fixed my errors"
Rethakgetse-Manaka Jun 28, 2024
1aeeb93
"Need to fix linting. Lines aren't identical"
Rethakgetse-Manaka Jun 28, 2024
568e4a2
"Created a setup test function"
Rethakgetse-Manaka Jun 29, 2024
5559902
"Duplicates removed"
Rethakgetse-Manaka Jun 29, 2024
53852e3
"Can't remove certain test cases because they are testing different t…
Rethakgetse-Manaka Jun 29, 2024
3bb8b0b
"Duplicates should be removed"
Rethakgetse-Manaka Jun 29, 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
67 changes: 7 additions & 60 deletions .github/workflows/deploy-golang-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,7 @@ defaults:
working-directory: occupi-backend

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Install golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

- name: Run golangci-lint
run: |
golangci-lint run

test:
needs: lint
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Decrypt env variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 .env.gpg > .env

- name: Decrypt key file
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 key.pem.gpg > key.pem

- name: Decrypt cert file
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 cert.pem.gpg > cert.pem

- name: Run tests
run: |
go test -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware ./tests/... -coverprofile=coverage.out

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

build-test:
needs: test
name: Build
runs-on: ubuntu-latest

Expand Down Expand Up @@ -115,10 +58,14 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Decrypt env variables
- name: Decrypt default variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 configs/config.yaml.gpg > configs/config.yaml

- name: Decrypt test variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 .dev.env.gpg > .dev.env

echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 configs/dev.deployed.yaml.gpg > configs/dev.deployed.yaml
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
Expand Down
67 changes: 7 additions & 60 deletions .github/workflows/deploy-golang-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,64 +12,7 @@ defaults:
working-directory: occupi-backend

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Install golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

- name: Run golangci-lint
run: |
golangci-lint run

test:
needs: lint
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Decrypt env variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 .env.gpg > .env

- name: Decrypt key file
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 key.pem.gpg > key.pem

- name: Decrypt cert file
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 cert.pem.gpg > cert.pem

- name: Run tests
run: |
go test -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware ./tests/... -coverprofile=coverage.out

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

build:
needs: test
name: Build
runs-on: ubuntu-latest

Expand Down Expand Up @@ -107,10 +50,14 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Decrypt env variables
- name: Decrypt default variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 configs/config.yaml.gpg > configs/config.yaml

- name: Decrypt test variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 .prod.env.gpg > .prod.env

echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 configs/prod.yaml.gpg > configs/prod.yaml
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
Expand Down
60 changes: 51 additions & 9 deletions .github/workflows/lint-test-build-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,69 @@ jobs:
name: Test
runs-on: ubuntu-latest

services:
mongo:
image: mongo:latest
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.adminCommand({ping: 1})'"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install mongosh
run: |
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo apt-get update
sudo apt-get install -y mongodb-mongosh


- name: Wait for MongoDB to be ready
run: |
for i in {1..30}; do
if mongosh --eval 'db.adminCommand({ping: 1})' ${{ secrets.MONGO_DB_TEST_URL }}; then
echo "MongoDB is up"
break
fi
echo "Waiting for MongoDB to be ready..."
sleep 2
done

- name: Create MongoDB User
env:
MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGO_DB_TEST_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGO_DB_TEST_PASSWORD }}
MONGO_INITDB_DATABASE: ${{ secrets.MONGO_DB_TEST_DB }}
run: |
mongosh ${{ secrets.MONGO_DB_TEST_URL }}/admin --eval "
db.createUser({
user: '${MONGO_INITDB_ROOT_USERNAME}',
pwd: '${MONGO_INITDB_ROOT_PASSWORD}',
roles: [
{ role: 'readWrite', db: '${MONGO_INITDB_DATABASE}' }
]
});
"

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Decrypt env variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 .env.gpg > .env

- name: Decrypt key file
- name: Decrypt default variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 key.pem.gpg > key.pem
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 configs/config.yaml.gpg > configs/config.yaml

- name: Decrypt cert file
- name: Decrypt test variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 cert.pem.gpg > cert.pem

echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 configs/test.yaml.gpg > configs/test.yaml
- name: Run tests
run: |
go test -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware ./tests/... -coverprofile=coverage.out
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
/benchmarks
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
![Codecov](https://img.shields.io/codecov/c/github/COS301-SE-2024/occupi?style=flat-square)
![GitHub License](https://img.shields.io/github/license/COS301-SE-2024/occupi?style=flat-square)
![GitHub repo size](https://img.shields.io/github/repo-size/COS301-SE-2024/occupi?style=flat-square)
![Docs Website](https://img.shields.io/website?url=https%3A%2F%2Fdocs.occupi.tech&style=flat-square)
![Uptime Robot ratio (7 days)](https://img.shields.io/uptimerobot/ratio/7/m797164574-0d7a208e3fca09e737a9619f?style=flat-square)
![Uptime Robot ratio (7 days)](https://img.shields.io/uptimerobot/ratio/7/m797164576-1e9cec32af1ac1e298136819?style=flat-square)
![Uptime Robot ratio (7 days)](https://img.shields.io/uptimerobot/ratio/7/m797164567-64429e97f6d650162e9354dd?style=flat-square)
![GitHub Repo stars](https://img.shields.io/github/stars/COS301-SE-2024/occupi?style=flat-square)
[![codecov](https://codecov.io/gh/COS301-SE-2024/occupi/graph/badge.svg?token=71QPCD9NNP)](https://codecov.io/gh/COS301-SE-2024/occupi)
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/COS301-SE-2024/occupi?style=flat-square)
Expand Down
Loading
Loading