-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added travis package builds * changed travis * fixed travis * fixed travis * updated travis * removed ci * update travis * ut * updated travis * updated travis * removed pip caching * removed coverage * flipped dependencies * ut * updated essentials * add back 3.4 test * updated circle * commit * added init * fixed * flake8 * 36 * more python * added masonite validation * fixed build jobs * trigger ci build * trigger builds * fixed trigger * added build parameter * fix for build parameters * updated for Masonite API * updated for code coverage * fixed dependency for code coverage * fixed for code coverage * fixed coverage * updated trigger build * changed build url
- Loading branch information
1 parent
5a83bb1
commit 34459d4
Showing
4 changed files
with
189 additions
and
25 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,68 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/python:3.6 # primary container for the build job | ||
steps: | ||
- checkout | ||
- run: make | ||
- run: make ci | ||
python3.4: | ||
docker: | ||
- image: circleci/python:3.4 | ||
steps: | ||
- checkout | ||
- run: make | ||
- run: make ci | ||
python3.5: | ||
docker: | ||
- image: circleci/python:3.5 | ||
steps: | ||
- checkout | ||
- run: make | ||
- run: make ci | ||
python3.7: | ||
docker: | ||
- image: circleci/python:3.7 | ||
steps: | ||
- checkout | ||
- run: make | ||
- run: make ci | ||
Masonite Validation: | ||
docker: | ||
- image: circleci/python:3.6 | ||
steps: | ||
- checkout | ||
- run: python trigger_build.py --repo masoniteframework/validation --branch circle-ci --build MASONITE_DEPENDENT_BRANCH=$CIRCLE_BRANCH | ||
Masonite API: | ||
docker: | ||
- image: circleci/python:3.6 | ||
steps: | ||
- checkout | ||
- run: python trigger_build.py --repo masoniteframework/api --branch 2.2 --build MASONITE_DEPENDENT_BRANCH=$CIRCLE_BRANCH | ||
Code Coverage: | ||
docker: | ||
- image: circleci/python:3.6 | ||
steps: | ||
- checkout | ||
- run: pip install -r requirements.txt --user | ||
- run: make coverage | ||
- run: make deepsource | ||
|
||
workflows: | ||
version: 2 | ||
build_and_test: | ||
jobs: | ||
- build | ||
- python3.4 | ||
- python3.5 | ||
- python3.7 | ||
- Masonite Validation: | ||
requires: | ||
- build | ||
- Masonite API: | ||
requires: | ||
- build | ||
- Code Coverage: | ||
requires: | ||
- build |
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
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
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,88 @@ | ||
""" | ||
This is a script to easily execute circle CI jobs from other repository builds. | ||
Useful if you have a dependent build that you need to run to ensure the latest code is up to date with the parent build. | ||
This script will: | ||
- Fire a build in another circle CI repository | ||
- Loop and call the build_url to continuously get the status | ||
- Wait until the job finishes | ||
- If the job fails this script will exit 1 which will fail the job. | ||
- Else it will exit 0 which will pass the job. | ||
**You will need to download this script and put it in the base of your repository** | ||
Usage: | ||
- python trigger_build.py --repo user/repo --branch branch_name --token CIRCLE_TOKEN --build ENV_VARIABLE=value --build ENV_VARIABLE2=value2 | ||
Example: | ||
- python trigger_build.py --repo masoniteframework/validation --branch circle-ci --token $CIRCLE_TOKEN --build MASONITE_BRANCH=$CIRCLE_BRANCH | ||
NOTE: You can get your CircleCI access token via your dashboard. If no token is specified it will use the CIRCLE_TOKEN in your job dashboard. | ||
So if you don't want to pass in the token then put it in the environment variable in your job's dashboard. | ||
Example config: | ||
version: 2 | ||
jobs: | ||
Masonite Validation: | ||
docker: | ||
- image: circleci/python:3.6 | ||
steps: | ||
- checkout | ||
- run: python trigger_build.py --repo masoniteframework/validation --branch circle-ci --build MASONITE_DEPENDENT_BRANCH=$CIRCLE_BRANCH | ||
""" | ||
|
||
import requests | ||
import time | ||
import os | ||
import argparse | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("-r", "--repo", help="Repository name") | ||
parser.add_argument("-b", "--branch", help="Branch name") | ||
parser.add_argument("-t", "--token", help="Circle CI Token") | ||
parser.add_argument('-a', '--build', action='append', help='Set Build Arguments') | ||
parser.add_argument('-p', '--poll', help='How long the script should sleep before checking status') | ||
args = parser.parse_args() | ||
|
||
repo = args.repo | ||
branch = args.branch or 'master' | ||
token = args.token or os.getenv('CIRCLE_TOKEN') | ||
poll = args.poll or 5 | ||
|
||
if os.getenv('CIRCLE_PR_NUMBER'): | ||
repo = os.getenv('CIRCLE_PR_USERNAME') + '/' + os.getenv('CIRCLE_PR_REPONAME') | ||
branch = os.getenv('CIRCLE_BRANCH') | ||
print('Pull Request #{} Detected. Changing build repo to: {} and branch to {}'.format(os.getenv('CIRCLE_PR_NUMBER'), repo, branch)) | ||
|
||
parameters = {} | ||
for argument in args.build or []: | ||
if not '=' in argument: | ||
print("ERROR: '--build' argument must contain a '=' sign. Got '{}'".format(argument)) | ||
exit(1) | ||
key = argument.split('=')[0] | ||
value = argument.split('=')[1] | ||
|
||
parameters.update({key: value}) | ||
|
||
build_parameters = {'build_parameters': parameters} | ||
|
||
r = requests.post('https://circleci.com/api/v1/project/{}/tree/{}?circle-token={}'.format(repo, branch, token), json=build_parameters) | ||
|
||
if 'build_num' not in r.json(): | ||
print('ERROR: Could not find repository {} or with the branch {}'.format(repo, branch)) | ||
print(r.json()) | ||
exit(1) | ||
|
||
print('Building: ', r.json()['build_num']) | ||
|
||
status = requests.get('https://circleci.com/api/v1.1/project/github/{}/{}?circle-token={}'.format(repo, r.json()['build_num'], token)) | ||
print('Build Status: ', status.json()['lifecycle']) | ||
while status.json()['lifecycle'] != 'finished': | ||
time.sleep(poll) | ||
print('Build Status: ', status.json()['lifecycle']) | ||
status = requests.get('https://circleci.com/api/v1.1/project/github/{}/{}?circle-token={}'.format(repo, r.json()['build_num'], token)) | ||
|
||
print('Finished. Failed? ', status.json()['failed']) | ||
if status.json()['failed']: | ||
exit(1) |