You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+87-74Lines changed: 87 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,12 @@ Thank you for helping us make Trigger.dev even better! 🤩
10
10
11
11
The development branch is `main`. This is the branch that all pull
12
12
requests should be made against. The changes on the `main`
13
-
branch are tagged into a release monthly.
13
+
branch are tagged into a release periodically.
14
14
15
15
### Prerequisites
16
16
17
-
-[Node.js](https://nodejs.org/en) version >=16.x
18
-
-[pnpm package manager](https://pnpm.io/installation) version 7
17
+
-[Node.js](https://nodejs.org/en) version 20.11.1
18
+
-[pnpm package manager](https://pnpm.io/installation) version 8.15.5
19
19
-[Docker](https://www.docker.com/get-started/)
20
20
21
21
### Setup
@@ -33,15 +33,19 @@ branch are tagged into a release monthly.
33
33
```
34
34
cd trigger.dev
35
35
```
36
-
3. Install the required packages using pnpm.
36
+
3. Ensure you are on the correct version of Node.js (20.11.1). If you are using `nvm`, there is an `.nvmrc` file that will automatically select the correct version of Node.js when you navigate to the repository.
37
+
38
+
4. Run `corepack enable` to use the correct version of pnpm (`8.15.5`) as specified in the root `package.json` file.
39
+
40
+
5. Install the required packages using pnpm.
37
41
```
38
42
pnpm i
39
43
```
40
-
4. Create your `.env` file
44
+
6. Create your `.env` file
41
45
```
42
46
cp .env.example .env
43
47
```
44
-
5. Open it and generate a new value for `ENCRYPTION_KEY`:
48
+
7. Open it and generate a new value for `ENCRYPTION_KEY`:
45
49
46
50
`ENCRYPTION_KEY` is used to two-way encrypt OAuth access tokens and so you'll probably want to actually generate a unique value, and it must be a random 16 byte hex string. You can generate one with the following command:
47
51
@@ -51,27 +55,23 @@ branch are tagged into a release monthly.
51
55
52
56
Feel free to update `SESSION_SECRET` and `MAGIC_LINK_SECRET` as well using the same method.
53
57
54
-
6. Start Docker. This starts the required services like Postgres. If this is your first time using Docker, consider going through this [guide](DOCKER_INSTALLATION.md)
58
+
8. Start Docker. This starts the required services like Postgres & Redis. If this is your first time using Docker, consider going through this [guide](DOCKER_INSTALLATION.md)
55
59
56
60
```
57
61
pnpm run docker
58
62
```
59
63
60
64
This will also start and run a local instance of [pgAdmin](https://www.pgadmin.org/) on [localhost:5480](http://localhost:5480), preconfigured with email `admin@example.com` and pwd `admin`. Then use `postgres` as the password to the Trigger.dev server.
61
65
62
-
7. Migrate the database
66
+
9. Migrate the database
63
67
```
64
68
pnpm run db:migrate
65
69
```
66
-
8. Build the app
67
-
```
68
-
pnpm run build --filter webapp
69
-
```
70
-
9. Run the seed script
71
-
```
72
-
pnpm run db:seed
73
-
```
74
-
10. Run the app. See the section below.
70
+
10. Build the server app
71
+
```
72
+
pnpm run build --filter webapp
73
+
```
74
+
11. Run the app. See the section below.
75
75
76
76
## Running
77
77
@@ -83,99 +83,92 @@ branch are tagged into a release monthly.
83
83
84
84
It should run on port `3030`: [http://localhost:3030](http://localhost:3030/)
85
85
86
-
2. Once the app is running click the magic link button and enter your email.
87
-
3. Check your terminal, the magic link email should have printed out as following:
86
+
2. Once the app is running click the magic link button and enter your email. You will automatically be logged in, since you are running locally. Create an Org and your first project in the dashboard.
88
87
89
-
```sh
90
-
webapp:dev: Log in to Trigger.dev
91
-
webapp:dev:
92
-
webapp:dev: Click here to log in with this magic link
webapp:dev: If you didn't try to log in, you can safely ignore this email.
96
-
```
88
+
## Manual testing using v3-catalog
97
89
98
-
Paste the magic link shown in your terminal into your browser to login.
90
+
We use the `<root>/references/v3-catalog` subdirectory as a staging ground for testing changes to the SDK (`@trigger.dev/sdk` at `<root>/packages/trigger-sdk`), the Core package (`@trigger.dev/core` at `<root>packages/core`), the CLI (`trigger.dev` at `<root>/packages/cli-v3`) and the platform (The remix app at `<root>/apps/webapp`). The instructions below will get you started on using the `v3-catalog` for local development of Trigger.dev (v3).
2. Change directory to the packages/database folder
104
-
```sh
105
-
cd packages/database
106
-
```
107
-
3. Generate the Prisma client
94
+
First, make sure you are running the webapp according to the instructions above. Then:
108
95
109
-
```sh
110
-
pnpm run generate
111
-
```
96
+
1. In Postgres go to the "Organizations" table and on your org set the `v3Enabled` column to `true`.
112
97
113
-
The above updates the prisma client generated into node_modules/.prisma/client folder. This helps with typing of relevant prisma models. It ensures typescript
114
-
recognizes fields added or removed from a model and type-checks appropriately.
98
+
2. Visit http://localhost:3030 in your browser and create a new V3 project called "v3-catalog". If you don't see an option for V3, you haven't set the `v3Enabled` flag to true.
115
99
116
-
4. Create and apply the migrations
100
+
3. In Postgres go to the "Projects" table and for the project you create change the `externalRef` to `yubjwjsfkxnylobaqvqz`.
117
101
118
-
```
119
-
pnpm run db:migrate:dev
120
-
```
102
+
4. Build the CLI
121
103
122
-
This creates a migration file and executes the migrations against your database and applies changes to the database schema(s)
104
+
```sh
105
+
pnpm run build --filter trigger.dev
106
+
```
123
107
124
-
5. Commit generated migrations as well as changes to the schema.prisma file
125
-
6. If you're using VSCode you may need to restart the Typescript server in the webapp to get updated type inference. Open a TypeScript file, then open the Command Palette (View > Command Palette) and run `TypeScript: Restart TS server`.
108
+
5. Change into the `<root>/references/v3-catalog` directory and authorize the CLI to the local server:
126
109
127
-
## Testing CLI changes
110
+
```sh
111
+
cd references/v3-catalog
112
+
pnpm exec triggerdev login -a http://localhost:3030
113
+
```
128
114
129
-
To test CLI changes, follow the steps below:
115
+
This will open a new browser window and authorize the CLI against your local user account.
130
116
131
-
1. Build the CLI and watch forchanges
117
+
You can optionally pass a `--profile` flag to the `login` command, which will allow you to use the CLI with separate accounts/servers. We suggest using a profile called `local`for your local development:
132
118
133
119
```sh
134
-
cd packages/cli
135
-
pnpm run dev
120
+
cd references/v3-catalog
121
+
pnpm exec triggerdev login -a http://localhost:3030 --profile local
122
+
# later when you run the dev or deploy command:
123
+
pnpm exec triggerdev dev --profile local
124
+
pnpm exec triggerdev deploy --profile local
136
125
```
137
126
138
-
2. Open a new Terminal window and run the webapp locally and then create a new project in the dashboard. Copy out the dev API key.
127
+
### Running
139
128
140
-
3. Create a new temporary Next.js app in references directory
129
+
The following steps should be followed any time you start working on a new feature you want to test in v3:
5. Back in the terminal, navigate into the reference, and initialize the CLI. When prompted, select`self-hosted` and enter `localhost:3030`if you are testing against the local instance of Trigger.dev, or you can just use the Trigger.dev cloud. When asked for an API key, use the key you copied earlier.
139
+
2. Open a new terminal window, and anytime changes are made to the `@trigger.dev/core` package, you'll need to manually rebuild the CLI:
157
140
158
141
```sh
159
-
cd ./test-cli
160
-
pnpm i
161
-
pnpm exec trigger-cli init
142
+
pnpm run build --filter trigger.dev
162
143
```
163
144
164
-
6. If you are just testing the `init` command, you can stop here. If you'd like to test the `dev` command, first start the Next.js app on port 3000:
145
+
Note: You do not need to do the same for `@trigger.dev/sdk`, just core.
146
+
147
+
3. Open another terminal window, and change into the `<root>/references/v3-catalog` directory.
148
+
149
+
4. Run the `dev` command, which will register all the local tasks with the platform and allow you to start testing task execution:
165
150
166
151
```sh
167
-
pnpm run dev
152
+
# in <root>/references/v3-catalog
153
+
pnpm exec triggerdev dev
168
154
```
169
155
170
-
7. Open a new terminal window, and then run the `dev` command like so:
156
+
If you want additional debug logging, you can use the `--log-level debug` flag:
171
157
172
158
```sh
173
-
pnpm exec trigger-cli dev
159
+
# in <root>/references/v3-catalog
160
+
pnpm exec triggerdev dev --log-level debug
174
161
```
175
162
176
-
8. Please remember to delete the temporary project you created after you've tested the changes, and before you raise a PR.
163
+
5. If you make any changes in the CLI/Core/SDK, you'll need to `CTRL+C` to exit the `dev` command and restart it to pickup changes. Any changes to the files inside of the `v3-catalog/src/trigger` dir will automatically be rebuilt by the `dev` command.
164
+
165
+
6. Navigate to the `v3-catalog` project in your local dashboard at localhost:3030 and you should see the list of tasks.
166
+
167
+
7. Go to the "Test" page in the sidebar and select a task. Then enter a payload and click "Run test". You can tell what the payloads should be by looking at the relevant task file inside the `/references/v3-catalog/src/trigger` folder. Many of them accept an empty payload.
177
168
178
-
## Running end-to-end webapp tests
169
+
8. Feel free to add additional files in `v3-catalog/src/trigger` to test out specific aspects of the system, or add in edge cases.
170
+
171
+
## Running end-to-end webapp tests (deprecated)
179
172
180
173
To run the end-to-end tests, follow the steps below:
181
174
@@ -223,6 +216,26 @@ The end-to-end tests use a `setup` and `teardown` script to seed the database wi
2. Change directory to the packages/database folder
223
+
224
+
```sh
225
+
cd packages/database
226
+
```
227
+
228
+
3. Create and apply the migrations
229
+
230
+
```
231
+
pnpm run db:migrate:dev
232
+
```
233
+
234
+
This creates a migration file and executes the migrations against your database and applies changes to the database schema(s)
235
+
236
+
4. Commit generated migrations as well as changes to the schema.prisma file
237
+
5. If you're using VSCode you may need to restart the Typescript server in the webapp to get updated type inference. Open a TypeScript file, then open the Command Palette (View > Command Palette) and run `TypeScript: Restart TS server`.
238
+
226
239
## Add sample jobs
227
240
228
241
The [references/job-catalog](./references/job-catalog/) project defines simple jobs you can get started with.
0 commit comments