Skip to content

Commit 1c86c32

Browse files
authored
Merge branch 'master' into chore/agent-rules
2 parents 05dede6 + 1f4f1bf commit 1c86c32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1094
-764
lines changed

.github/scripts/before-beta-release.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import path from 'node:path';
2-
import { readFile, writeFile } from 'node:fs/promises';
31
import { execSync } from 'node:child_process';
2+
import { readFile, writeFile } from 'node:fs/promises';
3+
import path from 'node:path';
44

55
const PKG_JSON_PATH = path.join(import.meta.dirname, '..', '..', 'package.json');
66

@@ -13,10 +13,14 @@ const nextVersion = getNextVersion(VERSION);
1313
console.log(`before-deploy: Setting version to ${nextVersion}`);
1414
pkgJson.version = nextVersion;
1515

16-
await writeFile(PKG_JSON_PATH, JSON.stringify(pkgJson, null, 4) + '\n');
16+
await writeFile(PKG_JSON_PATH, `${JSON.stringify(pkgJson, null, 4)}\n`);
1717

1818
function getNextVersion(version: string) {
19-
const versionString = execSync(`npm show ${PACKAGE_NAME} versions --json`, { encoding: 'utf8' });
19+
const versionString = execSync(`npm show ${PACKAGE_NAME} versions --json`, {
20+
encoding: 'utf8',
21+
stdio: ['ignore', 'pipe', 'ignore'],
22+
});
23+
2024
const versions = JSON.parse(versionString) as string[];
2125

2226
if (versions.some((v) => v === VERSION)) {

.github/workflows/check.yaml

Lines changed: 149 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,103 @@
33
name: Check
44

55
on:
6-
# Push to master will deploy a beta version
76
push:
87
branches: [master, renovate/**]
98
pull_request:
109
branches: [master]
1110

11+
env:
12+
LATEST_NODE_VERSION: 22
13+
APIFY_CLI_DISABLE_TELEMETRY: 1
14+
15+
concurrency:
16+
cancel-in-progress: false
17+
group: checks-${{ github.ref }}
18+
1219
jobs:
13-
build_and_test:
14-
name: Build & Test
20+
build:
1521
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
16-
runs-on: ${{ matrix.os }}
22+
23+
name: Build
24+
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Use Node.js ${{ env.LATEST_NODE_VERSION }}
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: ${{ env.LATEST_NODE_VERSION }}
34+
35+
- name: Enable corepack
36+
run: |
37+
corepack enable
38+
corepack prepare yarn@stable --activate
39+
40+
- name: Activate cache for Node.js ${{ env.LATEST_NODE_VERSION }}
41+
uses: actions/setup-node@v4
42+
with:
43+
cache: yarn
44+
45+
- name: Install Dependencies
46+
run: yarn
47+
48+
- name: Run TSC
49+
run: yarn build
50+
51+
- name: Ensure the reference documentation builds
52+
run: yarn update-docs
53+
54+
lint:
55+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
56+
57+
name: Lint & Format
58+
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Use Node.js ${{ env.LATEST_NODE_VERSION }}
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: ${{ env.LATEST_NODE_VERSION }}
68+
69+
- name: Enable corepack
70+
run: |
71+
corepack enable
72+
corepack prepare yarn@stable --activate
73+
74+
- name: Activate cache for Node.js ${{ env.LATEST_NODE_VERSION }}
75+
uses: actions/setup-node@v4
76+
with:
77+
cache: yarn
78+
79+
- name: Install Dependencies
80+
run: yarn
81+
82+
- name: Run lint checks
83+
run: yarn lint
84+
85+
- name: Run format checks
86+
run: yarn format
87+
88+
test_local:
89+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
90+
91+
name: Local Tests
92+
93+
needs: [build]
1794

1895
strategy:
1996
fail-fast: false
2097
matrix:
2198
os: [ubuntu-latest, windows-2025]
2299
node-version: [18, 20, 22, 24]
23100

101+
runs-on: ${{ matrix.os }}
102+
24103
steps:
25104
- name: Mask secrets
26105
run: |
@@ -46,22 +125,61 @@ jobs:
46125
- name: Install Dependencies
47126
run: yarn
48127

49-
- name: Run Tests
128+
- name: Run local tests
129+
run: yarn test:local
130+
131+
test_api:
132+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
133+
134+
name: API Tests
135+
136+
needs: [build]
137+
138+
runs-on: ubuntu-latest
139+
140+
steps:
141+
- name: Mask secrets
142+
run: |
143+
echo "::add-mask::${{ secrets.APIFY_TEST_USER_API_TOKEN }}"
144+
145+
- uses: actions/checkout@v4
146+
147+
- name: Use Node.js ${{ env.LATEST_NODE_VERSION }}
148+
uses: actions/setup-node@v4
149+
with:
150+
node-version: ${{ env.LATEST_NODE_VERSION }}
151+
152+
- name: Enable corepack
153+
run: |
154+
corepack enable
155+
corepack prepare yarn@stable --activate
156+
157+
- name: Activate cache for Node.js ${{ env.LATEST_NODE_VERSION }}
158+
uses: actions/setup-node@v4
159+
with:
160+
cache: yarn
161+
162+
- name: Install Dependencies
163+
run: yarn
164+
165+
- name: Run API tests
50166
env:
51167
TEST_USER_TOKEN: ${{ secrets.APIFY_TEST_USER_API_TOKEN }}
52-
APIFY_CLI_DISABLE_TELEMETRY: 1
53-
run: yarn test
54-
55-
# - name: Ensure the reference documentation builds
56-
# run: yarn update-docs
168+
run: yarn test:api
57169

58170
test_python_support:
59-
name: Test Python template support
171+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
172+
173+
name: Python Support
174+
175+
needs: [build]
176+
60177
strategy:
61178
fail-fast: false
62179
matrix:
63180
os: [ubuntu-latest, windows-2025]
64181
python-version: ["3.9", "3.10", "3.11", "3.12"]
182+
65183
runs-on: ${{ matrix.os }}
66184

67185
steps:
@@ -71,17 +189,17 @@ jobs:
71189
72190
- uses: actions/checkout@v4
73191

74-
- name: Use Node.js 22
192+
- name: Use Node.js ${{ env.LATEST_NODE_VERSION }}
75193
uses: actions/setup-node@v4
76194
with:
77-
node-version: 22
195+
node-version: ${{ env.LATEST_NODE_VERSION }}
78196

79197
- name: Enable corepack
80198
run: |
81199
corepack enable
82200
corepack prepare yarn@stable --activate
83201
84-
- name: Activate cache for Node.js 22
202+
- name: Activate cache for Node.js ${{ env.LATEST_NODE_VERSION }}
85203
uses: actions/setup-node@v4
86204
with:
87205
cache: yarn
@@ -97,28 +215,29 @@ jobs:
97215
- name: Run Python tests
98216
env:
99217
TEST_USER_TOKEN: ${{ secrets.APIFY_TEST_USER_API_TOKEN }}
100-
APIFY_CLI_DISABLE_TELEMETRY: 1
101-
run: yarn test-python
218+
run: yarn test:python
102219

103220
docs:
104-
name: Docs build
105221
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
222+
223+
name: Docs build
224+
106225
runs-on: ubuntu-latest
226+
107227
steps:
108-
- name: Checkout Source code
109-
uses: actions/checkout@v4
228+
- uses: actions/checkout@v4
110229

111-
- name: Use Node.js 22
230+
- name: Use Node.js ${{ env.LATEST_NODE_VERSION }}
112231
uses: actions/setup-node@v4
113232
with:
114-
node-version: 22
233+
node-version: ${{ env.LATEST_NODE_VERSION }}
115234

116235
- name: Enable corepack
117236
run: |
118237
corepack enable
119238
corepack prepare yarn@stable --activate
120239
121-
- name: Activate cache for Node.js 22
240+
- name: Activate cache for Node.js ${{ env.LATEST_NODE_VERSION }}
122241
uses: actions/setup-node@v4
123242
with:
124243
cache: yarn
@@ -132,40 +251,12 @@ jobs:
132251
yarn
133252
yarn build
134253
135-
lint:
136-
name: Lint
137-
runs-on: ubuntu-latest
138-
139-
steps:
140-
- uses: actions/checkout@v4
141-
142-
- name: Use Node.js 22
143-
uses: actions/setup-node@v4
144-
with:
145-
node-version: 22
146-
147-
- name: Enable corepack
148-
run: |
149-
corepack enable
150-
corepack prepare yarn@stable --activate
151-
152-
- name: Activate cache for Node.js 22
153-
uses: actions/setup-node@v4
154-
with:
155-
cache: yarn
156-
157-
- name: Install Dependencies
158-
run: yarn
159-
160-
- name: Run lint checks
161-
run: yarn lint
254+
build_bundles:
255+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
162256

163-
- name: Run format checks
164-
run: yarn format
257+
name: Bundles (${{ matrix.label }})
165258

166-
build_bundles:
167-
name: Build Test Bundles (${{ matrix.label }})
168-
needs: [build_and_test]
259+
needs: [build]
169260

170261
strategy:
171262
fail-fast: false
@@ -183,17 +274,17 @@ jobs:
183274
steps:
184275
- uses: actions/checkout@v4
185276

186-
- name: Use Node.js 22
277+
- name: Use Node.js ${{ env.LATEST_NODE_VERSION }}
187278
uses: actions/setup-node@v4
188279
with:
189-
node-version: 22
280+
node-version: ${{ env.LATEST_NODE_VERSION }}
190281

191282
- name: Enable corepack
192283
run: |
193284
corepack enable
194285
corepack prepare yarn@stable --activate
195286
196-
- name: Activate cache for Node.js 22
287+
- name: Activate cache for Node.js ${{ env.LATEST_NODE_VERSION }}
197288
uses: actions/setup-node@v4
198289
with:
199290
cache: yarn
@@ -206,6 +297,7 @@ jobs:
206297
if: ${{ matrix.os != 'windows-11-arm' }}
207298
with:
208299
bun-version-file: .bun-version
300+
no-cache: true
209301

210302
- name: Install bun (Windows ARM)
211303
if: ${{ matrix.os == 'windows-11-arm' }}

.github/workflows/pre_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
with:
3838
ref: ${{ github.ref }}
3939
repo-token: ${{ secrets.GITHUB_TOKEN }}
40-
check-regexp: (Build & Test .*|Test Python template support|Lint|Docs build)
40+
check-regexp: (Build|Lint.*|(Local|API) Tests.*|Python Support.*|Docs build)
4141
wait-interval: 5
4242

4343
update_changelog:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
ref: ${{ github.ref }}
6868
repo-token: ${{ secrets.GITHUB_TOKEN }}
69-
check-regexp: (Build & Test .*|Test Python template support|Lint|Docs build)
69+
check-regexp: (Build|(Local|API) Tests.*|Python Support.*|Docs build)
7070
wait-interval: 5
7171

7272
update_changelog:

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Dev mode
44

5-
You can call `./bin/dev.sh` to run the CLI in development mode. This will use the local version of the CLI instead of the one installed globally.
5+
You can run `yarn dev:apify` to run the CLI in development mode. This will use the local version of the CLI instead of the one installed globally.
66

77
## Tests
88

@@ -12,10 +12,10 @@ You need to have Apify account to test all apify-cli features.
1212
Then you can run tests with commands in repository root directory:
1313

1414
1. Install all dependencies:
15-
`npm install`
15+
`yarn`
1616

1717
2. Run tests using credentials of the 'apify-test' user:
18-
`TEST_USER_TOKEN=<apifyUserApiToken> npm run test`
18+
`TEST_USER_TOKEN=<apifyUserApiToken> yarn test:all`
1919

2020
## Publish new version
2121

@@ -37,6 +37,9 @@ In `test/__setup__/hooks` we have a collection of hooks that you can use while w
3737

3838
Use this hook at the start of your test file to mark the entire suite as require-ing a separated authentication setup. By default, this will recreate the authentication setup per test in your suite, but you can disable that by passing in `{ perTest: false }` in the call to `useAuthSetup`.`
3939

40+
If you're writing a test case or file that relies on API interactions, make sure it either goes in the `test/api` folder, and that it has a `[api]` reference in the name of the test case (usually at the start).
41+
If your test file also mixes local tests, always add `[api]` for test cases that need the API. They will automatically be skipped for local tests.
42+
4043
#### Example usage
4144

4245
```typescript
@@ -131,7 +134,4 @@ afterAll(async () => {
131134

132135
### Running commands
133136

134-
Running commands in tests can be done in two ways:
135-
136-
- Importing the command class and calling `Command.run([], import.meta.url);`, where the array is the argv of the commands (think of it like the arguments you'd pass to the command in the terminal).
137-
- By importing `runCommand` from `@oclif/test` and using that helper to run the command.
137+
Running commands in tests can be done by calling `runCommand` (imported from the command framework)

0 commit comments

Comments
 (0)