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

build: fix make invocation in tools.yml #40890

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

Trott
Copy link
Member

@Trott Trott commented Nov 20, 2021

Be in the correct directory for make lint-md-rollup.

Refs: https://github.com/nodejs/node/runs/4270533399?check_suite_focus=true

@Trott Trott added the fast-track PRs that do not need to wait for 48 hours to land. label Nov 20, 2021
@github-actions
Copy link
Contributor

Fast-track has been requested by @Trott. Please 👍 to approve.

@nodejs-github-bot nodejs-github-bot added the meta Issues and PRs related to the general management of the project. label Nov 20, 2021
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

According to SC2103, we should rewrite:

cd tools/lint-md
NEW_VERSION=$(npm outdated --omit=dev --parseable | cut -d: -f4 | xargs)
if [ "$NEW_VERSION" != "" ]; then
  echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
  rm -rf package-lock.json node_modules && npm install --ignore-scripts
  cd ../..
  make lint-md-rollup
fi

into

NEW_VERSION=$(cd tools/lint-md && npm outdated --omit=dev --parseable | cut -d: -f4 | xargs)
if [ "$NEW_VERSION" != "" ]; then
  echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
  (cd tools/lint-md && rm -rf package-lock.json node_modules && npm install --ignore-scripts)
  make lint-md-rollup
fi

@Trott
Copy link
Member Author

Trott commented Nov 20, 2021

According to SC2103, we should rewrite:

For reasons I can get into if you want, I'm going with their other remediation suggestion which is to add || exit 1 after each of the cd commands.

@Trott
Copy link
Member Author

Trott commented Nov 20, 2021

According to SC2103, we should rewrite:

For reasons I can get into if you want, I'm going with their other remediation suggestion which is to add || exit 1 after each of the cd commands.

Thinking more about it and looking at the code, I don't think we should do either the subshell or the || exit. Here's why:

GitHub Actions run with set -eo pipefail which means that if any individual shell command fails (like cd foo), then the entire run fails.

Adding || exit to the cd commands but not the other commands raises more questions. (Why aren't we doing that on every single line? The answer is because it's not needed on any of the lines, including the cd lines.)

Using a subshell is similarly unnecessary and unwieldy. It's not bad with the code rewrite you have above, but with the fix for the bug I found, it gets confusing because we need to run npm ci before running npm outdated and without capturing the output of npm ci in NEW_VERSION. There are various ways to do that, but none of them are as readable as:

cd tools/lint-md
npm ci
NEW_VERSION=$(npm outdated --parseable | cut -d: -f4 | xargs)

@aduh95 What do you think?

Be in the correct directory for `make lint-md-rollup`.
@aduh95
Copy link
Contributor

aduh95 commented Nov 21, 2021

If we had been using subshells from the start, it would have been very hard to run make on the wrong directory, which is why I wanted to bring it up. If we are adding more
commands, it may not be worth it anymore, so let’s keep it the way it is.
I agree with you regarding the || exit trickery, my comment was specifically about subshells.

@Trott Trott added commit-queue Add this label to land a pull request using GitHub Actions. and removed fast-track PRs that do not need to wait for 48 hours to land. labels Nov 22, 2021
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 22, 2021
@nodejs-github-bot nodejs-github-bot merged commit bad6526 into nodejs:master Nov 22, 2021
@nodejs-github-bot
Copy link
Collaborator

Landed in bad6526

@Trott Trott deleted the tools-for-reals branch November 22, 2021 05:25
targos pushed a commit that referenced this pull request Nov 26, 2021
Be in the correct directory for `make lint-md-rollup`.

PR-URL: #40890
Refs: https://github.com/nodejs/node/runs/4270533399?check_suite_focus=true
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 30, 2022
Be in the correct directory for `make lint-md-rollup`.

PR-URL: #40890
Refs: https://github.com/nodejs/node/runs/4270533399?check_suite_focus=true
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this pull request Feb 1, 2022
Be in the correct directory for `make lint-md-rollup`.

PR-URL: #40890
Refs: https://github.com/nodejs/node/runs/4270533399?check_suite_focus=true
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@danielleadams danielleadams mentioned this pull request Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta Issues and PRs related to the general management of the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants