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: Prepare tooling for Gutenberg extensions in Jetpack #11639

Merged
merged 9 commits into from
Mar 25, 2019

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Mar 21, 2019

Adds files from Jetpack Gutenberg extensions folder (about to be merged in #11633) to ignore lists relevant for the packaged version of the plugin.

Changes proposed in this Pull Request:

  • SVN Ignores
  • CDN asset ignores
  • Ignores for release branches

Testing instructions:

Together with #11633 (git merge --squash --no-commit origin/add/jetpack-blocks-src) — does the build ignore assets in /extensions/* but still sees *.php files?

  • yarn build-production
  • php bin/build-asset-cdn-json.php

An alternative way of testing this would be to:

  • Checkout this branch.
  • Add the blocks src to: git merge --squash --no-commit origin/add/jetpack-blocks-src
  • Comment out this line so we can build a release branch from our current branch:
    git checkout master && git pull && git reset --hard origin/master

    You can apply this patch:
    https://gist.github.com/sirreal/2245987078998c2b6b9f95ba45d93d61#file-tooling-patch
  • Commit the changes (git add -A && git commit -am 'DROPME: testing changes')
  • Run tools/build-release-branch.sh -n
  • Pick a unique branch name.
  • Let the build happen for both branches (the release branch and the built branch)
  • Once the build is over, check the built branch
  • It should not include any of the block's source files.
  • the .gitignore should include the new lines.

Proposed changelog entry for your changes:

  • None

@sirreal sirreal requested a review from simison March 21, 2019 13:14
.gitattributes Outdated Show resolved Hide resolved
@simison simison added the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Mar 21, 2019
@simison simison requested review from simison and a team March 21, 2019 13:18
.svnignore Outdated Show resolved Hide resolved
@jeherve jeherve added [Type] Janitorial [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Mar 21, 2019
.svnignore Outdated
@@ -42,3 +42,4 @@ docker
bin/pre-commit-hook.js
bin/travis_install.sh
yarn-error.log
extensions/**/*.{js,jsx,json,gif,png,css,jpg,jpeg,sass,scss}
Copy link
Member

Choose a reason for hiding this comment

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

Copying over #11639 (comment) for visibility:

To help future groking, I'd love for svnignore comments (I believe # preceding the line should work here too) to explain why these files are ignored. Someone new to JP development may be confused why we're ignoring jpg, css, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

suggested by @dereksmart, could we do everything except php instead?

Copy link
Member

@simison simison Mar 21, 2019

Choose a reason for hiding this comment

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

See #11639 (comment):

I'd rather be explicit in svnignore as it can be really surprising. Something works great in GItHub and unless someone tests that explicit feature using a beta that was shipped in SVN we could have a pretty big gap in the production release.

Copy link
Member Author

Choose a reason for hiding this comment

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

svnignore is not a real thing. Under the hood, this is relying on shell globbing:

for file in $( cat "$TARGET_DIR/.svnignore" 2>/dev/null ); do
if [[ $file == "to-test.md" || $file == "docs/testing/testing-tips.md" ]]; then
continue
fi
rm -rf $TARGET_DIR/$file
done

We should be extremely careful and keep that in mind.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

I think we'll need to add the files here too:

# Add custom stuff to .gitignore release

.svnignore Outdated Show resolved Hide resolved
500 => 'modules/lazy-images/js/lazy-images.js',
501 => 'modules/wpgroho.js',
);
<?php
Copy link
Member

@simison simison Mar 22, 2019

Choose a reason for hiding this comment

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

@jeherve @kraftbj do we need to generate this file here or you'll do this during the build when packaging the release?

Copy link
Member

Choose a reason for hiding this comment

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

It's done automatically during the release process.

@simison simison marked this pull request as ready for review March 22, 2019 10:57
@jetpackbot
Copy link
Collaborator

jetpackbot commented Mar 22, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: April 2, 2019.
Scheduled code freeze: March 26, 2019

Generated by 🚫 dangerJS against ba75320

@sirreal sirreal changed the title Update/prep tooling for block src Build: Prepare tooling for Gutenberg extensions in Jetpack Mar 22, 2019
@sirreal sirreal requested review from simison and a team March 22, 2019 12:07
@ockham
Copy link
Contributor

ockham commented Mar 22, 2019

Testing instructions:

Together with #11633 — does the build ignore assets in /extensions/* but still sees *.php files?

  • yarn build-production
  • php bin/build-asset-cdn-json.php

Where do I check for presence of *.php files exactly? I opened modules/photon-cdn/jetpack-manifes.php, but that file doesn't reference any PHP files... 😬

@sirreal sirreal removed the request for review from simison March 22, 2019 14:05
echo "/extensions/**/*.sass" >> .gitignore
echo "/extensions/**/*.scss" >> .gitignore
echo "/extensions/**/*.svg" >> .gitignore
echo "__snapshots__/" >> .gitignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Late to the .gitignore party, but would a (semi-)whitelist-based approach (i.e. using negation) work? Something like

echo "/extensions/" >> .gitignore
echo "!/extensions/**/*.php" >> .gitignore

See e.g. https://www.atlassian.com/git/tutorials/saving-changes/gitignore#git-ignore-patterns

Copy link
Member Author

Choose a reason for hiding this comment

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

That would likely work, but would be harder to keep in sync with the .svnignore which is really a list of files to pass to rm -fr.

Copy link
Contributor

Choose a reason for hiding this comment

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

why we need a .svnignore again?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's used in several places around the build/deploy tooling:

for file in $( cat "$TARGET_DIR/.svnignore" 2>/dev/null ); do
if [[ $file == "to-test.md" || $file == "docs/testing/testing-tips.md" ]]; then
continue
fi
rm -rf $TARGET_DIR/$file
done

for file in $( cat "$DIR/.svnignore" 2>/dev/null ); do
# We want to commit changes to to-test.md as well as the testing tips.
if [[ $file == "to-test.md" || $file == "docs/testing/testing-tips.md" ]]
then
continue;
fi
rm -rf TMP_LOCAL_BUILT_VERSION/$file
done

for file in $( cat "$JETPACK_GIT_DIR/.svnignore" 2>/dev/null ); do
# We want to commit changes to to-test.md as well as the testing tips.
if [ $file == "to-test.md" || $file == "docs/testing/testing-tips.md" ]; then
continue;
fi
rm -rf $JETPACK_TMP_DIR_2/$file
done

for file in $( cat "$JETPACK_GIT_DIR/.svnignore" 2>/dev/null ); do
rm -rf $JETPACK_SVN_DIR/trunk/$file
done

Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but I wonder if we could de-dupe sources of truth (i.e. use .gitifnore where we're now using .svnignore) in the long run... 🤔


git rm -r --cached .
git add .
git commit -m ".gitignore cleanup"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make the commit msg more explicit here? Like Remove files based on .gitignore contents?

modify_svnignore

git rm -r --cached .
git add .
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this line? Not seeing anything added by that commit 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the logic here is

  • Remove everything
  • Add everything (respecting our new .gitignore)

This is the way we're able to filter out versioned files that are newly added to the gitignore.

ockham
ockham previously approved these changes Mar 25, 2019
Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Left a few minor (non-blocking) suggestions. Overall, this is looking great and working well AFAICT!

🚢 at will!

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

While this appears to work for now, I have some reservations about the latest changes; they can potentially be dangerous in that you can end up committing things you did not mean to.

tools/build-release-branch.sh Outdated Show resolved Hide resolved
tools/build-release-branch.sh Outdated Show resolved Hide resolved
@sirreal
Copy link
Member Author

sirreal commented Mar 25, 2019

I've added fdaeab9 and 327218f to address the latest review.

@sirreal sirreal requested a review from a team March 25, 2019 14:38
@kraftbj kraftbj added this to the 7.2 milestone Mar 25, 2019
@sirreal
Copy link
Member Author

sirreal commented Mar 25, 2019

After a call with @kraftbj and @dereksmart representing @Automattic/jetpack-crew, I've rolled back the changes that were intended to remove many files from extensions in release branches.

Part of the reasoning is that other unbuilt source is already included in release branches so including source in beta branches is not a regression and not something that needs to be addressed in this PR.

Thanks everyone, reviews appreciated 🙇

@sirreal sirreal requested review from a team and removed request for jeherve March 25, 2019 16:45
Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Seems to work as described and expected 👍

Copy link
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

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

I'm cautious about the additions in .svnignore and wanting to make sure they work as expected, so this will be an area of heavy testing in the next couple of days.

@kraftbj kraftbj added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Mar 25, 2019
@sirreal sirreal merged commit 0d14622 into master Mar 25, 2019
@ghost ghost removed the [Status] Ready to Merge Go ahead, you can push that green button! label Mar 25, 2019
@sirreal sirreal deleted the update/prep-tooling-for-block-src branch March 25, 2019 17:24
kraftbj added a commit that referenced this pull request Mar 26, 2019
kraftbj added a commit that referenced this pull request Mar 26, 2019
* Revert "Add source for Gutenberg extensions (#11633)"

This reverts commit a2bf967.

* Revert "Build: Prepare tooling for Gutenberg extensions in Jetpack (#11639)"

This reverts commit 0d14622.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Pri] High [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants