Skip to content

Commit fda7068

Browse files
feat: Spacecat task processor lambda (#1)
* initial commit * refactor * add npm debug * fix to ci.yaml * removed unused packages * fix index.js * update readme * fresh npm install * adjust message reading logic * change secrets path * resolve to right secrets name * fix api calls * fix slack message * refactor + add opportunity status task processor * use right api for to get suggestions * tweaks * adjust slack messages * incorporate review comments * tweak message * combine messages * add each opportunity in a new line * test files todo * add tests * increase the coverage limits * review comments * Revert "review comments" This reverts commit 5e3eb12. * address review comments * point to task manager secrets managher * pass slack tokens from api service * Revert "pass slack tokens from api service" This reverts commit 51b73bc. * fix name missing issue * experience url fix * fix test * use imsOrgId for mapping * review comments addressed
1 parent d3d7548 commit fda7068

44 files changed

Lines changed: 34515 additions & 0 deletions

Some content is hidden

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

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.vscode/*
2+
coverage/*
3+
scripts/*

.eslintrc.cjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2025 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
module.exports = {
14+
root: true,
15+
parser: '@typescript-eslint/parser',
16+
parserOptions: {
17+
ecmaVersion: 2020,
18+
sourceType: 'module',
19+
},
20+
extends: [
21+
'@adobe/helix',
22+
'plugin:@typescript-eslint/recommended',
23+
],
24+
plugins: [
25+
'import',
26+
'@typescript-eslint',
27+
],
28+
overrides: [
29+
{
30+
files: ['*.test.js'],
31+
rules: {
32+
'@typescript-eslint/no-unused-expressions': 'off',
33+
},
34+
},
35+
],
36+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
labels: bug
5+
6+
---
7+
8+
**Description**
9+
A clear and concise description of what the bug is.
10+
11+
**To Reproduce**
12+
Steps to reproduce the behavior:
13+
1. Go to '...'
14+
2. Click on '....'
15+
3. Scroll down to '....'
16+
4. See error
17+
18+
**Expected behavior**
19+
A clear and concise description of what you expected to happen.
20+
21+
**Screenshots**
22+
If applicable, add screenshots to help explain your problem.
23+
24+
**Version:**
25+
run: `$ hlx --version`
26+
27+
**Additional context**
28+
Add any other context about the problem here.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: Discussion
3+
about: Start a new discussion
4+
labels: question
5+
6+
---
7+
8+
## Overview
9+
whats' this discussion about?
10+
11+
## Details
12+
more details
13+
14+
## Proposed Actions
15+
and now?
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
labels: enhancement
5+
6+
---
7+
8+
**Is your feature request related to a problem? Please describe.**
9+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
10+
11+
**Describe the solution you'd like**
12+
A clear and concise description of what you want to happen.
13+
14+
**Describe alternatives you've considered**
15+
A clear and concise description of any alternative solutions or features you've considered.
16+
17+
**Additional context**
18+
Add any other context or screenshots about the feature request here.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Set up AWS Credentials and Fetch Secrets"
2+
description: "Configures AWS credentials for use in subsequent steps. Fetches secrets from AWS Secrets Manager."
3+
4+
inputs:
5+
aws_role_to_assume:
6+
description: "ARN of the IAM role to assume"
7+
default: "arn:aws:iam::682033462621:role/spacecat-role-github-actions"
8+
required: true
9+
secret_ids:
10+
description: "List of secret IDs to fetch from AWS Secrets Manager"
11+
default: |
12+
/spacecat/github-actions
13+
required: true
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Configure AWS Credentials
19+
id: creds
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
aws-region: us-east-1
23+
role-to-assume: ${{ inputs.aws_role_to_assume }}
24+
25+
- name: Fetch AWS Secrets
26+
uses: aws-actions/aws-secretsmanager-get-secrets@v2
27+
with:
28+
parse-json-secrets: true
29+
secret-ids: ${{ inputs.secret_ids }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Lint, Test, and Coverage"
2+
description: "Runs lint and test commands, plus coverage"
3+
4+
inputs:
5+
codecov_token:
6+
description: "Codecov Token (optional)"
7+
required: false
8+
default: ""
9+
upload_coverage:
10+
description: "Whether to upload coverage to Codecov (true/false). Default false."
11+
required: false
12+
default: "false"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Lint
18+
run: npm run lint
19+
shell: bash
20+
21+
- name: Test
22+
run: npm run test
23+
shell: bash
24+
25+
- name: Upload coverage to Codecov
26+
if: ${{ inputs.upload_coverage == 'true' }}
27+
uses: codecov/codecov-action@v5
28+
with:
29+
token: ${{ inputs.codecov_token }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "Setup Node & NPM (with cache)"
2+
description: "Checks out code, sets up Node, uses NPM cache, installs dependencies"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Set up Node
8+
uses: actions/setup-node@v4
9+
with:
10+
node-version: 22.12
11+
12+
- name: Get npm cache directory
13+
id: npm-cache-dir
14+
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
15+
shell: bash
16+
17+
- name: Set up NPM Cache
18+
uses: actions/cache@v4
19+
id: npm-cache
20+
with:
21+
path: ${{ steps.npm-cache-dir.outputs.dir }}
22+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
23+
restore-keys: |
24+
${{ runner.os }}-node-
25+
26+
- name: Update NPM (only if cache miss)
27+
run: npm install -g npm@10.9.2
28+
shell: bash
29+
30+
- name: Install dependencies (only if cache miss)
31+
run: npm ci
32+
shell: bash

.github/pull_request_template.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Please ensure your pull request adheres to the following guidelines:
2+
- [ ] make sure to link the related issues in this description
3+
- [ ] when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes
4+
5+
## Related Issues
6+
7+
8+
Thanks for contributing!

.github/workflows/ci.yaml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Build
2+
3+
permissions:
4+
id-token: write
5+
contents: write
6+
issues: read
7+
8+
on: [push]
9+
10+
env:
11+
CI_BUILD_NUM: ${{ github.run_id }}
12+
CI_BRANCH: ${{ github.ref_name }}
13+
HLX_AWS_REGION: ${{ secrets.AWS_REGION }}
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out
19+
uses: actions/checkout@v4
20+
with:
21+
persist-credentials: 'false'
22+
- name: Setup Node & NPM
23+
uses: ./.github/actions/setup-node-npm
24+
25+
- name: Lint, Test, Coverage Upload
26+
uses: ./.github/actions/lint-test-coverage
27+
with:
28+
upload_coverage: "true"
29+
codecov_token: ${{ secrets.CODECOV_TOKEN }}
30+
31+
- name: Semantic Release (Dry Run)
32+
if: github.ref != 'refs/heads/main'
33+
run: npm run semantic-release-dry
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.ADOBE_BOT_GITHUB_TOKEN }}
36+
NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
37+
38+
- name: Print npm debug log if build fails
39+
if: failure()
40+
run: |
41+
if [ -f /home/runner/.npm/_logs/*.log ]; then
42+
echo "==== NPM DEBUG LOG ===="
43+
find /home/runner/.npm/_logs -name '*.log' -exec cat {} \;
44+
echo "==== END NPM DEBUG LOG ===="
45+
else
46+
echo "No npm debug log found."
47+
fi
48+
49+
- name: Clean npm cache
50+
run: npm cache clean --force
51+
52+
- name: Create empty cache directory
53+
run: mkdir -p /tmp/empty-cache
54+
55+
- name: Install dependencies
56+
run: npm ci --cache /tmp/empty-cache
57+
58+
semantic-release:
59+
runs-on: ubuntu-latest
60+
needs: build
61+
if: github.ref == 'refs/heads/main'
62+
steps:
63+
- name: Check out
64+
uses: actions/checkout@v4
65+
with:
66+
persist-credentials: 'false'
67+
68+
- name: Configure Environment
69+
run: echo -e "LOG_LEVEL=info\n" > .env
70+
71+
- name: Setup Node & NPM
72+
uses: ./.github/actions/setup-node-npm
73+
74+
- name: Configure AWS
75+
uses: ./.github/actions/configure-aws
76+
with:
77+
aws_role_to_assume: 'arn:aws:iam::${{secrets.AWS_ACCOUNT_ID_PROD}}:role/spacecat-role-github-actions'
78+
79+
- name: Semantic Release
80+
run: npm run semantic-release
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.ADOBE_BOT_GITHUB_TOKEN }}
83+
NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
84+
AWS_REGION: us-east-1
85+
AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID_PROD}}
86+
87+
deploy-stage:
88+
runs-on: ubuntu-latest
89+
needs: build
90+
if: github.ref == 'refs/heads/main'
91+
steps:
92+
- name: Check out
93+
uses: actions/checkout@v4
94+
with:
95+
persist-credentials: 'false'
96+
97+
- name: Setup Node & NPM
98+
uses: ./.github/actions/setup-node-npm
99+
100+
- name: Configure AWS for STAGE
101+
uses: ./.github/actions/configure-aws
102+
with:
103+
aws_role_to_assume: 'arn:aws:iam::${{secrets.AWS_ACCOUNT_ID_STAGE}}:role/spacecat-role-github-actions'
104+
105+
- name: Branch Deployment
106+
run: npm run deploy-stage
107+
env:
108+
AWS_REGION: us-east-1
109+
AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID_STAGE}}
110+
111+
112+
branch-deploy:
113+
runs-on: ubuntu-latest
114+
needs: build
115+
if: github.ref != 'refs/heads/main'
116+
steps:
117+
- name: Check out
118+
uses: actions/checkout@v4
119+
with:
120+
persist-credentials: 'false'
121+
122+
- name: Setup Node & NPM
123+
uses: ./.github/actions/setup-node-npm
124+
125+
- name: Configure AWS
126+
uses: ./.github/actions/configure-aws
127+
with:
128+
aws_role_to_assume: 'arn:aws:iam::${{secrets.AWS_ACCOUNT_ID_DEV}}:role/spacecat-role-github-actions'
129+
130+
- name: Branch Deployment
131+
run: npm run deploy-dev
132+
env:
133+
AWS_REGION: us-east-1
134+
AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID_DEV}}
135+
136+
- name: Post-Deployment Integration Test
137+
run: npm run test-postdeploy

0 commit comments

Comments
 (0)