-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40e4f1f
commit 1fc9267
Showing
8 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests==2.20.1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIRNAME=$(dirname $0) | ||
BEFORE_DEPLOY_EXEC_FILES=$(find $DIRNAME -name 'before-deploy-*.sh') | ||
|
||
echo Running $0 | ||
echo *-*-*-*-*-*-*-*-*-*-*-*-*-* | ||
|
||
function decryptsecrets { | ||
echo decrypting secrets | ||
echo *-*-*-*-*-*-*-*-*-*-*-* | ||
mkdir -p ~/tmp | ||
openssl aes-256-cbc -K $encrypted_SOME_key -iv $encrypted_SOME_iv -in $TRAVIS_BUILD_DIR/src/main/scripts/cd/secrets.tar.enc -out ~/tmp/secrets.tar -d | ||
md5sum ~/tmp/secrets.tar | ||
tar -xvf ~/tmp/secrets.tar -C ~/.ssh | ||
shred -z -u ~/tmp/secrets.tar | ||
} | ||
|
||
function importpgp { | ||
echo importing pgp secret | ||
echo *-*-*-*-*-*-*-*-*-*-*-* | ||
eval $(gpg-agent --daemon --batch) | ||
gpg --batch --passphrase $GPG_PASSPHRASE --import ~/.ssh/codesigning.asc | ||
shred -z -u ~/.ssh/codesigning.asc | ||
} | ||
|
||
function setupssh { | ||
echo importing ssh secret | ||
echo *-*-*-*-*-*-*-*-*-*-*-* | ||
chmod 400 ~/.ssh/id_rsa | ||
touch ~/.ssh/config | ||
|
||
echo "Host github.com" >> $HOME/.ssh/config | ||
echo " IdentityFile $HOME/.ssh/id_rsa" >> $HOME/.ssh/config | ||
echo " StrictHostKeyChecking no" >> $HOME/.ssh/config | ||
|
||
eval "$(ssh-agent -s)" | ||
ssh-add ~/.ssh/id_rsa | ||
ssh -T [email protected] | true | ||
} | ||
|
||
function setupgit { | ||
echo setting git up | ||
echo *-*-*-*-*-*-*-*-*-*-*-* | ||
git remote set-url origin [email protected]:$TRAVIS_REPO_SLUG.git | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "io-scalecube-ci" | ||
git checkout -B $TRAVIS_BRANCH | true | ||
} | ||
|
||
function deployment { | ||
if [ "$TRAVIS_PULL_REQUEST" == 'false' ] && [ "$TRAVIS_BRANCH" = 'master' ] || [ "$TRAVIS_BRANCH" = 'develop' ]; then | ||
echo deployment | ||
echo *-*-*-*-*-*-*-*-*-*-*-* | ||
decryptsecrets | ||
importpgp | ||
setupssh | ||
setupgit | ||
fi | ||
} | ||
|
||
deployment | ||
|
||
# extends before-deploy.sh | ||
for script_file in $BEFORE_DEPLOY_EXEC_FILES; do | ||
. $script_file | ||
done |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env sh | ||
|
||
DIRNAME=$(dirname $0) | ||
DEPLOY_EXEC_FILES=$(find $DIRNAME -name 'deploy-*.sh') | ||
|
||
echo Running $0 | ||
echo *-*-*-*-*-*-*-*-*-*-*-*-*-* | ||
|
||
mvn -P release deploy -Darguments=-DskipTests -B -V -s travis-settings.xml | ||
pip install --user -r requirements.txt | ||
$(dirname $0)/external_build.sh | ||
|
||
# extends deploy.sh | ||
for script_file in $DEPLOY_EXEC_FILES; do | ||
. $script_file | ||
done | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python | ||
|
||
import requests | ||
import urlparse | ||
import json | ||
import time | ||
import sys | ||
import os | ||
|
||
class TravisBuilds: | ||
""" | ||
This class provides requests to builds and check their statuses | ||
""" | ||
travis_api_url = 'https://api.travis-ci.org/' | ||
build_id = None | ||
|
||
def __init__(self, repo_name, auth_token): | ||
self.headers = {'Content-Type': 'application/json', | ||
'Accept': 'application/json', | ||
'Travis-API-Version': '3', | ||
'Authorization': 'token {}'.format(auth_token) | ||
} | ||
self.repo_name = repo_name | ||
|
||
def start_build(self): | ||
data = {"request": { | ||
"branch": "master" | ||
}} | ||
url = urlparse.urljoin(self.travis_api_url, | ||
'repo/{}/requests'.format(self.repo_name)) | ||
response = requests.post(url=url, data=json.dumps(data), headers=self.headers) | ||
if response.status_code == 202: | ||
self.build_id = self.get_build_id(response.json()["request"]["id"]) | ||
print self.build_id | ||
return True | ||
|
||
def get_build_id(self, request_id): | ||
time.sleep(10) | ||
url = urlparse.urljoin(self.travis_api_url, | ||
'repo/{}/request/{}'.format(self.repo_name, request_id)) | ||
response = requests.get(url=url, headers=self.headers) | ||
return response.json()["builds"][0]['id'] | ||
|
||
def wait_for_build_result(self): | ||
attempts = 0 | ||
tests_minutes = int(os.getenv('TESTS_MINUTES')) | ||
while attempts < tests_minutes: | ||
url = urlparse.urljoin(self.travis_api_url, 'build/{}'.format(self.build_id)) | ||
response = requests.get(url=url, headers=self.headers) | ||
if response.json()['state'] == "passed": | ||
return True | ||
else: | ||
print "External build is running {} minutes".format(attempts) | ||
time.sleep(60) | ||
attempts += 1 | ||
return False | ||
|
||
|
||
if __name__ == '__main__': | ||
external_build = os.getenv('TRIGGER_EXTERNAL_CI', '') | ||
if external_build: | ||
travis = TravisBuilds(external_build, os.getenv('TRAVIS_AUTH_TOKEN')) | ||
build = travis.start_build() | ||
result = travis.wait_for_build_result() | ||
if result: | ||
sys.exit(0) | ||
sys.exit(1) | ||
sys.exit(0) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env sh | ||
|
||
DIRNAME=$(dirname $0) | ||
RELEASE_EXEC_FILES=$(find $DIRNAME -name 'release-*.sh') | ||
|
||
echo Running $0 | ||
echo *-*-*-*-*-*-*-*-*-*-*-*-*-* | ||
|
||
commit_to_develop() { | ||
git fetch | ||
git branch -r | ||
git checkout -B develop | ||
git rebase master | ||
git commit --amend -m "++++ Prepare for next development iteration build: $TRAVIS_BUILD_NUMBER ++++" | ||
git push origin develop | ||
} | ||
|
||
mvn -P release -Darguments=-DskipTests release:prepare release:perform -DautoVersionSubmodules=true -DscmCommentPrefix="$TRAVIS_COMMIT_MESSAGE [skip ci] " -B -V -s travis-settings.xml | ||
|
||
mvn clean | ||
commit_to_develop | ||
|
||
# extends release.sh | ||
for script_file in $RELEASE_EXEC_FILES; do | ||
. $script_file | ||
done |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIRNAME=$(dirname $0) | ||
AFTER_SUCCESS_EXEC_FILES=$(find $DIRNAME -name 'after-success-*.sh') | ||
|
||
echo Running $0 | ||
echo *-*-*-*-*-*-*-*-*-*-*-*-*-* | ||
|
||
if [ -z "$CODACY_PROJECT_TOKEN" ]; then | ||
echo [WARNING] Please go to https://app.codacy.com/app/$TRAVIS_REPO_SLUG/settings/coverage and add CODACY_PROJECT_TOKEN to travis settings | ||
else | ||
find -name jacoco.xml | xargs -i java -jar ~/codacy-coverage-reporter-assembly.jar report -l Java --partial -r {} | ||
java -jar ~/codacy-coverage-reporter-assembly.jar final | ||
fi; | ||
|
||
# extends after-success.sh | ||
for script_file in $AFTER_SUCCESS_EXEC_FILES; do | ||
. $script_file | ||
done | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIRNAME=$(dirname $0) | ||
BEFORE_INSTALL_EXEC_FILES=$(find $DIRNAME -name 'before-install-*.sh') | ||
|
||
echo Running $0 | ||
echo *-*-*-*-*-*-*-*-*-*-*-*-*-* | ||
|
||
echo logging to docker image repository: | ||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
|
||
# get latest version of codacy reporter from sonatype | ||
latest=$(curl "https://oss.sonatype.org/service/local/repositories/releases/content/com/codacy/codacy-coverage-reporter/maven-metadata.xml" | xpath -e "/metadata/versioning/release/text()") | ||
|
||
echo Downloading latest version $latest of codacy reporter from sonatype | ||
# download latest assembly jar | ||
mvn dependency:get dependency:copy \ | ||
-DoutputDirectory=$HOME \ | ||
-DoutputAbsoluteArtifactFilename=true \ | ||
-Dmdep.stripVersion=true \ | ||
-DrepoUrl=https://oss.sonatype.org/service/local/repositories/releases/content/ \ | ||
-Dartifact=com.codacy:codacy-coverage-reporter:$latest:jar:assembly | ||
|
||
echo local file md5sum: | ||
md5sum ~/codacy-coverage-reporter-assembly.jar | ||
echo remote file md5sum: | ||
curl "https://oss.sonatype.org/service/local/repositories/releases/content/com/codacy/codacy-coverage-reporter/$latest/codacy-coverage-reporter-$latest-assembly.jar.md5" | ||
|
||
# extends before-install.sh | ||
for script_file in $BEFORE_INSTALL_EXEC_FILES; do | ||
. $script_file | ||
done | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<settings | ||
xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd' | ||
xmlns='http://maven.apache.org/SETTINGS/1.0.0' | ||
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> | ||
<profiles> | ||
<profile> | ||
<id>skipstyle</id> | ||
<properties> | ||
<checkstyle.skip>true</checkstyle.skip> | ||
</properties> | ||
</profile> | ||
<profile> | ||
<id>skippmd</id> | ||
<properties> | ||
<pmd.skip>true</pmd.skip> | ||
</properties> | ||
</profile> | ||
<profile> | ||
<id>bintray</id> | ||
<repositories> | ||
<repository> | ||
<id>central</id> | ||
<name>bintray</name> | ||
<url>http://jcenter.bintray.com</url> | ||
<snapshots> | ||
<enabled>false</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
</profile> | ||
<profile> | ||
<id>ossrh</id> | ||
<properties> | ||
<gpg.passphrase>${env.GPG_KEY}</gpg.passphrase> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
<servers> | ||
<server> | ||
<id>ossrh</id> | ||
<username>${env.SONATYPE_USERNAME}</username> | ||
<password>${env.SONATYPE_PASSWORD}</password> | ||
</server> | ||
<server> | ||
<id>docker.io</id> | ||
<username>${env.DOCKER_USERNAME}</username> | ||
<password>${env.DOCKER_PASSWORD}</password> | ||
</server> | ||
</servers> | ||
<activeProfiles> | ||
<activeProfile>bintray</activeProfile> | ||
<activeProfile>ossrh</activeProfile> | ||
</activeProfiles> | ||
</settings> |