From 8c8c1fcb85ea5590b0994a27c044d3f8aa2e7b08 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Tue, 18 Jul 2017 20:40:11 +0900 Subject: [PATCH 1/4] Update CircleCI job to trigger a Travis CI job for trpl-ja-pdf --- circle.yml | 1 + tools/circleci/trigger-trpl-pdf-ja.sh | 72 +++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 tools/circleci/trigger-trpl-pdf-ja.sh diff --git a/circle.yml b/circle.yml index 52c7e685..f0d119c9 100644 --- a/circle.yml +++ b/circle.yml @@ -66,4 +66,5 @@ deployment: # are updated from 1.6. - rm -rf docs/1.9 - ./tools/circleci/push-to-master.sh + - ./tools/circleci/trigger-trpl-pdf-ja.sh # - ./tools/circleci/publish-to-gh-pages.sh diff --git a/tools/circleci/trigger-trpl-pdf-ja.sh b/tools/circleci/trigger-trpl-pdf-ja.sh new file mode 100755 index 00000000..830513b7 --- /dev/null +++ b/tools/circleci/trigger-trpl-pdf-ja.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# This script triggers a Travis CI build on trpl-ja-pdf to generates +# PDF files of TRPL. It does so by sending a request to Travis's API +# server. +# +# This script referes to the following mandatory and optional +# environment variables: +# +# - TRPL_JA_PDF_TRAVIS_AUTH_TOKEN (Mandatory): +# The auth token required by Travis CI web API. Since this +# variable carries a sensitive data, it should not be defined in +# circle.yml. Instead, it should be defined at Circle CI's web +# console at: +# https://circleci.com/gh/rust-lang-ja/the-rust-programming-language-ja/edit#env-vars +# +# To obtain a Travis auth token, follow the instructions on: +# https://docs.travis-ci.com/user/triggering-builds/ +# +# - TRPL_JA_PDF_GITHUB_REPO (Optional): +# The GitHub repository name of trpl-ja-pdf, default to +# `trpl-ja-pdf`. To override it, define this variable at +# CircleCI's web console or in circle.yml. +# +# - TRPL_JA_PDF_GITHUB_ORG (Optional): +# The GitHub organization or user name of trpl-ja-pdf, default to +# `rust-lanu-ja`. To override it, define this variable at +# CirildCI's web console or in circle.yml. + +set -e + +if [ -z "${TRPL_JA_PDF_TRAVIS_AUTH_TOKEN+x}" ]; then + echo "ERROR: Environment variable TRPL_JA_PDF_TRAVIS_AUTH_TOKEN is undefined." + echo " If you want to trigger a Travis CI build for trpl-ja-pdf," + echo " please read comments in this script to define the variable." + exit 1 +fi + +GITHUB_REPO=${TRPL_JA_PDF_GITHUB_REPO:-tarpl-ja-pdf} +GITHUB_ORG=${TRPL_JA_PDF_GITHUB_ORG:-rust-lang-ja} + +set -u + +# Get the revision of current branch. +REVISION=$(git rev-parse --short HEAD) + +BUILD_PARAMS='{ + "request": { + "branch": "master" + "message": "automatic build triggered by trpl-ja commit ${REVISION}" + } +}' + +echo "Triggering a build on Travis CI for ${GITHUB_ORG}/${GITHUB_REPO}." + +set +e +curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -H "Travis-API-Version: 3" \ + -H "Authorization: token ${TRPL_JA_PDF_TRAVIS_AUTH_TOKEN}" \ + -d "$BUILD_PARAMS" \ + https://api.travis-ci.org/repo/${GITHUB_ORG}%2F${GITHUB_REPO}/requests +RET=$? +set -e + +if [ $RET -eq 0 ]; then + echo "Successfully triggered the Travis CI build." +else + echo "Failed to trigger the Travis CI build." + exit 1 +fi From 2d77cd4b7757f49feb68795c8db48c40eacfee8b Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Tue, 18 Jul 2017 20:57:53 +0900 Subject: [PATCH 2/4] Temporary enable trigger-trpl-pdf-ja.sh on triggering-trpl-ja-pdf branch --- circle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index f0d119c9..8c2bd057 100644 --- a/circle.yml +++ b/circle.yml @@ -58,13 +58,13 @@ test: deployment: publish: - branch: master + branch: [master, triggering-trpl-ja-pdf] commands: - git config user.name "Tatsuya Kawano (CircleCI)" - git config user.email "tatsuya@hibaridb.org" # Do not publish 1.9 to gh-pages until all (or most of) the contents # are updated from 1.6. - rm -rf docs/1.9 - - ./tools/circleci/push-to-master.sh + # - ./tools/circleci/push-to-master.sh - ./tools/circleci/trigger-trpl-pdf-ja.sh # - ./tools/circleci/publish-to-gh-pages.sh From 14ec179ac86a008952a062f3289ba01cd31fb7da Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Tue, 18 Jul 2017 21:47:09 +0900 Subject: [PATCH 3/4] Brush up CircleCI job to trigger a Travis CI job for trpl-ja-pdf - Add an env variable: TRPL_JA_PDF_GITHUB_BRANCH - Fix `curl` params and the way to parse response. --- tools/circleci/trigger-trpl-pdf-ja.sh | 43 ++++++++++++++++----------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/tools/circleci/trigger-trpl-pdf-ja.sh b/tools/circleci/trigger-trpl-pdf-ja.sh index 830513b7..027038ed 100755 --- a/tools/circleci/trigger-trpl-pdf-ja.sh +++ b/tools/circleci/trigger-trpl-pdf-ja.sh @@ -17,15 +17,20 @@ # To obtain a Travis auth token, follow the instructions on: # https://docs.travis-ci.com/user/triggering-builds/ # +# - TRPL_JA_PDF_GITHUB_ORG (Optional): +# The GitHub organization or user name of trpl-ja-pdf, default to +# `rust-lanu-ja`. To override it, define this variable at +# CirildCI's web console or in circle.yml. +# # - TRPL_JA_PDF_GITHUB_REPO (Optional): # The GitHub repository name of trpl-ja-pdf, default to # `trpl-ja-pdf`. To override it, define this variable at # CircleCI's web console or in circle.yml. # -# - TRPL_JA_PDF_GITHUB_ORG (Optional): -# The GitHub organization or user name of trpl-ja-pdf, default to -# `rust-lanu-ja`. To override it, define this variable at -# CirildCI's web console or in circle.yml. +# - TRPL_JA_PDF_GITHUB_BRANCH (Optional): +# The GitHub branch of trpl-ja-pdf, default to `master`. To +# override it, define this variable at CircleCI's web console or +# in circle.yml. set -e @@ -36,37 +41,41 @@ if [ -z "${TRPL_JA_PDF_TRAVIS_AUTH_TOKEN+x}" ]; then exit 1 fi -GITHUB_REPO=${TRPL_JA_PDF_GITHUB_REPO:-tarpl-ja-pdf} GITHUB_ORG=${TRPL_JA_PDF_GITHUB_ORG:-rust-lang-ja} +GITHUB_REPO=${TRPL_JA_PDF_GITHUB_REPO:-trpl-ja-pdf} +GITHUB_BRANCH=${TRPL_JA_PDF_GITHUB_BRANCH:-master} set -u # Get the revision of current branch. REVISION=$(git rev-parse --short HEAD) -BUILD_PARAMS='{ +BUILD_PARAMS=$(cat < Date: Tue, 18 Jul 2017 21:53:04 +0900 Subject: [PATCH 4/4] Revert "Temporary enable trigger-trpl-pdf-ja.sh on triggering-trpl-ja-pdf branch" This reverts commit 2d77cd4b7757f49feb68795c8db48c40eacfee8b. --- circle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 8c2bd057..f0d119c9 100644 --- a/circle.yml +++ b/circle.yml @@ -58,13 +58,13 @@ test: deployment: publish: - branch: [master, triggering-trpl-ja-pdf] + branch: master commands: - git config user.name "Tatsuya Kawano (CircleCI)" - git config user.email "tatsuya@hibaridb.org" # Do not publish 1.9 to gh-pages until all (or most of) the contents # are updated from 1.6. - rm -rf docs/1.9 - # - ./tools/circleci/push-to-master.sh + - ./tools/circleci/push-to-master.sh - ./tools/circleci/trigger-trpl-pdf-ja.sh # - ./tools/circleci/publish-to-gh-pages.sh