Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bitbucket): add support for constructing pull_request payloads #23

Merged
merged 4 commits into from
Aug 24, 2023

Conversation

domharrington
Copy link
Member

@domharrington domharrington commented Aug 16, 2023

🧰 Changes

Add support for constructing pull_request payloads

TODO

  • Update action code samples on the README

🧬 QA & Testing

Do the tests pass? More thorough instructions incoming!

This is a more reliable place to look in the github payloads for the
organization slug.

Fixes: #22
@domharrington domharrington changed the title feat(bitbucket): add support for constructing pull_request payloads feat(bitbucket): add support for constructing pull_request payloads Aug 16, 2023
@domharrington domharrington marked this pull request as ready for review August 17, 2023 17:17
// https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-emctem
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
timestamp: new Date(
execSync('git show -s --format=%ct $BITBUCKET_COMMIT', {
Copy link
Contributor

Choose a reason for hiding this comment

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

should these be in UTC? if so: git show … --date=unix works

Copy link
Contributor

Choose a reason for hiding this comment

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

the timestamp for the head commit, not the last commit (ref, is what Micro should store?

git rev-parse origin/$BITBUCKET_PR_DESTINATION_BRANCH

...baseContext,
eventName,
payload: {
number: process.env.BITBUCKET_PR_ID,
Copy link
Contributor

Choose a reason for hiding this comment

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

how about parseInt'ing this - to keep the payload closer resembling to GH's?

the GH fixture pull_request.opened.json shows number: 2. it's a number in GH payloads, and a number in the Micro DB schema.

I wasn't entirely clear from PR #373 of how it's getting coerced, since I didn't see any changes to the pr object where number is assigned to data.payload.number

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's not a bad idea! I actually modified the json schema stuff in the backend to coerce types now, so it matters less. But probably a good idea to be as consistent as possible.

name: process.env.BITBUCKET_REPO_SLUG,
},
organization: {
login: process.env.BITBUCKET_WORKSPACE,
Copy link
Contributor

Choose a reason for hiding this comment

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

in the near future: should we be storing the workspace UUIDs and repo UUIDs for BB (and IDs for GH)?

lib/context.js Show resolved Hide resolved
lib/context.js Show resolved Hide resolved
lib/context.js Show resolved Hide resolved
README.md Show resolved Hide resolved
name: ReadMe Micro
image: node:18
script:
- npx @readme/micro@v2.4.0 '**/*.{yaml,yml,json}' --key=$README_MICRO_SECRET
Copy link
Contributor

Choose a reason for hiding this comment

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

could use conditions to run Micro only for this glob, but that'll add complexity when folks are integrating Micro into their bitbucket-pipelines.yml.

in an ideal world, this repo would have a Dockerfile, a pipe.yml, etc. so Bitbucket could use that Pipe, instead this getting converted to its own docker image before the Pipeline is run.

the number of lines needed for folks to plug in the Micro pipe in to their bitbucket-pipelines.yml file, but that can probably wait until we see Bitbucket customers requesting it.

@domharrington domharrington merged commit d2e6543 into main Aug 24, 2023
3 checks passed
@domharrington domharrington deleted the feature/bitbucket-pull-requests branch August 24, 2023 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants