Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a14fb6f

Browse files
committedOct 16, 2024··
ci: run next.js deps with netlify-cli dev dep
1 parent 3842695 commit a14fb6f

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed
 

‎.github/workflows/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
7575
run: |
7676
# Control netlify-cli as a regular dev dep but expose it globally for test fixtures to use
77-
npm install -g "netlify-cli@$(npm list --json | jq -r ".devDependencies[\"netlify-cli\"].version")"
77+
npm install -g "netlify-cli@$(npm list --json --depth=0 netlify-cli | jq -r ".dependencies[\"netlify-cli\"].version")"
7878
npx netlify login
7979
- name: Get installed Playwright version
8080
id: playwright-version
@@ -209,7 +209,7 @@ jobs:
209209
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
210210
run: |
211211
# Control netlify-cli as a regular dev dep but expose it globally for test fixtures to use
212-
npm install -g "netlify-cli@$(npm list --json | jq -r ".devDependencies[\"netlify-cli\"].version")"
212+
npm install -g "netlify-cli@$(npm list --json --depth=0 netlify-cli | jq -r ".dependencies[\"netlify-cli\"].version")"
213213
npx netlify login
214214
- name: Resolve Next.js version
215215
id: resolve-next-version

‎.github/workflows/test-e2e.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ jobs:
180180
run: npm run build
181181
working-directory: ${{ env.runtime-path }}
182182

183-
# TODO(serhalp) Use the netlify-cli dev dep? It's a bit trickier here because we're running in
184-
# the next.js directory, not the next-runtime directory. See https://github.com/netlify/next-runtime/pull/2484.
185-
- name: add netlify cli
186-
run: npm install -g netlify-cli
183+
- name: Prepare Netlify CLI
184+
# Control netlify-cli as a regular dev dep but expose it globally for test fixtures to use
185+
run: npm install -g "netlify-cli@$(npm list --json --depth=0 netlify-cli | jq -r ".dependencies[\"netlify-cli\"].version")"
187186

188187
- name: Install Playwright Browsers
189188
run: npx playwright install --with-deps

‎tests/netlify-deploy.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ export class NextDeployInstance extends NextInstance {
102102
await fs.writeFile(path.join(this.testDir, 'netlify.toml'), toml)
103103
}
104104

105-
// ensure netlify cli is installed
105+
// ensure netlify-cli is installed
106106
try {
107-
const res = await execa('netlify', ['--version'])
107+
const res = await execa('npx', ['netlify', '--version'])
108108
require('console').log(`Using Netlify CLI version:`, res.stdout)
109109
} catch (_) {
110-
require('console').log(`You need to have netlify-cli installed.
110+
require('console').log(`netlify-cli is not installed.
111111
112-
You can do this by running: "npm install -g netlify-cli@latest" or "yarn global add netlify-cli@latest"`)
112+
Something went wrong. Try running \`npm install\`.`)
113113
}
114114

115115
// ensure project is linked
116116
try {
117-
await execa('ntl', ['status', '--json'])
117+
await execa('npx', ['netlify', 'status', '--json'])
118118
} catch (err) {
119119
if (err.message.includes("You don't appear to be in a folder that is linked to a site")) {
120120
throw new Error(`Site is not linked. Please set "NETLIFY_AUTH_TOKEN" and "NETLIFY_SITE_ID"`)
@@ -132,8 +132,8 @@ export class NextDeployInstance extends NextInstance {
132132
: testName
133133

134134
const deployRes = await execa(
135-
'ntl',
136-
['deploy', '--build', '--json', '--message', deployTitle ?? ''],
135+
'npx',
136+
['netlify', 'deploy', '--build', '--json', '--message', deployTitle ?? ''],
137137
{
138138
cwd: this.testDir,
139139
reject: false,

0 commit comments

Comments
 (0)
Please sign in to comment.