|
4 | 4 |
|
5 | 5 | ## Status |
6 | 6 | [](https://codecov.io/gh/adobe-rnd/spacecat-task-processor) |
7 | | -[](https://circleci.com/gh/adobe-rnd/spacecat-audit-worker) |
8 | | -[](https://github.com/adobe-rnd/spacecat-audit-worker/blob/master/LICENSE.txt) |
9 | | -[](https://github.com/adobe-rnd/spacecat-audit-worker/issues) |
10 | | -[](https://lgtm.com/projects/g/adobe-rnd/spacecat-audit-worker) |
| 7 | +[](https://circleci.com/gh/adobe-rnd/spacecat-task-processor) |
| 8 | +[](https://github.com/adobe-rnd/spacecat-task-processor/blob/master/LICENSE.txt) |
| 9 | +[](https://github.com/adobe-rnd/spacecat-task-processor/issues) |
| 10 | +[](https://lgtm.com/projects/g/adobe-rnd/spacecat-task-processor) |
11 | 11 | [](https://github.com/semantic-release/semantic-release) |
12 | 12 |
|
13 | 13 | ## Installation |
@@ -52,98 +52,3 @@ Expected message body format in `SPACECAT-TASK-PROCESSOR-JOBS` is: |
52 | 52 | "siteId": "string" |
53 | 53 | } |
54 | 54 | ``` |
55 | | - |
56 | | -Output message body format sent to `SPACECAT-TASK-PROCESSOR-JOBS` is: |
57 | | - |
58 | | -```json |
59 | | -{ |
60 | | - "type": "string", |
61 | | - "url": "string", |
62 | | - "auditContext": "object", |
63 | | - "auditResult": "object" |
64 | | -} |
65 | | -``` |
66 | | - |
67 | | -## How to Run Locally |
68 | | - |
69 | | -### 1. Using `nodemon` and AWS Credentials |
70 | | - |
71 | | -Everyone working on Spacecat should have access to the development environments via [KLAM](https://klam.corp.adobe.com/). |
72 | | -If you don’t have access, please refer to the engineering onboarding guide or contact your Spacecat team representative. |
73 | | - |
74 | | -After logging into KLAM, you’ll receive the following credentials required to access AWS resources such as DynamoDB and S3 for local development: |
75 | | - |
76 | | -- `AWS_ACCESS_KEY_ID` |
77 | | -- `AWS_SECRET_ACCESS_KEY` |
78 | | -- `AWS_SESSION_TOKEN` |
79 | | - |
80 | | -**IMPORTANT: DO NOT USE THE AWS TOKENS FROM KLAM PRODUCTION PROFILES. USE ONLY DEV TOKENS.** |
81 | | - |
82 | | - |
83 | | -### Steps to use `nodemon` |
84 | | - |
85 | | -#### 1. Create an `.env` File |
86 | | - |
87 | | -Create a `.env` file in the root directory with the following environment variables, which are required for all audits. |
88 | | -Add any additional environment variables specific to the audit you're working on. |
89 | | - |
90 | | -``` |
91 | | -AWS_REGION=us-east-1 |
92 | | -DYNAMO_TABLE_NAME_DATA=spacecat-services-data |
93 | | -AWS_ACCESS_KEY_ID=<acquired from KLAM> |
94 | | -AWS_SECRET_ACCESS_KEY=<acquired from KLAM> |
95 | | -AWS_SESSION_TOKEN=<acquired from KLAM> |
96 | | -# ... other required variables depending on the audit |
97 | | -``` |
98 | | - |
99 | | -#### 2. Run/Debug with `npm start` |
100 | | - |
101 | | -Once your `.env` file is set up, start the local development server using: |
102 | | - |
103 | | -```bash |
104 | | -npm start |
105 | | -``` |
106 | | - |
107 | | -To use breakpoints, make sure to use the debugging tools provided by your IDE (e.g., VSCode, WebStorm, etc.). |
108 | | - |
109 | | -#### 3. Trigger a Task |
110 | | - |
111 | | -With the server running, you can trigger a task using a `curl` POST request. The request body should include the task type and `siteId`: |
112 | | - |
113 | | -```json |
114 | | -{ |
115 | | - "type": "<task handler name>", |
116 | | - "siteId": "<siteId>" |
117 | | -} |
118 | | -``` |
119 | | - |
120 | | -- A list of task handler names can be found in the [index.js file](https://github.com/adobe/spacecat-task-processor/blob/main/src/index.js#L45). |
121 | | -- You can retrieve a `siteId` using: |
122 | | - - The [Spacecat API](https://opensource.adobe.com/spacecat-api-service/#tag/site/operation/getSiteByBaseUrl) |
123 | | - - The Slack command: `@spacecat-dev get site domain.com` |
124 | | - |
125 | | -Example `curl` request to trigger the "demo-url" task: |
126 | | - |
127 | | -```bash |
128 | | -curl -X POST http://localhost:3000 \ |
129 | | - -H "Content-Type: application/json" \ |
130 | | - -d '{ "type": "demo-url", "siteId": "9ab0575a-c238-4470-ae82-9d37fb2d0e78" }' |
131 | | -``` |
132 | | - |
133 | | -### 2. Using AWS SAM and Docker. |
134 | | - |
135 | | -1. Ensure you have [Docker](https://docs.docker.com/desktop/setup/install/mac-install/), [AWS SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) and [jq](https://jqlang.org/) installed. |
136 | | -2. Login to AWS using [KLAM](https://klam.corp.adobe.com/) and login with your [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). |
137 | | - * KLAM dev project: `SpaceCat Development (AWS3338)` |
138 | | -3. To provide secrets to the audit, please run `./scripts/populate-env.sh` once. It will fetch all secrets from the AWS Secret Manager. |
139 | | -4. To run the audit locally, execute the following commands: |
140 | | - ```bash |
141 | | - source env.sh |
142 | | - npm run local-build |
143 | | - npm run local-run |
144 | | - ``` |
145 | | -5. Starting point of the execution is `src/index-local.js`. Output of the audit can be found in `output.txt`. |
146 | | -6. To hot reload any changes in the `/src` folder, you can use `npm run local-watch`. Note: This will require to run `npm run local-build` at least once beforehand. |
147 | | - |
148 | | -If you need to add additional secrets, make sure to adjust the Lambda `template.yml` accordingly. |
149 | | - |
0 commit comments