chore:full migrations test #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | |
Found the following differences in the sql schema: | |
<details> | |
<summary>To get from local migrations to auto migration state one would need to</summary> | |
```sql | |
${{ steps.diff_migrations.outputs.local_to_auto }} | |
``` | |
</details> | |
<details> | |
<summary>To get from auto migrations to local migration state one would need to</summary> | |
```sql | |
${{ steps.diff_migrations.outputs.auto_to_local }} | |
``` | |
</details> | |
edit-mode: replace | |
reactions: eyes |