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

Run lint and unit tests on Buildkite #17

Merged
merged 2 commits into from May 13, 2024

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Apr 24, 2024

Proposed Changes

As discussed internally, we should have a single CI system. Given we need Buildkite to code sign builds, Buildkite will be that system.

This PR duplicates the lint and unit tests steps to Buildkite. I didn't remove the GitHub actions one because it would be interesting to run the in tandem for a couple of days to see if there is any difference in behavior.

Testing Instructions

See https://buildkite.com/automattic/studio/builds/81 and notice it's green 😄

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors? — N.A.

@mokagio mokagio force-pushed the mokagio/migrate-gh-action-to-buildkite branch 8 times, most recently from 2b6c499 to 81a258b Compare April 24, 2024 07:46
Comment on lines +10 to +14
LOCAL_NPM_CACHE=./vendor/npm
mkdir -p $LOCAL_NPM_CACHE
echo "--- :npm: Set npm to use $LOCAL_NPM_CACHE for cache"
npm set cache $LOCAL_NPM_CACHE
echo "npm cache set to $(npm get cache)"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In setting this up, it seems like using a local cache works better than the default ($HOME/.npm).

I haven't gone back and did a fair comparison, but I got the impression that the _cacache subfolder was not extracted when using the local cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am no npm expert so I don't know all the available commands nor how it handles cache, nor what npm ci does that npm install wouldn't, but couldn't our install_npm_dependencies helper from ci-toolkit be of help here (instead of reinventing the wheel)?
And if not, could we maybe extend a8c-ci-toolkit to bring the things from this script that are not yet supported by our helper to be supported (either by the existing install_npm_packages helper, or by a new one)? 🤔

@mokagio mokagio changed the title Run unit tests on Buildkite Run lint and unit tests on Buildkite Apr 24, 2024
@mokagio mokagio mentioned this pull request Apr 26, 2024
1 task
Comment on lines +10 to +14
LOCAL_NPM_CACHE=./vendor/npm
mkdir -p $LOCAL_NPM_CACHE
echo "--- :npm: Set npm to use $LOCAL_NPM_CACHE for cache"
npm set cache $LOCAL_NPM_CACHE
echo "npm cache set to $(npm get cache)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I am no npm expert so I don't know all the available commands nor how it handles cache, nor what npm ci does that npm install wouldn't, but couldn't our install_npm_dependencies helper from ci-toolkit be of help here (instead of reinventing the wheel)?
And if not, could we maybe extend a8c-ci-toolkit to bring the things from this script that are not yet supported by our helper to be supported (either by the existing install_npm_packages helper, or by a new one)? 🤔

Comment on lines +31 to +42
npm ci \
--unsafe-perm \
--prefer-offline \
--no-audit \
--no-progress \
--maxsockets "$MAX_SOCKETS" \
"$@"

echo "--- :npm: Save cache if necessary"
# Notice that we don't cache the local node_modules.
# Those get regenerated by npm ci as per Node reccomendations.
# What we are caching is the root npm folder, which stores pacakge downloads so they are available if the package.json resolution demands them.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very interesting information. I wonder why we didn't go that route in https://github.com/Automattic/a8c-ci-toolkit-buildkite-plugin/blob/trunk/bin/install_npm_packages; might be worth updating that helper to make other apps using npm benefit from this?

@mokagio mokagio requested a review from a team May 9, 2024 02:37
@mokagio mokagio mentioned this pull request May 9, 2024
1 task
Copy link
Contributor

@wojtekn wojtekn left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for adding that.

@mokagio mokagio force-pushed the mokagio/migrate-gh-action-to-buildkite branch from ec49b5b to 497e700 Compare May 12, 2024 23:54
@mokagio mokagio merged commit 6619e75 into trunk May 13, 2024
12 checks passed
@mokagio mokagio deleted the mokagio/migrate-gh-action-to-buildkite branch May 13, 2024 00:18
mokagio added a commit that referenced this pull request May 16, 2024
In #17 ,
6619e75 , we duplicated the logic to
run unit tests and linters on Buildkite.

After running them side by side for a few days, no issues have been
reported.

It's now time to remove the GitHub Actions step.

See #99 and
#76 for the E2E counterpart.
wojtekn pushed a commit that referenced this pull request May 16, 2024
In #17 ,
6619e75 , we duplicated the logic to
run unit tests and linters on Buildkite.

After running them side by side for a few days, no issues have been
reported.

It's now time to remove the GitHub Actions step.

See #99 and
#76 for the E2E counterpart.
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.

None yet

3 participants