diff --git a/.github/actions/setup-pnpm/action.yml b/.github/actions/setup-pnpm/action.yml index 2f9630a65..d2a7ce373 100644 --- a/.github/actions/setup-pnpm/action.yml +++ b/.github/actions/setup-pnpm/action.yml @@ -8,6 +8,10 @@ inputs: runs: using: 'composite' steps: + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install pnpm uses: pnpm/action-setup@v3 with: diff --git a/.github/actions/setup-rust/action.yaml b/.github/actions/setup-rust/action.yaml index 3d59ef3ec..a4aa92a09 100644 --- a/.github/actions/setup-rust/action.yaml +++ b/.github/actions/setup-rust/action.yaml @@ -73,12 +73,21 @@ runs: # 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 + _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 or a release tag, to avoid releasing an app with a broken db + exit 1 + ;; + esac fi - name: Save Prisma codegen diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f632fbdc4..6a3827d74 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -169,6 +169,27 @@ Once that has completed, run `xcode-select --install` in the terminal to install Also ensure that Rosetta is installed, as a few of our dependencies require it. You can install Rosetta with `softwareupdate --install-rosetta --agree-to-license`. +#### `ModuleNotFoundError: No module named 'distutils'` + +If you run into this issue, or some other error involving `node-gyp`: +``` +File "pnpm@8.15.6/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py", line 42, in + import gyp # noqa: E402 + ^^^^^^^^^^ +File "pnpm@8.15.6/node_modules/pnpm/dist/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in + import gyp.input +File "pnpm@8.15.6/node_modules/pnpm/dist/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in + from distutils.version import StrictVersion +``` + +Some pnpm dependencies require compilation steps that depend on Python to execute. +However, a recent change in Python version 3.12 broke the utility used to bridge these compilation steps to node/npm/pnpm. + +Currently, there is no definitive solution to this issue due to it being fairly new. But there are two workarounds: + +1. Downgrade your system Python version to 3.11 or lower. +2. Update pnpm to version v9.0.0-rc.0 (Release Candidate, not fully stable yet). + ### Credits This CONTRIBUTING.md file was inspired by the [github/docs CONTRIBUTING.md](https://github.com/github/docs/blob/main/CONTRIBUTING.md) file, and we extend our gratitude to the original author.