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

Make locales extraction script work with and without token #14049

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions scripts/travis-extract-l10n.sh → scripts/extract-l10n.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# - Update your code
# - Extract new strings and push to the .po files
#
# If you're running the script manually please make sure to expose
# For the fully automated experience make sure to expose
# the following variables to the environment:
# - GITHUB_TOKEN (to the github token of addons-robot,
# talk to tofumatt or cgrebs)
# talk to @diox or @muffinresearch)
# - TRAVIS_REPO_SLUG="mozilla/addons-server"
Copy link
Member

Choose a reason for hiding this comment

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

Can't we provide this as a default in the file?

Copy link
Member Author

Choose a reason for hiding this comment

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

As TRAVIS_BRANCH this is automatically present in travis

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking for local use so we don't have to define extra variables to make it run.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'll make sure no variables are needed for manual usage

# - TRAVIS_BRANCH="master"
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't appear to be used at all (despite the erroring if it's not set).

Copy link
Member Author

Choose a reason for hiding this comment

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

This is purely if used in travis to make sure it's not running against branches other than master

Copy link
Member

Choose a reason for hiding this comment

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

okay, that makes sense.


Copy link
Member

Choose a reason for hiding this comment

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

In init_environment it does git checkout master which depends on you having an up-to-date local master. Can we just git checkout upstream/master instead? (Even better if we can always checkout from the repo in TRAVIS_REPO_SLUG)

Copy link
Member Author

Choose a reason for hiding this comment

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

mmm in the case of travis, upstream doesn't exist as the remote... I'm going to try to steal some logic from https://github.com/mozilla/addons-frontend/blob/master/bin/run-l10n-extraction for this, pulling from the remote directly.

Expand Down Expand Up @@ -72,9 +72,11 @@ function extract_locales {
echo "done."
}


function commit_and_push {
function git_commit {
git commit -m "$MESSAGE" --author "$ROBOT_NAME <$ROBOT_EMAIL>" --no-gpg-sign locale/*/LC_MESSAGES/*.po locale/templates/
}

function git_push {
git push -q "https://addons-robot:[email protected]/$TRAVIS_REPO_SLUG/"
}

Expand All @@ -98,21 +100,23 @@ function create_auto_pull_request {
echo "auto merge pull request is created ..."
}

if [ "$TRAVIS_BRANCH" != "master" ]; then
echo "This commit was made against the $TRAVIS_BRANCH and not the master! No extract!"
exit 0
fi

if [ "GITHUB_TOKEN" == "" ]
then
echo "Must provide github token"
exit 0
fi

init_environment

extract_locales

commit_and_push
git_commit

if [ "GITHUB_TOKEN" = "" ]
then
echo "No Github token provided, you'll have to push the branch and create the pull request yourself."
Copy link
Member

Choose a reason for hiding this comment

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

I understand why we can't create the pull request without the github API access but we could still push the branch like https://github.com/mozilla/addons-frontend/pull/9375/files#diff-cae1c8c05fe95719db14844a8f236ab1R76

else
if [ "$TRAVIS_BRANCH" != "master" ]; then
echo "This commit was made against the $TRAVIS_BRANCH and not the master! No extract!"
exit 0
fi
git_push

create_auto_pull_request
fi


create_auto_pull_request