Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

Conversation

@quickliketurtle
Copy link
Member

No description provided.

Copy link
Member Author

@quickliketurtle quickliketurtle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FelipeD-FiveTalent Added comments here. Take a look and let me know if you have questions. Most are code organizations suggestions. Let me know if you need further info or if you want to work through it together.

stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-west-2'}
environment:
env: ${self:provider.stage}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is included by default in each function. no need to add explicitly.

serverless.yml Outdated
env: ${self:provider.stage}

functions:
tracker:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does the name tracker represent?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is tracking the workflow. Dont we need to have a name for the function? should we have a different name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you need a name, so my comment is related to it having a ligit meaning. As it's not actually tracking anything. This endpoint is listening to GitHub webhooks.

serverless.yml Outdated
- http:
path: tracker
method: post
cors: true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? I don't think cors is used since no browser is involved.

src/index.js Outdated
Comment on lines 52 to 54
const message = 'Done!!';

callback(null, createResponse(200, { message }));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shows up on github right? is there more useful information we can return? if a webhook is not processes we are still responding with done. Or if there are no commits to process, etc...

@@ -0,0 +1,27 @@
class ParseGithub {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's convert this to a regular function, Seams out of place to have a single Class with no internal functions.

return { Status: 'QA', Environment: 'Testing' };
}
if (branch === 'staging') {
return { Status: 'Passed - QA', Environment: 'Staging' };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this status needs to be 'CAT' not 'Passed - QA'.

src/index.js Outdated
Comment on lines 20 to 26
commits.forEach(commit => {
console.log('commit: ', commit);
const match5OrMoreDigits = /[0-9]{5,}/; // Prevents making request for merge #'s ie "Merge pull request #12...""
const idChecker = commit.message.match(match5OrMoreDigits);

if (idChecker) {
const id = idChecker[0];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we abstract this to a function with a descriptive name? What is it actually doing, is it getTaskIDs or validateTaskIds or validateCommitMessages?

src/index.js Outdated
Comment on lines 32 to 50
const url = `${LP_API_BASE_URL}/tasks/${id}`;
const postRequestData = {
task: {
custom_field_values: customFieldValues,
},
};
const postRequestConfig = { headers: { Authorization: `Bearer ${LP_API_TOKEN}` } };

axios
.put(url, postRequestData, postRequestConfig)
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
}
});
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be abstracted also, maybe create an LP API Helper that had an update task method?

runtime: nodejs12.x
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-west-2'}
environment:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme say to add 2 env vars to the function, but they are not defined here. Does that mean you are manually editing the deployed function in the console?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the answer is yes, but if there is a better way please let me know. I was thinking of doing param store but you also have to manually edit that on the console.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could create a config file to deploy those by stage. Or you can create an ssm parameter and reference that via the code.
It would be fine to create the parameter with serverless, but the value should be set manually. But that can be done in the cli also so no need to actually log into the AWS console to make changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants