mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-22 15:40:07 -04:00
* Ensure prisma generation works before continuing CI - Add script that list all dependencies with multiple version in Cargo.lock * Ensure CI runs when custom actions are modified * Rever windows change in hopes that it fixes prisma generation * Fix prisma generation check in CI * Update deps * Replace prisma-client-rust-cli with oficial prisma cli to fix windows model generation - Revert back to windows-rs implementation of get_inode in file-path-helper - Adjust Github CI to use oficial prisma cli - Update scripts dependencies - Fix some new rust warnings due to it trying to compile OS specific code on all plataforms * Fix windows-rs impl for get_inode_windows in file-path-helper * More fixes to windows-rs impl for get_inode_windows in file-path-helper * More fixes to windows-rs impl for get_inode_windows in file-path-helper * More fixes to windows-rs impl for get_inode_windows in file-path-helper * More fixes to windows-rs impl for get_inode_windows in file-path-helper * More fixes to windows-rs impl for get_inode_windows in file-path-helper * Import windows constant intead of hardcoding its value * Fix check for prisma files in setup-rust * Autoformat * Fix iOS and Android targets in watcher --------- Co-authored-by: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com>
85 lines
3.0 KiB
YAML
85 lines
3.0 KiB
YAML
name: Setup Rust and Prisma
|
|
description: Setup Rust and Prisma
|
|
inputs:
|
|
target:
|
|
description: toolchain target triple
|
|
required: false
|
|
save-cache:
|
|
description: Whether to save the Rust cache
|
|
required: false
|
|
default: 'false'
|
|
restore-cache:
|
|
description: Whether to restore the Rust cache
|
|
required: false
|
|
default: 'true'
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Install Rust
|
|
id: toolchain
|
|
uses: IronCoreLabs/rust-toolchain@v1
|
|
with:
|
|
target: ${{ inputs.target }}
|
|
components: clippy, rustfmt
|
|
|
|
- name: Cache Rust Dependencies
|
|
if: ${{ inputs.restore-cache == 'true' }}
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: ${{ inputs.target }}
|
|
save-if: ${{ inputs.save-cache }}
|
|
shared-key: stable-cache
|
|
|
|
- name: Cargo config.toml
|
|
shell: bash
|
|
run: echo '{}' | npx -y mustache - .cargo/config.toml.mustache .cargo/config.toml
|
|
|
|
- name: Restore cached Prisma codegen
|
|
id: cache-prisma-restore
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
key: prisma-1-${{ runner.os }}-${{ hashFiles('./core/prisma/*', './crates/sync-generator/*', './Cargo.*') }}
|
|
path: crates/prisma/src/**/*.rs
|
|
|
|
- name: Generate Prisma client
|
|
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }}
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
npx -y prisma generate --schema core/prisma/schema.prisma
|
|
|
|
if ! {
|
|
[ -f crates/prisma/src/prisma/mod.rs ] && \
|
|
[ -f crates/prisma/src/prisma_sync/mod.rs ]
|
|
}; then
|
|
echo "Prisma generation failed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Check if a new migration should be created due to changes in the schema
|
|
npx -y prisma migrate dev --schema core/prisma/schema.prisma -n test --create-only --skip-generate
|
|
_new_migrations="$(
|
|
git ls-files --others --exclude-standard \
|
|
| { grep '^prisma/migrations/' || true; } \
|
|
| xargs sh -euxc '[ "$#" -lt 2 ] || grep -L "$@" || true' sh 'This is an empty migration' \
|
|
| wc -l \
|
|
| awk '{$1=$1};1'
|
|
)"
|
|
if [ "$_new_migrations" -gt 0 ]; then
|
|
echo "::error file=core/prisma/schema.prisma,title=Missing migration::New migration should be generated due to changes in prisma schema"
|
|
case "$GITHUB_REF" in
|
|
"refs/heads/main" | "refs/heads/gh-readonly-queue/main/"* | "refs/tags/"*)
|
|
# Fail action if we are on main, merge queue or a release tag, to avoid releasing the app with a broken db
|
|
exit 1
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
- name: Save Prisma codegen
|
|
id: cache-prisma-save
|
|
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' && (github.ref == 'refs/heads/main' || inputs.save-cache == 'true') }}
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
key: ${{ steps.cache-prisma-restore.outputs.cache-primary-key }}
|
|
path: crates/prisma/src/**/*.rs
|