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

🏗 Replace gulp with the amp task runner #33315

Merged
merged 11 commits into from
Mar 18, 2021
Merged

🏗 Replace gulp with the amp task runner #33315

merged 11 commits into from
Mar 18, 2021

Conversation

rsimha
Copy link
Contributor

@rsimha rsimha commented Mar 17, 2021

This PR replaces gulp with a lightweight task runner with a single-file implementation.

PR highlights:

  • Introduce a new amp task runner based on the commander CLI interface
  • Remove gulpfile.js and uninstall gulp from the root package.json
  • Create identical amp equivalents for all existing gulp commands
  • Create a wrapper called gulp that redirects to amp after printing a deprecation notice
  • Update the codebase and replace references to gulp commands with their amp equivalents

Notes:

  • Backwards compatibility is maintained: existing gulp commands will continue to work via the amp task runner
  • No extra installation steps required (sync repo, run npm install, and carry on)

Reasons behind the choice of commander:

  • The most popular NodeJS compatible CLI solution (50M downloads / week)
  • Flexible in how tasks are defined / configured / run
  • High degree of compatibility with the existing UX of AMP's gulp-based dev tools
  • Built-in support for task discovery and usage help (via auto-generated --help)
  • Package has a tiny footprint (60KB) compared to gulp (multiple MB + dependencies)
  • Task start-up is near instant compared to gulp

Screenshots:

New interface: amp

image

Deprecation notice: gulp

image

Top-level help: amp --help

image

Task-level help: amp dist --help

image

Unknown task: amp foo

image

Invalid invocation: amp lint --foo --bar

image

First-time install with global gulp-cli: npm i

image

First-time install without global gulp-cli: npm i

image

Subsequent install: npm i

image

Fixes #32585

@rsimha rsimha self-assigned this Mar 17, 2021
@rsimha rsimha marked this pull request as ready for review March 17, 2021 17:14
@amp-owners-bot
Copy link

amp-owners-bot bot commented Mar 17, 2021

Hey @danielrozenberg! These files were changed:

build-system/compile/internal-version.js
build-system/tasks/visual-diff/index.js
build-system/tasks/visual-diff/package-lock.json
build-system/tasks/visual-diff/package.json

Hey @alanorozco! These files were changed:

build-system/server/app-index/settings.js
build-system/tasks/markdown-toc/README.md
build-system/tasks/markdown-toc/index.js
build-system/tasks/markdown-toc/test/all-are-complete/allows-paragraph-after-list.md
build-system/tasks/markdown-toc/test/all-are-complete/arbitrary-header-indentation.md
build-system/tasks/markdown-toc/test/all-are-complete/complete.md
build-system/tasks/markdown-toc/test/all-are-complete/ignores-unparsable-options.md
build-system/tasks/markdown-toc/test/all-are-complete/uses-options.md
build-system/tasks/markdown-toc/test/some-are-incomplete/complete.md
build-system/tasks/markdown-toc/test/some-are-incomplete/incomplete.md
build-system/tasks/storybook/index.js
build-system/tasks/storybook/package-lock.json
+1 more

Hey @estherkim! These files were changed:

build-system/tasks/e2e/DEBUGGING.md
build-system/tasks/e2e/README.md
build-system/tasks/e2e/index.js
build-system/tasks/e2e/package-lock.json
build-system/tasks/e2e/package.json
build-system/tasks/e2e/repl.js

Hey @gmajoulet, @processprocess, @t0mg! These files were changed:

extensions/amp-story-360/0.1/amp-story-360.js

Hey @Enriqe! These files were changed:

src/amp-story-player/README.md

Hey @ampproject/wg-caching! These files were changed:

validator/js/engine/validator_test.js

@rsimha
Copy link
Contributor Author

rsimha commented Mar 17, 2021

This PR is ready for preliminary review while I iron out any issues found during CI.

Reviewer notes:

  • The meat of this PR lies in the commit titled "Replace gulp with the amp task runner"
  • The majority of the remaining changes merely replace the word gulp with amp in JS files and docs
  • Adding infra team members for full review of that commit + skim through everything else
  • Adding non-infra folks for general comment on the new interface

build-system/tasks/amp-task-runner.js Outdated Show resolved Hide resolved
build-system/tasks/amp-task-runner.js Outdated Show resolved Hide resolved
build-system/tasks/amp-task-runner.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@samouri
Copy link
Member

samouri commented Mar 17, 2021

Is there any difference in speed?

Copy link
Contributor

@honeybadgerdontcare honeybadgerdontcare left a comment

Choose a reason for hiding this comment

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

Approved for validator. There's a couple of internal docs that I'll update once this is merged.

Also second Daniel's comment, can we remove gulp as a required install? If so I'll update our new dev docs internally.

build-system/tasks/amp-task-runner.js Outdated Show resolved Hide resolved
build-system/tasks/amp-task-runner.js Outdated Show resolved Hide resolved
@rsimha
Copy link
Contributor Author

rsimha commented Mar 17, 2021

Is there any difference in speed?

With amp, startup while invoking a task is near instant. With gulp, it would take ~1s before there was any output. Not a huge difference to longer running tasks, but short ones like clean now run in under 20ms.

image

Also second Daniel's comment, can we remove gulp as a required install? If so I'll update our new dev docs internally.

The idea of this PR is to no longer require the gulp library for AMP development. Daniel's comment called out the fact that I am forcibly replacing the global gulp-cli with our redirection wrapper. I'm going to attempt to find a less invasive way of doing this.

Copy link
Collaborator

@estherkim estherkim left a comment

Choose a reason for hiding this comment

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

Awesome! Some nits.

contributing/contributing-code.md Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
Copy link
Contributor

@kristoferbaxter kristoferbaxter left a comment

Choose a reason for hiding this comment

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

install-task-runner.js appears to have resolved my concern from earlier.

Nice work Raghu!

@rsimha
Copy link
Contributor Author

rsimha commented Mar 18, 2021

All CI jobs are green, and I've re-tested the transition paths with and without global installs of gulp-cli and gulp. I'm going to merge this (🤞) and send out a PSA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modernize AMP’s development tasks
8 participants