Skip to content

Commit

Permalink
Merge branch 'main' into bug/tolerant-tufilm-parser
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/api/tumdev/campus_backend.pb.go
#	server/backend/migration/migration.go
  • Loading branch information
CommanderStorm committed Oct 25, 2023
2 parents 7a0ca0b + e2fa378 commit 751c6a9
Show file tree
Hide file tree
Showing 66 changed files with 2,163 additions and 2,815 deletions.
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@v4
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
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ 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.
Expand Down
8 changes: 0 additions & 8 deletions deployment/charts/backend/templates/sql-init-config.yaml

This file was deleted.

1 change: 0 additions & 1 deletion deployment/charts/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ mariadb:
storageClass: local-path
volumePermissions:
enabled: true
initdbScriptsConfigMap: sql-init


backend:
Expand Down
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 751c6a9

Please sign in to comment.