[CI] Fix CircleCI context issue by separating out docs & translations (#8614)

See <https://github.com/koreader/koreader/pull/8607> for discussion.
reviewable/pr8618/r1
Frans de Jonge 2 years ago committed by GitHub
parent bc16b32395
commit ec280f874f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,41 +9,6 @@ set +e
if [ -z "${CIRCLE_PULL_REQUEST}" ] && [ "${CIRCLE_BRANCH}" = 'master' ]; then
echo "CIRCLE_NODE_INDEX: ${CIRCLE_NODE_INDEX}"
if [ "${CIRCLE_NODE_INDEX}" = 1 ]; then
echo -e "\\n${ANSI_GREEN}Updating translation source file."
make pot
pushd l10n && {
git checkout master
# If only one line was added and removed, it was just the timestamp.
git diff --numstat | grep "1[[:space:]]1[[:space:]]templates/koreader.pot" && echo -e "\\n${ANSI_GREEN}No updated translations found." || {
git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \
commit templates/koreader.pot -m "Updated translation source file"
git push --quiet "https://${TRANSLATIONS_GITHUB_TOKEN}@github.com/koreader/koreader-translations.git" master
echo -e "\\n${ANSI_GREEN}Translation update pushed."
}
} && popd || exit
echo -e "\\n${ANSI_GREEN}Checking out koreader/doc for update."
git clone git@github.com:koreader/doc.git koreader_doc
# push doc update
pushd doc && {
luajit "$(command -v ldoc)" . 2>/dev/null
if [ ! -d html ]; then
echo "Failed to generate documents..."
exit 1
fi
} && popd || exit
cp -r doc/html/* koreader_doc/
pushd koreader_doc && {
git add -A
echo -e "\\n${ANSI_GREEN}Pushing document update..."
git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \
commit -a --amend -m 'Automated documentation build from travis-ci.'
git push -f --quiet "https://${DOCS_GITHUB_TOKEN}@github.com/koreader/doc.git" gh-pages >/dev/null
echo -e "\\n${ANSI_GREEN}Documentation update pushed."
} && popd || exit
echo -e "\\n${ANSI_GREEN}Running make testfront for timings."
make testfront BUSTED_OVERRIDES="--output=junit -Xoutput junit-test-results.xml"
fi
@ -56,5 +21,5 @@ if [ -z "${CIRCLE_PULL_REQUEST}" ] && [ "${CIRCLE_BRANCH}" = 'master' ]; then
} && popd || exit
fi
else
echo -e "\\n${ANSI_GREEN}Not on official master branch. Skipping documentation update and coverage."
echo -e "\\n${ANSI_GREEN}Not on official master branch. Skipping coverage."
fi

@ -0,0 +1,42 @@
#!/usr/bin/env bash
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=/dev/null
source "${CI_DIR}/common.sh"
set +e
echo -e "\\n${ANSI_GREEN}Updating translation source file."
make pot
pushd l10n && {
git checkout master
# If only one line was added and removed, it was just the timestamp.
git diff --numstat | grep "1[[:space:]]1[[:space:]]templates/koreader.pot" && echo -e "\\n${ANSI_GREEN}No updated translations found." || {
git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \
commit templates/koreader.pot -m "Updated translation source file"
git push --quiet "https://${TRANSLATIONS_GITHUB_TOKEN}@github.com/koreader/koreader-translations.git" master
echo -e "\\n${ANSI_GREEN}Translation update pushed."
}
} && popd || exit
echo -e "\\n${ANSI_GREEN}Checking out koreader/doc for update."
git clone git@github.com:koreader/doc.git koreader_doc
# push doc update
pushd doc && {
luajit "$(command -v ldoc)" . 2>/dev/null
if [ ! -d html ]; then
echo "Failed to generate documents..."
exit 1
fi
} && popd || exit
cp -r doc/html/* koreader_doc/
pushd koreader_doc && {
git add -A
echo -e "\\n${ANSI_GREEN}Pushing document update..."
git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \
commit -a --amend -m 'Automated documentation build from travis-ci.'
git push -f --quiet "https://${DOCS_GITHUB_TOKEN}@github.com/koreader/doc.git" gh-pages >/dev/null
echo -e "\\n${ANSI_GREEN}Documentation update pushed."
} && popd || exit

@ -1,4 +1,18 @@
version: 2
workflows:
version: 2
build:
jobs:
- build
- docs:
context: koreader-vars
filters:
branches:
only: master
requires:
- build
jobs:
build:
docker:
@ -63,7 +77,7 @@ jobs:
# docs, coverage, and test timing (can we use two outputs at once?); master branch only
- run:
name: docs-and-coverage
name: coverage
command: .ci/after_success.sh
# by storing the test results CircleCI automatically distributes tests based on execution time
- store_test_results:
@ -71,10 +85,31 @@ jobs:
# CircleCI doesn't make the test results available as artifacts (October 2017)
- store_artifacts:
path: koreader-emulator-x86_64-linux-gnu/koreader/junit-test-results.xml
docs:
docker:
- image: koreader/koappimage:0.2.2
auth:
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
environment:
EMULATE_READER: 1
parallelism: 1
steps:
- checkout
- restore_cache:
keys:
# binary dependencies require {{ arch }} because there are different CPUs in use on the servers
- deps-{{ arch }}-{{ checksum ".ci/install.sh" }}-{{ checksum ".ci/helper_luarocks.sh" }}
# need to init some stuff first or git will complain when sticking in base cache
- run: git submodule init base && git submodule update base && pushd base && git submodule init && git submodule update && popd
# we can't use command output directly for cache check so we write it to git-rev-base
- run: pushd base && git_rev_base=$(git describe HEAD) && popd && echo $git_rev_base && echo $git_rev_base >git-rev-base
workflows:
version: 2
build:
jobs:
- build:
context: koreader-vars
- run:
name: init-submodules
command: git submodule init && git submodule sync && git submodule update
# docs, coverage, and test timing (can we use two outputs at once?); master branch only
- run:
name: docs-and-translation
command: .ci/after_success_docs_translation.sh

Loading…
Cancel
Save