godaddy-wordpress / sake

Our internal build tool for WP/WC plugins
MIT License
4 stars 0 forks source link

Remove hardcoded references to SkyVerge #62

Closed wvega closed 3 years ago

wvega commented 3 years ago

Summary

⚠️ Please don't merge after approving. We need to update the wiki to account for these changes.

This PR updates saké to remove hardcoded references to SkyVerge on various tasks. Specifically:

  1. Removes SkyVerge as the default SVN username
  2. Replaces the DROPBOX_PATH environment variable with SAKE_PRE_RELEASE_PATH
  3. Makes WP_SVN_USER environment variable required for deploy if deploy type is wp
  4. Makes SAKE_PRE_RELEASE_PATH environment variable required for deploy
  5. Removes wc-plugins-sales-docs as the default docs repo
  6. Does not offer to create a docs issue unless the docs repository is specified using the DEPLOY_DOCS environment variable or providing the repo owner and repo slug through config.deploy.docs configuration entry
  7. Removes skyverge as the default repo owner in github:create_release task

Additionally, this PR updates the get getGithub() helper function to use different instances of the client based on the task being performed: dev, docs, or production. The function continues to use the value of the GITHUB_API_KEY environment variable as the personal access by default, but now it can be overridden in specific cases using the SAKE_DEV_GITHUB_API_KEY, SAKE_DOCS_GITHUB_API_KEY, and SAKE_PRODUCTION_GITHUB_API_KEY.

The new environment variables should allow us to use a different personal access token to create releases on the new plugin repos and on the mirror repos while running the deploy task.

These modifications to remove the hardcoded references can be considered braking changes because they require extra environment variables to be defined in order to continue using sake as before. However, I think we can't avoid having to define extra environment variables to be able to use different personal access tokens to create releases in repos from different organizations, so extra cost from the changes to remove the references is small. No changes to existing configuration files should be required.

Story: CH 72087

QA

Setup

  1. cd into the sake repository, checkout this branch and run npm link to make the sake binary from this branch globally available
  2. Ensure GITHUB_API_KEY has a personal access token with permissions to access the repositories in the gdcorp-partners organization
  3. Define environment variable WP_SVN_USER with SkyVerge as the value
  4. Define environment variable DEPLOY_DOCS with skyverge/wc-plugins-sales-docs as the value
  5. Define environment variable SAKE_PRE_RELEASE_PATH with ${DROPBOX_PATH}/skyverge-prereleases/ as the value
  6. Define environment variable SAKE_PRODUCTION_GITHUB_API_KEY with a personal access token with permissions to create releases on WooCommerce mirror repos as the value

Code Review

Test WC deploy

  1. Create a fork of WooCommerce Cybersource Gateway (development repo)
  2. Create a fork of the mirror repo for WooCommerce Cybersource Gateway (production repo)
  3. Clone the development repo (If you get an error see the SSH/Git Configuration section at the bottom)
  4. Update sake.config.js as follows, replacing the Git URL for the forked production repo:
module.exports = {
    deploy: {
        production: '{Git URL}'
    },
    framework: 'v5',
    autoload: true
}
  1. Commit the changes to sake.config.js
  2. Prepare the plugin for deploy (bump the development version) and commit the changes
  3. Run sake deploy (instead of npx sake deploy) to deploy a new version of the plugin but don't upload the plugin to WC.com (answer N to the prompt)
    • [x] The tasks are completed without errors
    • [x] A release was created in the development repo
    • [x] A release was created in the production repo

Test WP deploy

  1. Create a fork of WooCommerce Customizer (development repo)
  2. Create a local SVN repository to be used as the production repo
  3. Clone the development repo
  4. Update sake.config.js as follows, replacing the path to the SVN repo:
    module.exports = {
    clubhouse: 14031,
    deploy: {
        type: 'wp',
        production: 'file:///path/to/repo'
    },
    framework: false
    }
  5. Commit the changes to sake.config.js
  6. Prepare the plugin for deploy (bump the development version) and commit the changes
  7. Run export SAKE_DEV_GITHUB_API_KEY={token} where {token} is a personal access token with permission to update repositories in the SkyVerge organization. Most likely the same token used for SAKE_PRODUCTION_GITHUB_API_KEY is going to work here. This step is necessary because the development repo belongs to an organization that cannot be accessed using the default GITHUB_API_KEY
  8. Run sake deploy (instead of npx sake deploy) to deploy a new version of the plugin
    • [x] The tasks are completed without errors
    • [x] A release was created in the development repo
    • [x] Changes were committed to the local SVN repo

SSH/Git configuration

You may need to update your SSH/Git configuration to work with repos that belong to your GoDaddy account.

I'm using the configuration described in https://gist.github.com/wvega-godaddy/51f74951a6d0af85d40f22a220cd0e83 and had to update my ~/.gitconfig file to add:

[url "git@github-godaddy:wvega-godaddy"]
    insteadOf = git@github.com:wvega-godaddy

Before merge

wvega commented 3 years ago

Thank you for reviewing @ChaseWiseman. I updated the wiki to account for these changes and I'm going to merge now.