-
Notifications
You must be signed in to change notification settings - Fork 2
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: Grab compare SHA for GH pre-merge commits #147
Changes from 8 commits
ed67122
75e1bfc
6f1ee34
f900b7e
e68b43b
9e0809b
4ebe7d7
c5d9902
8448dbc
319e880
5869b73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pnpm setup action version was upgraded from v2 to v4. Make sure this plugin's functionalities are unbroken by this change. |
||
with: | ||
version: 9 | ||
run_install: false | ||
|
@@ -62,12 +62,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
@@ -108,12 +108,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
@@ -154,12 +154,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
@@ -237,12 +237,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
@@ -288,12 +288,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HEAD_SHA and BASE_SHA were added as environment variables. Make sure they are being declared and correctly manipulated in the context. |
||
run_install: false | ||
|
@@ -326,6 +326,8 @@ jobs: | |
- name: Build ${{ matrix.example }} app for production | ||
working-directory: ./examples/${{ matrix.example }} | ||
env: | ||
HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} | ||
NEXT_API_URL: ${{ secrets.CODECOV_API_URL }} | ||
NUXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} | ||
|
@@ -358,12 +360,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
@@ -396,6 +398,8 @@ jobs: | |
- name: Build ${{ matrix.example }} app for staging | ||
working-directory: ./examples/${{ matrix.example }} | ||
env: | ||
HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} | ||
NEXT_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }} | ||
NUXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} | ||
|
@@ -436,12 +440,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
@@ -502,12 +506,12 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,11 @@ export default defineConfig({ | |
bundleName: "@codecov/example-rollup-app", | ||
apiUrl: process.env.ROLLUP_API_URL, | ||
uploadToken: process.env.ROLLUP_UPLOAD_TOKEN, | ||
debug: true, | ||
nicholas-codecov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uploadOverrides: { | ||
sha: process.env.HEAD_SHA, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding an uploadOverrides object with 'sha'/'compareSha' properties. Make sure this doesn't overlap or cause conflicts with existing functionality, and that the values are being correctly provided from the environment. |
||
compareSha: process.env.BASE_SHA, | ||
}, | ||
}), | ||
], | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,11 @@ | |
body[key] = encodeSlug(value); | ||
} | ||
|
||
// temporary removal for testing | ||
nicholas-codecov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (key === "compareSha") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 'compareSha' key is being temporarily removed for testing. If this code is intended for production, this deletion should not occur here. |
||
delete body[key]; | ||
} | ||
|
||
if (!value || value === "") { | ||
body[key] = null; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,43 @@ | |
return commit ?? ""; | ||
} | ||
|
||
function _getCompareSHA(inputs: ProviderUtilInputs, output: Output): string { | ||
const { args } = inputs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _getCompareSHA function is added. The complexity of the function could potentially be a point of failure, ensure it is adequately tested and performs as expected in various scenarios. |
||
if (args?.compareSha && args.compareSha !== "") { | ||
debug(`Using commit: ${args.compareSha}`, { enabled: output.debug }); | ||
return args.compareSha; | ||
} | ||
|
||
let compareSha = ""; | ||
const pr = _getPR(inputs); | ||
if (pr) { | ||
const mergeCommitRegex = /^[a-z0-9]{40} [a-z0-9]{40}$/; | ||
const mergeCommitMessage = runExternalProgram("git", [ | ||
"show", | ||
"--no-patch", | ||
"--format=%P", | ||
]); | ||
|
||
debug(`Merge commit message: ${mergeCommitMessage}`, { | ||
enabled: output.debug, | ||
}); | ||
|
||
if (mergeCommitRegex.exec(mergeCommitMessage)) { | ||
const splitMergeCommit = mergeCommitMessage.split(" "); | ||
|
||
debug(`Split commit message: ${splitMergeCommit}`, { | ||
enabled: output.debug, | ||
}); | ||
|
||
compareSha = splitMergeCommit?.[0] ? splitMergeCommit[0] : ""; | ||
} | ||
} | ||
|
||
debug(`Using compareSha: ${compareSha ?? ""}`, { enabled: output.debug }); | ||
|
||
return compareSha ?? ""; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a left-over style from the original Codecov Node uploader, tho we should probably adjust this. We do have a guard in the |
||
} | ||
|
||
function _getSlug(inputs: ProviderUtilInputs): string { | ||
const { args, envs } = inputs; | ||
if (args?.slug && args.slug !== "") { | ||
|
@@ -175,6 +212,7 @@ | |
build: _getBuild(inputs), | ||
buildURL: await _getBuildURL(inputs), | ||
commit: _getSHA(inputs, output), | ||
compareSha: _getCompareSHA(inputs, output), | ||
job: _getJob(inputs.envs), | ||
pr: _getPR(inputs), | ||
service: _getService(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node setup action version was upgraded from v3 to v4. Compatibility for all related plugins and actions with the newer version should be ensured.