name: Setup Rust description: Setup Rust inputs: target: description: Toolchain target triple required: false save-cache: description: Whether or not to save the rust cache required: false default: 'false' restore-cache: description: Whether or not to restore the rust cache required: false default: 'true' runs: using: composite steps: - name: Install Rust Stable uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a with: toolchain: stable targets: ${{ inputs.target }} components: clippy, rustfmt - name: Install Rust Nightly uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a with: toolchain: nightly targets: ${{ inputs.target }} components: clippy, rustfmt - name: Cache Rust if: ${{ inputs.restore-cache == 'true' }} uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 with: key: ${{ inputs.target }} save-if: ${{ inputs.save-cache }} shared-key: stable-cache - name: Prepare Cargo shell: bash run: echo '{}' | npx -y mustache - .cargo/config.toml.mustache .cargo/config.toml - name: Prisma Cache id: prisma-cache uses: actions/cache/restore@v4 with: key: prisma-v1-${{ runner.os }}-${{ hashFiles('./packages/core/prisma/*', './Cargo.*') }} path: packages/prisma/src/**/*.rs - name: Generate Prisma if: ${{ steps.prisma-cache.outputs.cache-hit != 'true' }} shell: bash run: | set -euxo pipefail npx -y prisma generate --schema packages/core/prisma/schema.prisma if ! [ -f packages/prisma/src/prisma/mod.rs ]; then echo "prisma generation failed" >&2 exit 1 fi npx -y prisma migrate dev --schema packages/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 'empty migration' \ | wc -l \ | awk '{$1=$1};1' )" if [ "$_new_migrations" -gt 0 ]; then echo "::error file=packages/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/"*) exit 1 ;; esac fi - name: Save Prisma Cache id: prisma-cache-save if: ${{ steps.prisma-cache.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: packages/prisma/src/**/*.rs