Skip to content

Commit

Permalink
Merge branch 'main' into feature/alarm-cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm authored Jan 2, 2024
2 parents 6c30fbf + 3b4cac0 commit 99d519a
Show file tree
Hide file tree
Showing 100 changed files with 4,279 additions and 3,377 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/client_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:
paths:
- 'server/api/tumdev/campus_backend.proto'

workflow_dispatch:

jobs:
deploy:
runs-on: macos-latest

steps:
- name: Fetch Changes
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0 # Checkout everything to get access to the tags
ref: main
Expand All @@ -36,7 +38,7 @@ jobs:
echo "BRANCH_NAME=chore/update-protos-to-\$LATEST_TAG" >> $GITHUB_ENV
- name: Clone Repository
run: git clone --depth=1 --branch=development https://runner:${{ secrets.CAMPUS_FLUTTER_TOKEN }}@github.com/${{ env.REPOSITORY }} ${{ env.FOLDER }}
run: git clone --depth=1 --branch=main https://runner:${{ secrets.CAMPUS_FLUTTER_TOKEN }}@github.com/${{ env.REPOSITORY }} ${{ env.FOLDER }}

- name: Update Proto Files
run: |
Expand Down Expand Up @@ -74,7 +76,7 @@ jobs:
--body "" \
--title "Chore: Update Protos to ${{ env.LATEST_TAG }}" \
--head "${{ env.BRANCH_NAME }}" \
--base "development"
--base "main"
- name: Error Message
if: steps.commit.outcome != 'success'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
Expand All @@ -31,6 +31,6 @@ jobs:
- run: bash server/api/installBuf.bash
- name: pre-commit
uses: pre-commit/[email protected]
- uses: ls-lint/action@v2.0.1
- uses: ls-lint/action@v2.2.2
with:
config: .ls-lint.yaml
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache-dependency-path: |
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/test_migration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Migration Test
on:
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
jobs:
test_migrations:
runs-on: ubuntu-latest
services:
auto_mariadb:
image: bitnami/mariadb:latest
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: super_secret_passw0rd
MARIADB_DATABASE: campus_db
manual_mariadb:
image: bitnami/mariadb:latest
ports:
- 3300:3306
env:
MARIADB_ROOT_PASSWORD: super_secret_passw0rd
MARIADB_DATABASE: campus_db
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache-dependency-path: |
server/go.sum
- name: run manual migrations
run: go run main.go
working-directory: ./server
env:
CI_EXIT_AFTER_MIGRATION: "true"
CI_AUTO_MIGRATION: "false"
DB_DSN: root:super_secret_passw0rd@tcp(localhost:3306)/campus_db?charset=utf8mb4&parseTime=True&loc=Local
ENVIRONMENT: dev
- name: run auto migrations
run: go run main.go
working-directory: ./server
env:
CI_EXIT_AFTER_MIGRATION: "true"
CI_AUTO_MIGRATION: "true"
DB_DSN: root:super_secret_passw0rd@tcp(localhost:3300)/campus_db?charset=utf8mb4&parseTime=True&loc=Local
ENVIRONMENT: dev
- uses: ariga/setup-atlas@master
- name: export diff the migrations
id: diff_migrations
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) &&
echo "local_to_auto<<$EOF" >> $GITHUB_OUTPUT &&
atlas schema diff --from "maria://root:super_secret_passw0rd@localhost:3306/campus_db" --to "maria://root:super_secret_passw0rd@localhost:3300/campus_db" --format '{{ sql . " " }}' >> $GITHUB_OUTPUT &&
echo "$EOF" >> $GITHUB_OUTPUT
echo "auto_to_local<<$EOF" >> $GITHUB_OUTPUT &&
atlas schema diff --from "maria://root:super_secret_passw0rd@localhost:3306/campus_db" --to "maria://root:super_secret_passw0rd@localhost:3300/campus_db" --format '{{ sql . " " }}' >> $GITHUB_OUTPUT &&
echo "$EOF" >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: "${{ github.event.number }}"
body-includes: Found the following differences in the sql schema
comment-author: github-actions[bot]
- name: Create comment
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: "${{ github.event.number }}"
comment-id: "${{ steps.fc.outputs.comment-id }}"
body: |
:eyes: Found the following differences in the sql schema:
<details>
<summary>Needed get from <b>local</b> to <b>auto</b> migration state</summary>
```sql
${{ steps.diff_migrations.outputs.local_to_auto }}
```
</details>
<details>
<summary>Needed from <b>auto</b> to <b>local</b> migration state</summary>
```sql
${{ steps.diff_migrations.outputs.auto_to_local }}
```
</details>
edit-mode: replace
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,13 @@ The docker compose will start the server and a mariadb instance.
The server will be available at `localhost:50051` and the mariadb instance at `localhost:3306`.
Additionally, docker creates the volume `campus-db-data` to persist the data of the mariadb instances.

### Setting up the Database
The mariadb schema can be installed by executing the following command inside the mariadb container:
```bash
mysql --user=root --password=secret_root_password campus_db < /entrypoint/schema.sql
```

### Environment Variables
The following environment variables need to be set for the server to work properly:
* [REQUIRED] `DB_NAME`: The name of the database to use.
* [REQUIRED] `DB_ROOT_PASSWORD`: The password of the root user.
* [OPTIONAL] `DB_PORT`: The port of the database server. Defaults to `3306`.
* [OPTIONAL] `SENTRY_DSN`: The Sentry [Data Source Name](https://sentry-docs-git-patch-1.sentry.dev/product/sentry-basics/dsn-explainer/) for reporting issues and crashes.
* [OPTIONAL] `OMDB_API_KEY`: The key to get more information for tu-film movies from [omdbapi](https://omdbapi.com/). See [omdbapi](https://omdbapi.com/apikey.aspx) for a key.
* **[iOS Push Notification Service [OPTIONAL]](#ios-push-notifications-service)**:
* [REQUIRED] `APNS_KEY_ID`: The key ID of the APNs key => APNs Key needs to be downloaded from the Apple Developer Portal the name of the file also contains the key ID.
* [REQUIRED] `APNS_TEAM_ID`: The team ID of the iOS app can be found in AppStoreConnect.
Expand Down
8 changes: 4 additions & 4 deletions client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20231009133538-1a7f37e5f27c
github.com/sirupsen/logrus v1.9.3
google.golang.org/grpc v1.58.2
google.golang.org/grpc v1.60.1
)

require (
Expand All @@ -14,8 +14,8 @@ require (
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
20 changes: 10 additions & 10 deletions client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ github.com/TUM-Dev/Campus-Backend/server v0.0.0-20231009133538-1a7f37e5f27c/go.m
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
Expand All @@ -29,14 +29,14 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA=
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4=
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI=
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0=
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk=
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU=
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY=
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
2 changes: 1 addition & 1 deletion deployment/charts/backend/templates/backend-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ spec:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storage: 3Gi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
app.kubernetes.io/part-of: tum-campus-app
app.kubernetes.io/name: backend-v1
spec:
priorityClassName: tca-backend
volumes:
- name: legacybackend-config
secret:
Expand Down
29 changes: 27 additions & 2 deletions deployment/charts/backend/templates/deployments/backend-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
app.kubernetes.io/part-of: tum-campus-app
app.kubernetes.io/name: backend-v2
spec:
priorityClassName: tca-backend
volumes:
- name: storage-vol
persistentVolumeClaim:
Expand Down Expand Up @@ -61,6 +62,26 @@ spec:
secretKeyRef:
name: backend-api-keys
key: CAMPUS_API_TOKEN
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: backend-api-keys
key: SMTP_PASSWORD
- name: SMTP_URL
valueFrom:
secretKeyRef:
name: backend-api-keys
key: SMTP_URL
- name: SMTP_USERNAME
valueFrom:
secretKeyRef:
name: backend-api-keys
key: SMTP_USERNAME
- name: SMTP_PORT
valueFrom:
secretKeyRef:
name: backend-api-keys
key: SMTP_PORT
- name: DB_DSN
value: "{{ $db.username }}:{{ $db.password }}@tcp(tca-backend-mariadb.{{ $.Values.namespace }}.svc.cluster.local:3306)/{{ $db.database }}?charset=utf8mb4&parseTime=True&loc=Local"
- name: APNS_KEY_ID
Expand Down Expand Up @@ -91,8 +112,8 @@ spec:
readOnlyRootFilesystem: true
resources:
requests:
cpu: 1000m
memory: 100Mi
cpu: 100m
memory: 50Mi
limits:
memory: 500Mi
livenessProbe:
Expand Down Expand Up @@ -158,6 +179,10 @@ data:
apns_auth_key.p8: {{ $.Values.backend.apns.auth_key }}
APNS_KEY_ID: {{ $.Values.backend.apns.key_id | b64enc }}
APNS_TEAM_ID: {{ $.Values.backend.apns.team_id | b64enc }}
SMTP_PASSWORD: {{ $.Values.backend.smtp.password | b64enc }}
SMTP_URL: {{ $.Values.backend.smtp.url | b64enc }}
SMTP_USERNAME: {{ $.Values.backend.smtp.username | b64enc }}
SMTP_PORT: {{ $.Values.backend.smtp.port | b64enc }}
---
apiVersion: v1
kind: ConfigMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app.kubernetes.io/part-of: tum-campus-app
namespace: {{ $.Values.namespace }}
spec:
commonName: api-test-v1.tum.app
commonName: app.tum.de
secretName: app.tum.de
issuerRef:
name: letsencrypt-production
Expand Down
7 changes: 7 additions & 0 deletions deployment/charts/backend/templates/priority-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: tca-backend
value: 1000
globalDefault: false
description: This priority class should be used for the tca-backend.
8 changes: 0 additions & 8 deletions deployment/charts/backend/templates/sql-init-config.yaml

This file was deleted.

7 changes: 5 additions & 2 deletions deployment/charts/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ namespace: tca-backend
tag: latest
urls:
v1:
- api-test-v1.tum.app
- app.tum.app
- app.tum.de
- www.app.tum.de
Expand Down Expand Up @@ -38,7 +37,6 @@ mariadb:
storageClass: local-path
volumePermissions:
enabled: true
initdbScriptsConfigMap: sql-init


backend:
Expand All @@ -50,6 +48,11 @@ backend:
auth_key: changeme-changeme-changeme
key_id: changeme-changeme-changeme
team_id: changeme-changeme-changeme
smtp:
password: change-me
url: smtp.gmail.com
username: change-me
port: "465"
legacy:
config: changeme-changeme-changeme
imagepullsecret: changeme-changeme-changeme
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ services:
- MARIADB_DATABASE=${DB_NAME}
volumes:
- campus-db-data:/bitnami/mariadb
- ./deployment/charts/backend/files/source-schema.sql:/docker-entrypoint-startdb.d/schema.sql
healthcheck:
test: ['CMD', '/opt/bitnami/scripts/mariadb/healthcheck.sh']
interval: 15s
Expand Down
Loading

0 comments on commit 99d519a

Please sign in to comment.