mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-04 11:03:27 +00:00
CI now checks if a migration is missing (#2295)
* CI now checks if a migration is missing - Fail CI on main and tag releases if a new migration should be created due to changes in the db schema - Add error msg to schema.prisma file if a migration is not created to reflect changes made to db schema, but do NOT fail action * Change schema to test CI changes * Add debug to prisma generate CI script * Removem prisma cache to test * Fix grep for migrations * Revert changes made for testing * Only cache prisma data on main or cache-factory
This commit is contained in:
parent
8e14bc68bc
commit
11555c583a
16
.github/actions/setup-rust/action.yaml
vendored
16
.github/actions/setup-rust/action.yaml
vendored
|
@ -67,11 +67,23 @@ runs:
|
||||||
working-directory: core
|
working-directory: core
|
||||||
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }}
|
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cargo prisma generate
|
run: |
|
||||||
|
set -euxo pipefail
|
||||||
|
cargo prisma generate
|
||||||
|
|
||||||
|
# Check if a new migration should be created due to changes in the schema
|
||||||
|
cargo prisma migrate dev -n test --create-only --skip-generate
|
||||||
|
if git ls-files --others --exclude-standard | grep -q '^prisma/migrations/'; then
|
||||||
|
echo "::error file=core/prisma/schema.prisma,title=Missing migration::New migration should be generated due to changes in prisma schema"
|
||||||
|
# Fail action if we are on main or a release tag, to avoid releasing a app with broken db
|
||||||
|
if [ "$GITHUB_REF" == "refs/heads/main" ] || [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Save Prisma codegen
|
- name: Save Prisma codegen
|
||||||
id: cache-prisma-save
|
id: cache-prisma-save
|
||||||
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }}
|
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' && (github.ref == 'refs/heads/main' || inputs.save-cache == 'true') }}
|
||||||
uses: actions/cache/save@v4
|
uses: actions/cache/save@v4
|
||||||
with:
|
with:
|
||||||
key: ${{ steps.cache-prisma-restore.outputs.cache-primary-key }}
|
key: ${{ steps.cache-prisma-restore.outputs.cache-primary-key }}
|
||||||
|
|
Loading…
Reference in a new issue