Use GH Actions for automation (#579)
This commit is contained in:
Родитель
a46aa2d897
Коммит
b31a668529
|
@ -1,67 +0,0 @@
|
|||
# update secret-env-cypher locally with:
|
||||
# openssl aes-256-cbc -e -in secret-env-plain -out secret-env-cipher -k $KEY
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:14
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
# https://www.openssl.org/docs/faq.html#USER3
|
||||
command: |
|
||||
|
||||
openssl aes-256-cbc -md md5 -d -in secret-env-cipher -k $KEY >> ~/.circlerc
|
||||
sudo apt-get update; sudo apt-get install gettext graphicsmagick
|
||||
sudo npm install -g grunt-cli gh@2.8.9
|
||||
source ~/.circlerc
|
||||
GITHUB_TOKEN=$GITHUB_TOKEN GITHUB_USER=$GITHUB_USER node scripts/ci-creds.js
|
||||
mkdir -p ~/.config/configstore/
|
||||
echo optOut: true > ~/.config/configstore/insight-gh.yml
|
||||
git config --global user.email "bugmirror@restmail.net"
|
||||
git config --global user.name "Bug Mirror"
|
||||
git remote rm origin
|
||||
git remote add origin git@github.com:bug-mirror/fxa-content-server-l10n.git
|
||||
|
||||
ssh-agent -s > ~/.ssh_agent_conf;
|
||||
source ~/.ssh_agent_conf;
|
||||
|
||||
ssh-add -D;
|
||||
openssl aes-256-cbc -md md5 -d -in id_bug_mirror.enc -k $KEY >> ~/.ssh/id_bug_mirror;
|
||||
chmod 0600 ~/.ssh/id_bug_mirror;
|
||||
ssh-add ~/.ssh/id_bug_mirror;
|
||||
|
||||
bash ./scripts/extract-and-pull-request.sh; gh pr --submit mozilla --branch master --browser false;
|
||||
|
||||
ci:
|
||||
docker:
|
||||
- image: circleci/node:14
|
||||
steps:
|
||||
- checkout
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
# workflow jobs are _not_ run in tag builds by default
|
||||
# we use filters to whitelist jobs that should be run for tags
|
||||
|
||||
# workflow jobs are run in _all_ branch builds by default
|
||||
# we use filters to blacklist jobs that shouldn't be run for a branch
|
||||
|
||||
# see: https://circleci.com/docs/2.0/workflows/#git-tag-job-execution
|
||||
|
||||
build-test-push:
|
||||
jobs:
|
||||
- ci
|
||||
|
||||
send-pr:
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: "0 22 * * 4" # At 15:00 PDT on Thursday
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
jobs:
|
||||
- build
|
|
@ -0,0 +1,64 @@
|
|||
name: Extract Strings
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 22 * * 4' # At 15:00 PDT on Thursday
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
extract:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Linux packages
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install gettext git hub -y
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14
|
||||
- name: Install global npm packages
|
||||
run: |
|
||||
npm install -g grunt-cli
|
||||
- name: Clone l10n repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: "fxa-l10n"
|
||||
- name: Clone FxA code repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: "mozilla/fxa"
|
||||
fetch-depth: 1
|
||||
path: "fxa-code"
|
||||
- name: Install npm packages
|
||||
run: |
|
||||
cd fxa-l10n
|
||||
npm install
|
||||
- name: Extract strings
|
||||
run: |
|
||||
cd fxa-code
|
||||
yarn workspaces focus fxa-content-server fxa-auth-server fxa-payments-server fxa-settings
|
||||
yarn workspace fxa-settings build
|
||||
yarn workspace fxa-auth-server grunt merge-ftl
|
||||
|
||||
NODE_ENV=development ../fxa-l10n/scripts/extract_strings.sh \
|
||||
--mailer-repo ./packages/fxa-auth-server \
|
||||
--payments-repo ./packages/fxa-payments-server \
|
||||
--content-repo ./packages/fxa-content-server \
|
||||
--settings-repo ./packages/fxa-settings \
|
||||
--l10n-repo ../fxa-l10n
|
||||
- name: Commit changes and open pull request
|
||||
run: |
|
||||
git config --global user.email 'bugmirror@restmail.net'
|
||||
git config --global user.name 'Bug Mirror'
|
||||
# Random release number to avoid collision with old trains or branches
|
||||
TRAIN_NUMBER=$(( $RANDOM + $RANDOM + 1000 ))
|
||||
|
||||
cd fxa-l10n
|
||||
git checkout -B "merge-train-$TRAIN_NUMBER-strings"
|
||||
git add .
|
||||
git commit -m "Merge strings for train $TRAIN_NUMBER"
|
||||
git push -f origin "merge-train-$TRAIN_NUMBER-strings"
|
||||
|
||||
# Create pull request, use the last commit message as title
|
||||
hub pull-request --no-edit
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@ -0,0 +1,33 @@
|
|||
name: Tests
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
run-test:
|
||||
# Pontoon creates one commit per locale every 10 minutes, only run on
|
||||
# the latest commit of the batch.
|
||||
concurrency:
|
||||
group: ${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Linux packages
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install gettext graphicsmagick -y
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14
|
||||
- name: Install global npm packages
|
||||
run: |
|
||||
npm install -g grunt-cli
|
||||
- name: Clone l10n repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install npm packages
|
||||
run: |
|
||||
npm install
|
||||
- name: Run tests
|
||||
run: |
|
||||
npm test
|
|
@ -1,6 +1,3 @@
|
|||
/.idea/
|
||||
node_modules
|
||||
workspace
|
||||
secret-env-plain
|
||||
.gh.json
|
||||
id_bug_mirror
|
||||
/.idea/
|
||||
|
|
65
README.md
65
README.md
|
@ -1,13 +1,15 @@
|
|||
fxa-content-server-l10n
|
||||
=======================
|
||||
|
||||
[![CircleCI](https://circleci.com/gh/mozilla/fxa-content-server-l10n/tree/master.svg?style=svg)](https://circleci.com/gh/mozilla/fxa-content-server-l10n/tree/master)
|
||||
[![Tests](https://github.com/mozilla/fxa-content-server-l10n/actions/workflows/test.yaml/badge.svg)](https://github.com/mozilla/fxa-content-server-l10n/actions/workflows/test.yaml)
|
||||
|
||||
This repo (abbreviated as "L10N" in this README) contains all translated/translatable strings for all of the FxA servers (fxa-content-server, fxa-auth-server, etc.). The FxA repository is abbreviated as "SOURCE" in this document.
|
||||
This repo (abbreviated as "L10N" in this README) contains all translated/translatable strings for all of the FxA servers (fxa-content-server, fxa-auth-server, etc.). The FxA repository is abbreviated as "SOURCE" in this document.
|
||||
|
||||
The string localization is managed in [Pontoon](https://pontoon.mozilla.org/projects/firefox-accounts/) and it pushes changes anytime it likes.
|
||||
|
||||
On a regular basis (currently once a week) a [cron job runs](https://github.com/mozilla/fxa-content-server-l10n/blob/master/.circleci/config.yml) which extracts all the strings from SOURCE and opens a PR to merge them into this repository. Someone from the localization team will review that PR for any strings that are confusing to localize and, if there aren't any problems, will merge it. At that point Pontoon sees the changes and strings can be localized from the Pontoon interface.
|
||||
On a regular basis (currently once a week) a [cron job runs](https://github.com/mozilla/fxa-content-server-l10n/blob/master/.github/workflows/l10n_extract.yaml) to extract all the strings from SOURCE and open a PR to merge them into this repository. Someone from the localization team will review that PR for any strings that are confusing to localize and, if there aren't any problems, will merge it. At that point Pontoon sees the changes and strings can be localized from the Pontoon interface.
|
||||
|
||||
The extraction process can also be triggered manually from [here](https://github.com/mozilla/fxa-content-server-l10n/actions/workflows/l10n_extract.yaml).
|
||||
|
||||
A new copy of this repository is checked out every time a deploy happens so deployed sites have the latest strings.
|
||||
|
||||
|
@ -15,60 +17,3 @@ A new copy of this repository is checked out every time a deploy happens so depl
|
|||
|
||||
Please find your locale on [Pontoon - Firefox Accounts](https://pontoon.mozilla.org/projects/firefox-accounts/).
|
||||
Follow the instructions on those sites to submit your translations.
|
||||
|
||||
## !! Warning !!
|
||||
|
||||
The directions below are super old and may not be relevant anymore. The tools, like gettext, still matter, but I don't think all the script that exist here are run anymore. So, beware.
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* Install [gettext](https://www.gnu.org/software/gettext/).
|
||||
OS X:
|
||||
```
|
||||
brew install gettext
|
||||
brew link gettext --force # brew does not link the tools into /usr/local. Force the link.
|
||||
```
|
||||
|
||||
Ubuntu: `sudo apt-get install gettext`
|
||||
|
||||
The process to work with strings:
|
||||
|
||||
* Make sure you installed the dependencies and `msgfilter` (from `gettext`) command is available in your shell.
|
||||
* Have the `fxa-auth-server` and `fxa-content-server` repos at the same directory level as `fxa-content-server-l10n`.
|
||||
* Have all the dependencies be up to date in the fxa-auth-server and fxa-content-server repos using `npm install`.
|
||||
|
||||
## Locale Normalization
|
||||
> Before Release Build
|
||||
|
||||
Some locales need to be copied over into a different directory. Run this script a few hours before the production deploy:
|
||||
|
||||
```
|
||||
./scripts/before_prod_deploy.sh --l10n-repo .
|
||||
```
|
||||
|
||||
## String extraction
|
||||
> After Production Deploy
|
||||
|
||||
Source strings are extracted from the [fxa-content-server](https://github.com/mozilla/fxa-content-server/) and [fxa-auth-server](https://github.com/mozilla/fxa-auth-server/) repos. Make sure you to `git pull` the latest changes from `master` for both of those repositories.
|
||||
|
||||
* `cd` into this project directory and run:
|
||||
```
|
||||
./scripts/extract_strings.sh --mailer-repo ../fxa-auth-server --content-repo ../fxa-content-server --l10n-repo . TRAIN_NUMBER
|
||||
```
|
||||
where `TRAIN_NUMBER` is the train you are cutting strings for.
|
||||
|
||||
This will create a new branch. Now run:
|
||||
```
|
||||
./scripts/before_prod_deploy.sh --l10n-repo .
|
||||
```
|
||||
|
||||
Git commit the changes made by the script. Pull request that branch against `master`.
|
||||
|
||||
After that pull request is merged run:
|
||||
|
||||
```
|
||||
./scripts/email-dev-l10n.sh
|
||||
```
|
||||
|
||||
The script above will generate an email for the l10n mailing list. Read through the instructions in the script output to post to the l10n mailing list.
|
||||
|
|
Двоичные данные
id_bug_mirror.enc
Двоичные данные
id_bug_mirror.enc
Двоичный файл не отображается.
|
@ -1,7 +0,0 @@
|
|||
const fs = require('fs');
|
||||
|
||||
fs.writeFileSync('.gh.json', JSON.stringify({
|
||||
github_token: process.env.GITHUB_TOKEN,
|
||||
github_user: process.env.GITHUB_USER,
|
||||
use_editor: false,
|
||||
}));
|
|
@ -1,44 +0,0 @@
|
|||
# Script adapted from https://github.com/mozilla/olympia/blob/master/locale/omg_new_l10n.sh
|
||||
|
||||
EMAIL_FROM="Firefox Accounts Developers <dev-fxacct@mozilla.org>"
|
||||
EMAIL_TO="Awesome Localizers <dev-l10n-web@lists.mozilla.org>"
|
||||
EMAIL_SUBJECT="[FxA] .po files updated"
|
||||
|
||||
# A link to the .po files
|
||||
EMAIL_SOURCE="https://github.com/mozilla/fxa-content-server-l10n/tree/master/locale"
|
||||
PONTOON_URL="https://pontoon.mozilla.org/projects/firefox-accounts"
|
||||
|
||||
SCRIPT_DIR=`dirname "$0"`
|
||||
LOCALE_DIR=$SCRIPT_DIR/../locale
|
||||
echo $DIR
|
||||
echo $SCRIPT_DIR
|
||||
echo $PWD
|
||||
|
||||
echo "Calculating changes...."
|
||||
CHANGES=$(cat <<MAIL
|
||||
From: $EMAIL_FROM
|
||||
To: $EMAIL_TO
|
||||
Subject: $EMAIL_SUBJECT
|
||||
Hi,
|
||||
|
||||
I am an automated script letting you know that some .po files have just been
|
||||
updated. Unless something unusual is happening, we do bi-weekly pushes every other
|
||||
Wednesday so any strings committed by then will go live. To give you an idea of
|
||||
the number of new strings I will calculate untranslated strings below.
|
||||
|
||||
`$SCRIPT_DIR/stats-po.sh $LOCALE_DIR`
|
||||
|
||||
Pontoon: $PONTOON_URL
|
||||
Source files: $EMAIL_SOURCE
|
||||
|
||||
If you have any questions please reply to the list.
|
||||
Thanks so much for all your help!
|
||||
MAIL
|
||||
)
|
||||
|
||||
echo "-----------------------------------------------"
|
||||
echo "$CHANGES"
|
||||
echo "-----------------------------------------------"
|
||||
|
||||
echo "^ Open https://groups.google.com/forum/#!forum/mozilla.dev.l10n.web and paste the above under 'New Topic'"
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
rm -rf workspace
|
||||
mkdir workspace
|
||||
(cd workspace && git clone --depth 1 https://github.com/mozilla/fxa)
|
||||
(cd workspace/fxa && yarn workspaces focus fxa-content-server fxa-auth-server fxa-payments-server fxa-settings)
|
||||
(cd workspace/fxa && yarn workspace fxa-settings build)
|
||||
(cd workspace/fxa && yarn workspace fxa-auth-server grunt merge-ftl)
|
||||
|
||||
# random release number, avoids collision with old trains or branches
|
||||
r=$(( $RANDOM + $RANDOM + 1000 ))
|
||||
NODE_ENV=development ./scripts/extract_strings.sh --mailer-repo workspace/fxa/packages/fxa-auth-server --payments-repo workspace/fxa/packages/fxa-payments-server --content-repo workspace/fxa/packages/fxa-content-server --settings-repo workspace/fxa/packages/fxa-settings --l10n-repo . $r
|
|
@ -1,13 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# syntax:
|
||||
# extract_strings.sh [--mailer-repo ./fxa-auth-server] [--content-repo ./fxa-content-server] [--l10n-repo ./fxa-content-server-l10n] train_number
|
||||
# extract_strings.sh [--mailer-repo ./fxa-auth-server] [--content-repo ./fxa-content-server] [--l10n-repo ./fxa-content-server-l10n]
|
||||
|
||||
set -e
|
||||
|
||||
function usage() {
|
||||
echo "syntax:"
|
||||
echo "extract_strings.sh [--mailer-repo ./fxa-auth-server] [--content-repo ./fxa-content-server] [--payments-repo ./fxa-payments-server] [--l10n-repo ./fxa-content-server-l10n] train_number"
|
||||
echo "extract_strings.sh [--mailer-repo ./fxa-auth-server] [--content-repo ./fxa-content-server] [--payments-repo ./fxa-payments-server] [--l10n-repo ./fxa-content-server-l10n]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,6 @@ case $param in
|
|||
esac
|
||||
done
|
||||
|
||||
TRAIN_NUMBER=$1
|
||||
|
||||
printf "Checking $MAILER_DIR.. "
|
||||
check_folder $MAILER_DIR
|
||||
printf "Checking $CONTENT_DIR.. "
|
||||
|
@ -92,19 +90,7 @@ cp $SETTINGS_DIR/public/locales/en-US/*.ftl $L10N_DIR/locale/templates
|
|||
cp $MAILER_DIR/public/locales/en/*.ftl $L10N_DIR/locale/templates
|
||||
|
||||
cd $L10N_DIR
|
||||
git checkout -b merge-train-$TRAIN_NUMBER-strings
|
||||
./scripts/merge_po.sh ./locale
|
||||
./scripts/before_prod_deploy.sh --l10n-repo $L10N_DIR
|
||||
git add .
|
||||
git commit -m "merge strings for train $TRAIN_NUMBER"
|
||||
|
||||
set +x
|
||||
|
||||
echo
|
||||
echo
|
||||
echo "Everything seems to be in order. Please check the extraction went okay then you can push the new branch with:"
|
||||
echo "cd $L10N_DIR"
|
||||
echo "git push <remote> merge-train-$TRAIN_NUMBER-strings"
|
||||
echo
|
||||
echo "When the strings have been merged, send an email to the l10n list by running:"
|
||||
echo "./scripts/email-l10n-dev.sh"
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
# syntax:
|
||||
# stats-po.sh
|
||||
|
||||
echo "Printing number of untranslated strings found in locales:"
|
||||
|
||||
for lang in $(find $1 -type f -name "server.po" | sort); do
|
||||
dir=$(dirname $lang)
|
||||
lang_dir=$(dirname $dir)
|
||||
stem=$(basename $lang .po)
|
||||
js="$dir/client.po"
|
||||
count=$(msgattrib $lang --untranslated --no-obsolete --no-fuzzy | grep -c 'msgid ')
|
||||
if [ $count -gt 0 ]; then
|
||||
count=$(($count-1))
|
||||
fi
|
||||
count2=$(msgattrib $js --untranslated --no-obsolete --no-fuzzy | grep -c 'msgid ')
|
||||
if [ $count2 -gt 0 ]; then
|
||||
count2=$(($count2-1))
|
||||
fi
|
||||
echo -e "${lang_dir##*/}\t\tserver=$count\tclient=$count2"
|
||||
done
|
Двоичные данные
secret-env-cipher
Двоичные данные
secret-env-cipher
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче