Skip to content

Commit

Permalink
🏗 Update AMP's CI config to work on the main branch (ampproject#33698
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha authored and rochapablo committed Aug 30, 2021
1 parent 45f59fd commit 702fa76
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 29 deletions.
18 changes: 9 additions & 9 deletions .circleci/check_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ RED() { echo -e "\n\033[0;31m$1\033[0m"; }
YELLOW() { echo -e "\033[0;33m$1\033[0m"; }
CYAN() { echo -e "\033[0;36m$1\033[0m"; }

# Push builds are only run against master and amp-release branches.
if [[ "$CIRCLE_BRANCH" == "master" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
# Push builds are only run against the main branch and amp-release branches.
if [[ "$CIRCLE_BRANCH" == "main" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
echo $(GREEN "Nothing to do because $CIRCLE_BRANCH is not a PR branch.")
exit 0
fi

# Check if the PR branch contains the most recent revision the CircleCI config.
CONFIG_REV=`git rev-list master -1 -- .circleci/config.yml`
CONFIG_REV=`git rev-list main -1 -- .circleci/config.yml`
(set -x && git merge-base --is-ancestor $CONFIG_REV $CIRCLE_SHA1) || err=$?

if [[ "$err" -ne "0" ]]; then
Expand All @@ -46,23 +46,23 @@ if [[ "$err" -ne "0" ]]; then
echo " ⤷ It can be found towards the bottom of the PR, after the list of checks."
echo -e "\n"

echo "2. Pull the latest commits from $(CYAN "master") and re-push the PR branch."
echo "2. Pull the latest commits from $(CYAN "main") and re-push the PR branch."
echo " ⤷ Follow these steps:"
echo ""
echo " $(CYAN "git checkout master")"
echo " $(CYAN "git checkout main")"
echo " $(CYAN "git pull")"
echo " $(CYAN "git checkout <PR branch>")"
echo " $(CYAN "git merge master")"
echo " $(CYAN "git merge main")"
echo " $(CYAN "git push origin")"
echo -e "\n"

echo "3. Rebase on $(CYAN "master") and re-push the PR branch."
echo "3. Rebase on $(CYAN "main") and re-push the PR branch."
echo " ⤷ Follow these steps:"
echo ""
echo " $(CYAN "git checkout master")"
echo " $(CYAN "git checkout main")"
echo " $(CYAN "git pull")"
echo " $(CYAN "git checkout <PR branch>")"
echo " $(CYAN "git rebase master")"
echo " $(CYAN "git rebase main")"
echo " $(CYAN "git push origin --force")"
echo -e "\n"
exit 1
Expand Down
6 changes: 3 additions & 3 deletions .circleci/compute_merge_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ err=0
GREEN() { echo -e "\n\033[0;32m$1\033[0m"; }

# Try to determine the PR number.
curl -sS https://raw.githubusercontent.com/ampproject/amphtml/master/.circleci/get_pr_number.sh | bash
curl -sS https://raw.githubusercontent.com/ampproject/amphtml/main/.circleci/get_pr_number.sh | bash
if [[ -f "$BASH_ENV" ]]; then
source $BASH_ENV
fi
Expand All @@ -34,8 +34,8 @@ if [[ -z "$PR_NUMBER" ]]; then
fi

# GitHub provides refs/pull/<PR_NUMBER>/merge, an up-to-date merge branch for
# every PR branch that can be cleanly merged to master. For more details, see:
# https://discuss.circleci.com/t/show-test-results-for-prospective-merge-of-a-github-pr/1662
# every PR branch that can be cleanly merged to the main branch. For more
# details, see: https://discuss.circleci.com/t/show-test-results-for-prospective-merge-of-a-github-pr/1662
MERGE_BRANCH="refs/pull/$PR_NUMBER/merge"
echo $(GREEN "Computing merge SHA of $MERGE_BRANCH...")
CIRCLE_MERGE_SHA="$(git ls-remote https://github.com/ampproject/amphtml.git "$MERGE_BRANCH" | awk '{print $1}')"
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ push_builds_only: &push_builds_only
filters:
branches:
only:
- master
- main
- /^amp-release-.*$/

executors:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
steps:
- run:
name: 'Compute Merge Commit'
command: curl -sS https://raw.githubusercontent.com/ampproject/amphtml/master/.circleci/compute_merge_commit.sh | bash
command: curl -sS https://raw.githubusercontent.com/ampproject/amphtml/main/.circleci/compute_merge_commit.sh | bash
- save_merge_commit
'Checks':
executor:
Expand Down
2 changes: 1 addition & 1 deletion .circleci/fail_fast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ YELLOW() { echo -e "\n\033[0;33m$1\033[0m"; }
# For push builds, continue in spite of failures so that other jobs like
# bundle-size and visual-diff can establish their baselines for this commit.
# Without this, our custom bots will not be able to function correctly.
if [[ "$CIRCLE_BRANCH" == "master" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
if [[ "$CIRCLE_BRANCH" == "main" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
echo $(YELLOW "Not canceling build in spite of failures because $CIRCLE_BRANCH is not a PR branch.")
exit 0
fi
Expand Down
8 changes: 4 additions & 4 deletions .circleci/fetch_merge_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the license.

# This script fetches the merge commit of a PR branch with master to make sure
# PRs are tested against all the latest changes on CircleCI.
# This script fetches the merge commit of a PR branch with the main branch to
# make sure PRs are tested against all the latest changes on CircleCI.

set -e
err=0
Expand Down Expand Up @@ -51,9 +51,9 @@ echo $(GREEN "Fetching merge commit $CIRCLECI_MERGE_COMMIT...")
# If a clean merge is not possible, do not proceed with the build. GitHub's UI
# will show an error indicating there was a merge conflict.
if [[ "$err" -ne "0" ]]; then
echo $(RED "Detected a merge conflict between $CIRCLE_BRANCH and master.")
echo $(RED "Detected a merge conflict between $CIRCLE_BRANCH and the main branch.")
echo $(RED "Please rebase your PR branch.")
exit $err
fi

echo $(GREEN "Successfully fetched merge commit of $CIRCLE_BRANCH with master.")
echo $(GREEN "Successfully fetched merge commit of $CIRCLE_BRANCH with the main branch.")
4 changes: 2 additions & 2 deletions .circleci/get_pr_number.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ err=0
GREEN() { echo -e "\n\033[0;32m$1\033[0m"; }
YELLOW() { echo -e "\n\033[0;33m$1\033[0m"; }

# Push builds are only run against master and amp-release branches.
if [[ "$CIRCLE_BRANCH" == "master" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
# Push builds are only run against the main branch and amp-release branches.
if [[ "$CIRCLE_BRANCH" == "main" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
echo $(GREEN "Nothing to do because $CIRCLE_BRANCH is not a PR branch.")
# Warn if the build is linked to a PR on a different repo (known CircleCI bug).
if [[ -n "$CIRCLE_PULL_REQUEST" && ! "$CIRCLE_PULL_REQUEST" =~ ^https://github.com/ampproject/amphtml* ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-design-review-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
steps:
- name: Create Design Review Issue
run: |
wget -q -O - "https://raw.githubusercontent.com/$GITHUB_REPOSITORY/master/.github/workflows/create-design-review-issue.js" | node
wget -q -O - "https://raw.githubusercontent.com/ampproject/amphtml/main/.github/workflows/create-design-review-issue.js" | node
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/cross-browser-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: GitHub Actions
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"<details>",
"<summary>How to resolve breaking changes</summary>",
"This PR may introduce breaking changes that require manual intervention. In such cases, you will need to check out this branch, fix the cause of the breakage, and commit the fix to ensure a green CI build. To check out and update this PR, follow the steps below:",
"```sh\n# Check out the PR branch (these steps are from GitHub)\ngit checkout -b renovate-bot-{{{branchName}}} master\ngit pull https://github.com/renovate-bot/amphtml.git {{{branchName}}}\n\n# Directly make fixes and commit them\namp lint --fix # For lint errors in JS files\namp prettify --fix # For prettier errors in non-JS files\n# Edit source code in case of new compiler warnings / errors\n\n# Push the changes to the branch\ngit push git@github.com:renovate-bot/amphtml.git renovate-bot-{{{branchName}}}:{{{branchName}}}\n```",
"```sh\n# Check out the PR branch (these steps are from GitHub)\ngit checkout -b renovate-bot-{{{branchName}}} main\ngit pull https://github.com/renovate-bot/amphtml.git {{{branchName}}}\n\n# Directly make fixes and commit them\namp lint --fix # For lint errors in JS files\namp prettify --fix # For prettier errors in non-JS files\n# Edit source code in case of new compiler warnings / errors\n\n# Push the changes to the branch\ngit push git@github.com:renovate-bot/amphtml.git renovate-bot-{{{branchName}}}:{{{branchName}}}\n```",
"</details>"
],

Expand Down
5 changes: 2 additions & 3 deletions build-system/common/main-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
*/

/**
* TODO(rsimha, #32195): Change this to main when branch is renamed, and delete
* this file once the dust settles.
* TODO(rsimha, #32195): Delete this file once the dust settles.
*/
const mainBranch = 'master';
const mainBranch = 'main';

module.exports = {
mainBranch,
Expand Down
2 changes: 1 addition & 1 deletion build-system/server/app-index/header-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = [
{
'name': 'CircleCI',
'href':
'https://app.circleci.com/pipelines/github/ampproject/amphtml?branch=master',
'https://app.circleci.com/pipelines/github/ampproject/amphtml?branch=main',
},
{
'name': 'Percy',
Expand Down

0 comments on commit 702fa76

Please sign in to comment.