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: Grab compare SHA for GH pre-merge commits #147

Merged
merged 11 commits into from
Jul 19, 2024

Conversation

nicholas-codecov
Copy link
Collaborator

@nicholas-codecov nicholas-codecov commented Jul 4, 2024

Description

This PR updates the GitHubAction provider to grab the correct "compare SHA" for GH PRs and send it along to the API. This value has also been added to the upload override options so the user can override the value in their bundler config if they wish to do so.

Notable Changes

  • Add compareSha to normalizeOptions
  • Update types
  • Update GitHubActions provider utils
  • Update examples to have debug set to true
  • Small fixes to CI action versions

Copy link

@codecov codecov bot left a comment

Choose a reason for hiding this comment

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

Overall, the largest issue is the consistent usage of debug mode throughout the code. Additionally, the use of the compareSHA is unclear and potentially not working as expected. Testing coverage for the added functional code appears robust.

examples/next-js/next.config.js Show resolved Hide resolved
examples/nuxt/nuxt.config.ts Show resolved Hide resolved
examples/remix/vite.config.ts Show resolved Hide resolved
examples/rollup/rollup.config.js Show resolved Hide resolved
examples/sveltekit/vite.config.ts Show resolved Hide resolved
examples/vite/vite.config.ts Show resolved Hide resolved
examples/webpack/webpack.config.js Show resolved Hide resolved
packages/bundler-plugin-core/src/types.ts Show resolved Hide resolved
packages/bundler-plugin-core/src/utils/preProcessBody.ts Outdated Show resolved Hide resolved
@codecov-notifications
Copy link

codecov-notifications bot commented Jul 4, 2024

Codecov Report

Attention: Patch coverage is 93.02326% with 3 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files Patch % Lines
...r-plugin-core/src/utils/providers/GitHubActions.ts 92.10% 3 Missing ⚠️
Components Coverage Δ
Plugin core 97.28% <93.02%> (-0.06%) ⬇️
Rollup plugin 10.81% <ø> (ø)
Vite plugin 11.02% <ø> (ø)
Webpack plugin 25.14% <ø> (ø)

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Jul 4, 2024

Codecov Report

Attention: Patch coverage is 93.02326% with 3 lines in your changes missing coverage. Please review.

Project coverage is 76.73%. Comparing base (2df4d02) to head (5869b73).

✅ All tests successful. No failed tests found.

Files Patch % Lines
...r-plugin-core/src/utils/providers/GitHubActions.ts 92.10% 3 Missing ⚠️
Additional details and impacted files
Components Coverage Δ
Plugin core 97.28% <93.02%> (-0.06%) ⬇️
Rollup plugin 10.81% <ø> (ø)
Vite plugin 11.02% <ø> (ø)
Webpack plugin 25.14% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@codecov codecov bot left a comment

Choose a reason for hiding this comment

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

CodecovAI submitted a new review for c5d9902

@@ -22,12 +22,12 @@ jobs:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
Copy link

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.

with:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
Copy link

Choose a reason for hiding this comment

The 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:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 9
Copy link

Choose a reason for hiding this comment

The 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.

@@ -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,
uploadOverrides: {
sha: process.env.HEAD_SHA,
Copy link

Choose a reason for hiding this comment

The 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.

@@ -10,6 +10,11 @@
body[key] = encodeSlug(value);
}

// temporary removal for testing
if (key === "compareSha") {
Copy link

Choose a reason for hiding this comment

The 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.

@@ -158,6 +158,43 @@
return commit ?? "";
}

function _getCompareSHA(inputs: ProviderUtilInputs, output: Output): string {
const { args } = inputs;
Copy link

Choose a reason for hiding this comment

The 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.

@codecov-staging
Copy link

codecov-staging bot commented Jul 4, 2024

Bundle Report

Changes will increase total bundle size by 533.98kB ⬆️

Bundle name Size Change
@codecov/nuxt-plugin-cjs 1.41kB 0 bytes
@codecov/webpack-plugin-esm 1.44kB 0 bytes
@codecov/sveltekit-plugin-cjs 1.33kB 0 bytes
@codecov/bundler-plugin-core-esm 8.2kB 30.02kB ⬇️
@codecov/sveltekit-plugin-esm 1.1kB 188 bytes ⬆️
@codecov/remix-vite-plugin-esm 975 bytes 0 bytes
@codecov/rollup-plugin-cjs 2.82kB 0 bytes
@codecov/rollup-plugin-esm 1.32kB 1.01kB ⬇️
@codecov/example-webpack-app-array-push 71.19kB 0 bytes
@codecov/example-next-app-edge-server-array-push 354 bytes 0 bytes
@codecov/example-next-app-client-array-push 907.85kB 907.85kB ⬆️
@codecov/nuxt-plugin-esm 855 bytes 0 bytes
@codecov/vite-plugin-cjs 2.8kB 0 bytes
@codecov/vite-plugin-esm 1.26kB 0 bytes
@codecov/webpack-plugin-cjs 3.77kB 0 bytes
@codecov/bundler-plugin-core-cjs 43.32kB 611 bytes ⬆️
@codecov/example-rollup-app-iife 95.46kB 0 bytes
@codecov/example-vite-app-esm 150.61kB 0 bytes
@codecov/remix-vite-plugin-cjs (removed) 1.32kB ⬇️
@codecov/example-next-app-server-cjs (removed) 342.32kB ⬇️

Copy link

codecov bot commented Jul 4, 2024

Bundle Report

Changes will increase total bundle size by 968.29kB ⬆️

Bundle name Size Change
@codecov/nuxt-plugin-cjs 1.41kB 1.41kB ⬆️
@codecov/nuxt-plugin-esm 855 bytes 0 bytes
@codecov/remix-vite-plugin-cjs 1.32kB 1.32kB ⬆️
@codecov/remix-vite-plugin-esm 975 bytes 0 bytes
@codecov/example-remix-app-client-esm 252.12kB 252.12kB ⬆️
@codecov/example-remix-app-server-esm 12.55kB 0 bytes
@codecov/vite-plugin-cjs 2.8kB 2.8kB ⬆️
@codecov/vite-plugin-esm 1.26kB 1.26kB ⬆️
@codecov/webpack-plugin-cjs 3.77kB 0 bytes
@codecov/rollup-plugin-cjs 2.82kB 0 bytes
@codecov/webpack-plugin-esm 1.44kB 1.62kB ⬇️
@codecov/rollup-plugin-esm 1.32kB 1.01kB ⬇️
@codecov/sveltekit-plugin-cjs 1.33kB 0 bytes
@codecov/sveltekit-plugin-esm 909 bytes 909 bytes ⬆️
@codecov/example-rollup-app-iife 95.46kB 95.46kB ⬆️
@codecov/bundler-plugin-core-cjs 43.32kB 43.32kB ⬆️
@codecov/bundler-plugin-core-esm 8.2kB 8.2kB ⬆️
@codecov/example-sveltekit-app-client-esm 714.6kB 2 bytes ⬇️
@codecov/example-sveltekit-app-server-esm 974.58kB 1 bytes ⬇️
@codecov/example-vite-app-esm 150.61kB 150.61kB ⬆️
@codecov/example-webpack-app-array-push 71.19kB 71.19kB ⬆️
@codecov/example-nuxt-app-client-esm 237.66kB 0 bytes
@codecov/example-nuxt-app-server-esm 347.95kB 0 bytes
@codecov/example-next-app-server-cjs 342.32kB 342.32kB ⬆️
@codecov/example-next-app-edge-server-array-push 354 bytes 0 bytes
@codecov/example-next-app-client-array-push 907.85kB 0 bytes

@nicholas-codecov nicholas-codecov marked this pull request as ready for review July 16, 2024 13:45

debug(`Using compareSha: ${compareSha ?? ""}`, { enabled: output.debug });

return compareSha ?? "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we return null or undefined if compareSha is not set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 preProcessBody that does handle this for us. Tho we should probably update this overall to just return null.

@nicholas-codecov nicholas-codecov merged commit 42bf08e into main Jul 19, 2024
41 checks passed
@nicholas-codecov nicholas-codecov deleted the feat-grab-compare-sha-for-pre-merge-commits branch July 19, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants