|
10 | 10 |
|
11 | 11 | # Chainlink Runtime Environment (CRE) - CLI Tool |
12 | 12 |
|
13 | | -Note this README is for CRE developers only, if you are a CRE user, please ask Dev Services team for the user guide. |
| 13 | +> If you want to **write workflows**, please use the public documentation: https://docs.chain.link/cre |
| 14 | +> This README is intended for **CRE CLI developers** (maintainers/contributors), not CRE end users. |
14 | 15 |
|
15 | | -A command-line interface (CLI) tool for managing workflows, built with Go and Cobra. This tool allows you to compile Go workflows into WebAssembly (WASM) binaries and manage your workflow projects. |
| 16 | +A Go/Cobra-based command-line tool for building, testing, and managing Chainlink Runtime Environment (CRE) workflows. This repository contains the CLI source code and developer tooling. |
16 | 17 |
|
17 | 18 | - [Installation](#installation) |
18 | | -- [Usage](#usage) |
19 | | -- [Configuration](#configuration) |
20 | | - - [Sensitive Data](#sensitive-data) |
21 | | - - [Global Configuration](#global-configuration) |
22 | | - - [Secrets Template](#secrets-template) |
23 | | -- [Global Flags](#global-flags) |
24 | | -- [Commands](#commands) |
25 | | - - [Workflow Simulate](#workflow-simulate) |
| 19 | +- [Developer Commands](#developer-commands) |
| 20 | +- [CRE Commands](#commands) |
| 21 | +- [Legal Notice](#legal-notice) |
26 | 22 |
|
27 | 23 | ## Installation |
28 | 24 |
|
29 | 25 | 1. Clone the repository: |
30 | 26 |
|
31 | | - ```bash |
32 | | - git clone https://github.com/smartcontractkit/cre-cli.git |
33 | | - cd cre-cli |
34 | | - ``` |
| 27 | + ```bash |
| 28 | + git clone https://github.com/smartcontractkit/cre-cli.git |
| 29 | + cd cre-cli |
| 30 | + ```` |
35 | 31 |
|
36 | 32 | 2. Make sure you have Go installed. You can check this with: |
37 | 33 |
|
38 | 34 | ```bash |
39 | 35 | go version |
40 | 36 | ``` |
41 | 37 |
|
42 | | -3. Build the CLI tool: |
43 | | - |
44 | | - ```bash |
45 | | - make build |
46 | | - ``` |
47 | | - |
48 | | -4. (optional) Enable git pre-commit hook |
49 | | - ```bash |
50 | | - ln -sf ../../.githooks/pre-commit .git/hooks/pre-commit |
51 | | - ``` |
52 | | - |
53 | | -## Usage |
54 | | - |
55 | | -You can use the CLI tool to manage workflows by running commands in the terminal. The main command is `cre`. |
56 | | - |
57 | | -To view all available commands and subcommands, you can start by running the tool with `--help` flag: |
58 | | - |
59 | | -```bash |
60 | | -./cre --help |
61 | | -``` |
62 | | - |
63 | | -To view subcommands hidden under a certain command group, select the command name and run with the tool with `--help` flag, for example: |
| 38 | +## Developer Commands |
64 | 39 |
|
65 | | -```bash |
66 | | -./cre workflow --help |
67 | | -``` |
| 40 | +Developer commands are available via the Makefile: |
68 | 41 |
|
69 | | -## Configuration |
| 42 | +* **Install dependencies/tools** |
70 | 43 |
|
71 | | -There are several ways to configure the CLI tool, with some configuration files only needed for running specific commands. |
72 | | - |
73 | | -### Sensitive Data and `.env` file |
74 | | -`.env` file is used to specify sensitive data required for running most of the commands. It is **highly recommended that you don't keep the `.env` file in unencrypted format** on your disk and store it somewhere safely (e.g. in secret manager tool). |
75 | | -The most important environment variable to define is `CRE_ETH_PRIVATE_KEY`. |
76 | | - |
77 | | -#### Using 1Password for Secret Management |
78 | | -* Install [1Password CLI](https://developer.1password.com/docs/cli/get-started/) |
79 | | -* Add variables to your 1Password Vault |
80 | | -* Create the `.env` file with [secret references](https://developer.1password.com/docs/cli/secret-references). Replace plaintext values with references like |
81 | | - ``` |
82 | | - CRE_ETH_PRIVATE_KEY=op://<vault-name>/<item-name>/[section-name/]<field-name> |
| 44 | + ```bash |
| 45 | + make install-tools |
83 | 46 | ``` |
84 | | -* Run `cre` commands using [1Password](https://developer.1password.com/docs/cli/secrets-environment-variables/#use-environment-env-files). |
85 | | - Use the op run command to provision secrets securely: |
86 | | - ```shell |
87 | | - op run --env-file=".env" -- cre workflow deploy myWorkflow |
88 | | - ``` |
89 | | - _Note: `op run` doesn't support `~` inside env file path. Use only absolute or relative paths for the env file (e.g. `--env-file="/Users/username/.chainlink/cli.env"` or `--env-file="../.chainlink/cli.env"`)._ |
90 | 47 |
|
91 | | -#### Exporting |
92 | | -To prevent any data leaks, you can also use `export` command, e.g. `export MY_ENV_VAR=mySecret`. For better security, use a space before the `export` command to prevent the command from being saved to your terminal history. |
| 48 | +* **Build the binary (for local testing)** |
93 | 49 |
|
94 | | -### Global Configuration |
95 | | -`project.yaml` file keeps CLI tool settings in one place. Once your project has been initiated using `cre init`, you will need to add a valid RPC to your `project.yaml`. |
| 50 | + ```bash |
| 51 | + make build |
| 52 | + ``` |
96 | 53 |
|
97 | | -Please find more information in the project.yaml file that is created by the `cre init` command. |
| 54 | +* **Run linters** |
98 | 55 |
|
99 | | -### Secrets Template |
100 | | -If you are planning on using a workflow that has a dependency on sensitive data, then it's recommended to encrypt those secrets. In such cases, a secrets template file secrets.yaml that is created by the `cre init` can be used as a starting point. Secrets template is required for the `secrets encrypt` command. |
| 56 | + ```bash |
| 57 | + make lint |
| 58 | + ``` |
101 | 59 |
|
102 | | -## Global Flags |
| 60 | +* **Regenerate CLI docs (when commands/flags change)** |
103 | 61 |
|
104 | | -All of these flags are optional, but available for each command and at each level: |
105 | | -- **`-h`** / **`--help`**: Prints help message. |
106 | | -- **`-v`** / **`--verbose`**: Enables DEBUG mode and prints more content. |
107 | | -- **`-R`** / **`--project-root`**: Path to project root directory. |
108 | | -- **`-e`** / **`--env`**: Path to .env file which contains sensitive data needed for running specific commands. |
| 62 | + ```bash |
| 63 | + make gendoc |
| 64 | + ``` |
109 | 65 |
|
110 | 66 | ## Commands |
111 | 67 |
|
112 | 68 | For a list of all commands and their descriptions, please refer to the [docs](docs) folder. |
113 | 69 |
|
114 | | -### Workflow Simulate |
115 | | - |
116 | | -To simulate a workflow, you can use the `cre workflow simulate` command. This command allows you to run a workflow locally without deploying it. |
117 | | - |
118 | | -```bash |
119 | | -cre workflow simulate <path-to-workflow> --target=staging-settings |
120 | | -``` |
121 | | - |
122 | | - |
123 | 70 | ## Legal Notice |
124 | | -By using the CRE CLI tool, you agree to the Terms of Service (https://chain.link/terms) and Privacy Policy (https://chain.link/privacy-policy). |
| 71 | + |
| 72 | +By using the CRE CLI tool, you agree to the Terms of Service ([https://chain.link/terms](https://chain.link/terms)) and Privacy Policy ([https://chain.link/privacy-policy](https://chain.link/privacy-policy)). |
0 commit comments