Created
February 4, 2019 08:26
-
-
Save AdrienLemaire/e5c78567e35be1dc2ec0013614e1073b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Frontend/scripts/ci.sh | |
#!/bin/bash | |
yarn ci:fast | |
echo "TRAVIS_BRANCH=$TRAVIS_BRANCH" | |
echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" | |
USER=miraidenshi | |
REPO=GOunite | |
CHECK_TITLE="Slow Tests" | |
check_result () { | |
BUILD_INFO=$(curl -s -X GET \ | |
-H "Content-Type: application/json" \ | |
-H "Accept: application/json" \ | |
-H "Travis-API-Version: 3" \ | |
-H "Authorization: token ${TRAVIS_ACCESS_TOKEN}" \ | |
https://api.travis-ci.org/repo/${USER}%2F${REPO}/builds?include=build.state\&include=build.id\&include=build.started_at\&branch.name=${TRAVIS_BRANCH}\&sort_by=started_atdesc\&limit=1 ) | |
BUILD_STATE=$(echo "${BUILD_INFO}" | grep -Po '"state":.*?[^\\]",'|head -n1| awk -F "\"" '{print $4}') | |
BUILD_ID=$(echo "${BUILD_INFO}" | grep '"id": '|head -n1| awk -F'[ ,]' '{print $8}') | |
} | |
if [[ $TRAVIS_COMMIT_MESSAGE == *"[slow]"* ]]; then | |
# Trigger build request | |
curl -LO --retry 3 https://raw.github.com/mernst/plume-lib/master/bin/trigger-travis.sh | |
MESSAGE="${CHECK_TITLE}:Frontend ${TRAVIS_COMMIT}" | |
OTHER="\"config\":{\"merge_mode\":\"deep_merge\",\"env\": {\"TRIGGER_PATH\": \"Frontend/statuses/${TRAVIS_COMMIT}\"}}" | |
# Hack trigger-travis to send env var TRIGGER_PATH to the GOunite build (for it to pass/fail the related PR status check) | |
sh trigger-travis.sh --pro $USER $REPO $TRAVIS_ACCESS_TOKEN "$MESSAGE\",$OTHER,\"HACK\":\"" | |
# Add pending status to Github PR | |
check_result | |
curl -H "Authorization: token ${DORI_PAT}" --data "{\"state\": \"pending\", \"target_url\": \"https://travis-ci.com/miraidenshi/GOunite/builds/${BUILD_ID}\", \"context\": \"${CHECK_TITLE}\"}" https://api.github.com/repos/miraidenshi/Frontend/statuses/$TRAVIS_COMMIT | |
else | |
echo "No marker [slow] detected, cancelling slow tests…" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Frontend/.travis.yml | |
--- | |
before_script: | |
- yarn build:stg --bail --progress=0 | |
cache: yarn | |
language: node_js | |
node_js: | |
- 10.12.0 | |
script: yarn ci |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Infra/.travis.yml | |
--- | |
install: | |
- CI=1 ./scripts/setup_local_env.sh | |
script: | |
- | # Execute Behave integration tests | |
cd $HOME/build/miraidenshi/gounite/GOunite/infrastructure/ | |
docker-compose exec -e IS_TEST_RUNNER=1 backend ./manage.py behave | |
after_success: | |
- | # Update Github PR Status check if triggered by xpc or backend | |
CHECK_TITLE="Slow Tests" | |
if [[ ! -z "$TRIGGER_PATH" ]]; then | |
curl -H "Authorization: token ${DORI_PAT}" --data "{\"state\": \"success\", \"context\": \"${CHECK_TITLE}\"}" https://api.github.com/repos/miraidenshi/$TRIGGER_PATH | |
fi | |
after_failure: | |
- | # Update Github PR Status check if triggered by xpc or backend | |
CHECK_TITLE="Slow Tests" | |
if [[ ! -z "$TRIGGER_PATH" ]]; then | |
curl -H "Authorization: token ${DORI_PAT}" --data "{\"state\": \"failure\", \"context\": \"${CHECK_TITLE}\"}" https://api.github.com/repos/miraidenshi/$TRIGGER_PATH | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment