Skip to content

Commit dae8ad9

Browse files
kristof-siketclaude
andcommitted
fix: install where the lockfile is, and test a repository with a prisma.config.ts end to end
A config file above the working directory was found, but the lockfile was only looked for in the working directory, so the install was skipped. A detected install now runs in the nearest folder with a lockfile, up to the repository root. The install-command input still runs in the working directory. The end-to-end job for a repository with no Composer module now runs for two apps. The new one, e2e/single-app-config, has a prisma.config.ts and its own prisma in its lockfile (package-lock.json, 4,844 generated lines). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 5fcd1c9 commit dae8ad9

13 files changed

Lines changed: 4954 additions & 36 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,28 +158,39 @@ jobs:
158158
run: bun scripts/sweep.ts
159159

160160
e2e-single-app:
161-
name: The action deploys a repository with no Composer module
161+
name: The action deploys a repository with no Composer module, ${{ matrix.name }}
162162
if: >-
163163
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) &&
164164
(github.event_name != 'push' || github.ref == 'refs/heads/main')
165165
runs-on: ubuntu-latest
166166
timeout-minutes: 30
167+
strategy:
168+
fail-fast: false
169+
matrix:
170+
include:
171+
- name: and no config file
172+
app: single-app
173+
id: plain
174+
# The action installs first, then runs the app's own prisma from its lockfile.
175+
- name: with a prisma.config.ts
176+
app: single-app-config
177+
id: config
167178
permissions:
168179
contents: read
169180
# The sweep reads whether the run that made a Project has finished.
170181
actions: read
171182
env:
172183
# The action cannot destroy a deploy with no Composer module, so each run
173184
# deploys into a Project of its own and deletes that Project afterwards.
174-
PROJECT: cloud-deploy-action-e2e-single-${{ github.run_id }}-${{ github.run_attempt }}
185+
PROJECT: cloud-deploy-action-e2e-single-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.id }}
175186
steps:
176187
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
177188
# No Bun: the action runs the CLI under Node.js in this mode.
178189
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
179190
with:
180191
node-version: 24
181192
- name: Give the app a body only this run has
182-
run: printf '{"project":"%s"}' "$PROJECT" > e2e/single-app/run.json
193+
run: printf '{"project":"%s"}' "$PROJECT" > "e2e/${{ matrix.app }}/run.json"
183194
# No environment input: a pull request run deploys to an environment named
184195
# after its branch, and a run on main deploys to production.
185196
- name: Deploy with the action
@@ -191,7 +202,7 @@ jobs:
191202
# The deploy creates the Project, which needs a region. Same as e2e/app.
192203
PRISMA_REGION: us-east-1
193204
with:
194-
working-directory: e2e/single-app
205+
working-directory: e2e/${{ matrix.app }}
195206
name: ${{ env.PROJECT }}
196207
- name: Check the action's outputs and the deployed service
197208
env:

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ The Prisma CLI does the rest. It works out how to build and start the Service, b
103103

104104
- The action runs no install and no build of its own, and does not use the `install-command` and `build-command` inputs. A repository with a `prisma.config.ts` is the one exception, described below.
105105
- The `prisma-version` input sets the CLI version. Set it to an exact version. Empty runs the newest release and logs a warning, because no lockfile pins the CLI in this mode.
106-
- **A repository with a `prisma.config.ts` is installed first.** The CLI reads that file before it runs, and the file imports the repository's own packages. So the action runs the install command (`install-command`, else from the lockfile: npm, bun, pnpm or yarn), and the CLI then installs again as part of its build. When the install gives the repository its own `prisma` at 8.0.0-rc.37 or later and `prisma-version` is empty, the action runs that CLI (`npx --no-install prisma deploy`), because a config file must be read by the CLI from the same install.
106+
- **A repository with a `prisma.config.ts` is installed first.** The CLI reads that file before it runs, and the file imports the repository's own packages. So the action runs the install command (`install-command`, else from the lockfile: npm, bun, pnpm or yarn), and the CLI then installs again as part of its build. A detected install runs in the nearest folder that has a lockfile, from the working directory up to the repository root, because the CLI also reads a config file above the working directory. The `install-command` input runs in the working directory. When the install gives the repository its own `prisma` at 8.0.0-rc.37 or later and `prisma-version` is empty, the action runs that CLI (`npx --no-install prisma deploy`), because a config file must be read by the CLI from the same install.
107107
- A `prisma.config.ts` written for Prisma ORM 7 stops the deploy with `CLI.CONFIG_MISSING_MARKER`. The CLI refuses a config file that was not made with `definePrismaConfig`.
108108
- A push to the default branch deploys to production, with no `--environment` argument.
109109
- The Service deploys into the Project that has its name. The `name` input sets that name. Empty uses the `name` in `package.json`, else the folder name.
@@ -213,7 +213,7 @@ Branch names reach the action as environment variables and are passed to the `pr
213213

214214
Plain Node with zero dependencies and no build step. Inputs arrive as `INPUT_*` environment variables; outputs and state go to `$GITHUB_OUTPUT` and `$GITHUB_STATE`.
215215

216-
CI tests the action in three ways. Unit tests cover the scripts. A matrix runs the exact arguments the action passes against real `prisma` CLIs, including the npm `latest` tag. An end-to-end job runs the action itself (`uses: ./`) on the small app in `e2e/app`: it deploys to a new preview environment, checks the outputs and that the service answers, then destroys the environment. It runs once with the app's pinned versions and once moved to `prisma@latest`. The end-to-end job needs the `PRISMA_SERVICE_TOKEN` and `PRISMA_WORKSPACE_ID` secrets. A sweep step destroys `e2e-*` environments whose run has finished, which are ones an earlier run could not destroy. It fails only when such an environment is more than a day old. To remove one by hand, run `ENVIRONMENT=<name> bun scripts/destroy.ts` in `e2e/app` with `PRISMA_SERVICE_TOKEN` and `PRISMA_WORKSPACE_ID` set. The end-to-end job covers the `bun install` path with the app's own `prisma` devDependency. It does not cover `npm ci` or the `prisma-version` input. A second end-to-end job runs the action on `e2e/single-app`, an app with no Composer module, with `prisma@latest`. The action cannot destroy that deploy, so each run deploys into a Project of its own, named `cloud-deploy-action-e2e-single-<run id>-<attempt>`, and deletes the Project afterwards. A pull request run deploys to an environment named after its branch, and a run on `main` deploys to production. The job also deletes such Projects whose run has finished, and fails only when one is more than a day old. To remove one by hand, run `prisma project delete <project id> --confirm <project id>`. CI also runs every 6 hours. A failed or cancelled job on `main`, on a scheduled run, on a manual run or on a `prisma-released` dispatch posts to Slack through the `SLACK_WEBHOOK_URL` secret.
216+
CI tests the action in three ways. Unit tests cover the scripts. A matrix runs the exact arguments the action passes against real `prisma` CLIs, including the npm `latest` tag. An end-to-end job runs the action itself (`uses: ./`) on the small app in `e2e/app`: it deploys to a new preview environment, checks the outputs and that the service answers, then destroys the environment. It runs once with the app's pinned versions and once moved to `prisma@latest`. The end-to-end job needs the `PRISMA_SERVICE_TOKEN` and `PRISMA_WORKSPACE_ID` secrets. A sweep step destroys `e2e-*` environments whose run has finished, which are ones an earlier run could not destroy. It fails only when such an environment is more than a day old. To remove one by hand, run `ENVIRONMENT=<name> bun scripts/destroy.ts` in `e2e/app` with `PRISMA_SERVICE_TOKEN` and `PRISMA_WORKSPACE_ID` set. The end-to-end job covers the `bun install` path with the app's own `prisma` devDependency. It does not cover `npm ci` or the `prisma-version` input. A second end-to-end job runs the action on two apps with no Composer module: `e2e/single-app`, with `prisma@latest`, and `e2e/single-app-config`, which has a `prisma.config.ts` and its own `prisma` in its lockfile. The action cannot destroy such a deploy, so each job deploys into a Project of its own, named `cloud-deploy-action-e2e-single-<run id>-<attempt>-<matrix entry>`, and deletes the Project afterwards. A pull request run deploys to an environment named after its branch, and a run on `main` deploys to production. The job also deletes such Projects whose run has finished, and fails only when one is more than a day old. To remove one by hand, run `prisma project delete <project id> --confirm <project id>`. CI also runs every 6 hours. A failed or cancelled job on `main`, on a scheduled run, on a manual run or on a `prisma-released` dispatch posts to Slack through the `SLACK_WEBHOOK_URL` secret.
217217

218218
Publishing a `v1.x.y` release, or promoting a prerelease to one, moves the `v1` tag to the newest published `v1.x.y` release (`.github/workflows/major-tag.yml`). Publishing a prerelease never moves it. To move it by hand, run that workflow.
219219

‎action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
description: Your build command, run verbatim in both modes; the exact value "none" skips the build phase. Not used in single-app mode, where the Prisma CLI builds the Service
66
default: npm run build
77
install-command:
8-
description: Empty auto-detects from the lockfile (npm ci or bun install --frozen-lockfile). In single-app mode the Prisma CLI installs the dependencies, and the action installs first only when the repository has a prisma.config.ts
8+
description: Empty auto-detects from the lockfile (npm ci or bun install --frozen-lockfile; a Composer module with pnpm or yarn must set this). In single-app mode the Prisma CLI installs the dependencies, and the action installs first only when the repository has a prisma.config.ts, in the folder with the lockfile, and then also detects pnpm and yarn
99
default: ""
1010
module:
1111
description: Path to your app's Composer module. Empty uses module.ts when it exists; a repository with no module.ts deploys in single-app mode

‎cli.mjs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,18 @@ export function deploysWithoutComposerModule(version) {
9393
}
9494

9595
/**
96-
* Whether `workdir` or a parent, up to `root`, holds a prisma.config.ts.
97-
* The CLI reads every such file before it runs a command.
96+
* The nearest directory, from `workdir` up to `root`, that holds a file with
97+
* one of `names`. Null when none does.
9898
*
99+
* @param {string[]} names
99100
* @param {string} workdir
100101
* @param {string} root - The repository root; the search does not go above it.
101-
* @returns {boolean}
102+
* @returns {string | null}
102103
*/
103-
export function hasPrismaConfig(workdir, root) {
104+
export function nearestDirectoryWith(names, workdir, root) {
104105
for (let dir = workdir; ; dir = dirname(dir)) {
105-
if (existsSync(join(dir, "prisma.config.ts"))) return true;
106-
if (dirname(dir) === dir || relative(root, dir) === "") return false;
106+
if (names.some((name) => existsSync(join(dir, name)))) return dir;
107+
if (dirname(dir) === dir || relative(root, dir) === "") return null;
107108
}
108109
}
109110

‎e2e/single-app-cleanup.mjs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Deletes the Project this run deployed e2e/single-app into, then the Projects
22
// of finished runs that could not delete their own. The action cannot destroy
3-
// a deploy with no Composer module, so each run gets a Project of its own,
4-
// named cloud-deploy-action-e2e-single-<run id>-<attempt>. A leftover that
5-
// will not go away fails the job only once it is a day old.
3+
// a deploy with no Composer module, so each job gets a Project of its own,
4+
// named cloud-deploy-action-e2e-single-<run id>-<attempt>-<matrix entry>. A
5+
// leftover that will not go away fails the job only once it is a day old.
66
import { spawnSync } from "node:child_process";
77
import { finishedRun } from "./finished-run.mjs";
88

9-
const RUN_PROJECT_RE = /^cloud-deploy-action-e2e-single-(\d+)-\d+$/;
9+
const RUN_PROJECT_RE = /^cloud-deploy-action-e2e-single-(\d+)-\d+-[a-z]+$/;
1010
const DAY_MS = 24 * 60 * 60 * 1000;
1111
const { PROJECT = "" } = process.env;
1212
if (!RUN_PROJECT_RE.test(PROJECT)) throw new Error(`refusing to delete "${PROJECT}": not a Project of this job`);

‎e2e/single-app-config/.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
run.json
2+
node_modules/
3+
.prisma/

0 commit comments

Comments
 (0)