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

ci: replace commitlint action with our own implementation #1845

Merged
5 commits merged into from
Feb 9, 2024

Conversation

ghost
Copy link

@ghost ghost commented Feb 9, 2024

Summary:

Our usage of wagoid/commitlint-github-action@v5 is causing upgrade to commitlint 18.6.0 to fail (source: https://github.com/chanzuckerberg/edu-design-system/actions/runs/7847650438/job/21417042874?pr=1841). I'm updating the workflow to use own implementation that way we aren't held back from updating libraries.

https://czi-tech.atlassian.net/browse/EFI-1617

Test Plan:

  • Workflow lints 1 commit when only 1 commit is pushed.
  • Workflow lints >1 commits when >1 commits are pushed.

Copy link

github-actions bot commented Feb 9, 2024

size-limit report 📦

Path Size
components 98.03 KB (0%)
styles 39.81 KB (0%)

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (476ed0a) 92.50% compared to head (76061e3) 92.54%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1845      +/-   ##
==========================================
+ Coverage   92.50%   92.54%   +0.03%     
==========================================
  Files         147      147              
  Lines        2776     2776              
  Branches      750      750              
==========================================
+ Hits         2568     2569       +1     
+ Misses        207      206       -1     
  Partials        1        1              

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

@ghost ghost force-pushed the jclothier/commitlint branch from 5e9bf53 to ba1ceae Compare February 9, 2024 21:00
@ghost ghost force-pushed the jclothier/commitlint branch from 7516775 to 482069b Compare February 9, 2024 21:13
@ghost ghost self-requested a review February 9, 2024 21:18
Comment on lines +122 to +130
- name: Validate commits commitlint
# This workflow can also be triggered via "workflow_call".
# Since it's a push event we have access to these properties https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
if: github.event_name == 'push'
run: |
COMMIT_COUNT=$(echo '${{ toJSON(github.event.commits) }}' | jq length)
echo "Number of commits in the push: $COMMIT_COUNT"

yarn commitlint --from HEAD~$COMMIT_COUNT --to HEAD --verbose
Copy link
Author

Choose a reason for hiding this comment

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

Credit to https://commitlint.js.org/#/guides-ci-setup?id=github-actions but I adjusted code to account for multiple commits being pushed up at once. Instead of using HEAD~1 we use HEAD~$COMMIT_COUNT

@ghost ghost mentioned this pull request Feb 9, 2024
1 task
Copy link
Contributor

@booc0mtaco booc0mtaco left a comment

Choose a reason for hiding this comment

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

LGTM. should we not use this provided action across the board now? anyone else using that?

# Since it's a push event we have access to these properties https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
if: github.event_name == 'push'
run: |
COMMIT_COUNT=$(echo '${{ toJSON(github.event.commits) }}' | jq length)
Copy link
Contributor

Choose a reason for hiding this comment

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

How/where does jq get installed? Mostly out of curiousity...

Copy link
Author

Choose a reason for hiding this comment

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

Great question! Github runners (the github hosted virtual machines we run workflows on) come with a set of preinstalled software. This can be seen looking at the logs of the github action. Here's the link in the image below for reference https://github.com/actions/runner-images/blob/ubuntu22/20240204.1/images/ubuntu/Ubuntu2204-Readme.md

Screenshot 2024-02-09 at 3 12 15 PM

@ghost
Copy link
Author

ghost commented Feb 9, 2024

LGTM. should we not use this provided action across the board now? anyone else using that?

I didn't check that, good idea. It doesn't look like the commitlint github action is being used much in the org. Only 3 repos (this repo, 1 archived repo, 1 other)

@ghost ghost merged commit b4d3835 into next Feb 9, 2024
9 checks passed
@ghost ghost deleted the jclothier/commitlint branch February 9, 2024 23:32
This pull request was closed.
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.

1 participant