To add a new pull request, make a directory with the PR number. Then run generate-all.sh
.
Created
May 10, 2016 16:47
-
-
Save dpb587/37f7f1d188be1cdb7c29930a8bd8f627 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
PR_OFFSET=0 | |
for PR in $( find . -type d ! -name '.*' ! -name 'z*' ) ; do | |
PR=$( basename "$PR" ) | |
echo "==> cloudfoundry/bosh#$PR" | |
./generate.sh $PR $PR_OFFSET | |
PR_OFFSET=$(( $PR_OFFSET + 1 )) | |
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
#!/bin/sh | |
set -eu | |
PR=$1 | |
PR_OFFSET=$2 # used to try and stagger runs; timer uses it to offset and run them overnight during our concourse quiet hours | |
pipeline="bosh:pr-$PR" | |
mkdir -p $PR | |
[ -e $PR/github.json ] \ | |
|| curl -s "https://api.github.com/repos/cloudfoundry/bosh/pulls/$PR" > "$PR/github.json" | |
[ -e $PR/config.json ] \ | |
|| jq -n '{"trusted":false}' > "$PR/config.json" | |
jq -n \ | |
--argfile github "$PR/github.json" \ | |
--argfile pr "$PR/config.json" \ | |
--argfile runtime runtime.json \ | |
--arg offset $PR_OFFSET \ | |
--from-file pipeline.jq \ | |
> "$PR/pipeline.json" | |
echo 'set-pipeline' | |
fly -t $CONCOURSE_TARGET \ | |
set-pipeline \ | |
--load-vars-from runtime.json \ | |
-p "$pipeline" \ | |
-c "$PR/pipeline.json" \ | |
| cat | |
# in theory, pause github-status resources since we don't trigger from them | |
# broken on production ci since it requires auth | |
echo 'pause-resource' | |
for resource in $( jq -r '.resources | map(select("github-status" == .type)) | map(.name)[]' < "$PR/pipeline.json" ) ; do | |
echo $resource | |
curl -s -X PUT "$CONCOURSE_URL/api/v1/pipelines/$pipeline/resources/$resource/pause" | |
done | |
rm $PR/pipeline.json |
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
{ | |
"groups": [ | |
{ | |
"name": "unit", | |
"jobs": [ | |
"unit-1.9", | |
"unit-2.1" | |
] | |
}, | |
{ | |
"name": "integration", | |
"jobs": [ | |
"integration-1.9-postgresql", | |
"integration-2.1-mysql", | |
"integration-2.1-postgresql" | |
] | |
}, | |
{ | |
"name": "ruby:1.9", | |
"jobs": [ | |
"unit-1.9", | |
"integration-1.9-postgresql" | |
] | |
}, | |
{ | |
"name": "ruby:2.1", | |
"jobs": [ | |
"unit-2.1", | |
"integration-2.1-mysql", | |
"integration-2.1-postgresql" | |
] | |
}, | |
{ | |
"name": "db:mysql", | |
"jobs": [ | |
"integration-2.1-mysql" | |
] | |
}, | |
{ | |
"name": "db:postgresql", | |
"jobs": [ | |
"unit-1.9", | |
"unit-2.1", | |
"integration-1.9-postgresql", | |
"integration-2.1-postgresql" | |
] | |
} | |
], | |
"jobs": [ | |
{ | |
"name": "trusted", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "trigger", | |
"trigger": $pr.trusted | |
}, | |
{ | |
"get": "head" | |
} | |
] | |
}, | |
{ | |
"name": "unit-success", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "head", | |
"trigger": true, | |
"passed": [ | |
"unit-1.9", | |
"unit-2.1" | |
] | |
} | |
] | |
}, | |
{ | |
"name": "integration-success", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "head", | |
"trigger": true, | |
"passed": [ | |
"integration-1.9-postgresql", | |
"integration-2.1-postgresql", | |
"integration-2.1-mysql" | |
] | |
} | |
] | |
}, | |
{ | |
"name": "unit-1.9", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "head", | |
"trigger": true, | |
"passed": [ | |
"trusted" | |
] | |
}, | |
{ | |
"put": "unit-1.9-status", | |
"params": { | |
"commit": "head", | |
"state": "pending" | |
} | |
}, | |
{ | |
"task": "tests", | |
"file": "head/ci/tasks/test-unit.yml", | |
"input_mapping": { | |
"bosh-src": "head" | |
}, | |
"params": { | |
"RUBY_VERSION": "1.9.3" | |
}, | |
"on_failure": { | |
"put": "unit-1.9-status", | |
"params": { | |
"commit": "head", | |
"state": "failure" | |
} | |
} | |
}, | |
{ | |
"put": "unit-1.9-status", | |
"params": { | |
"commit": "head", | |
"state": "success" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "unit-2.1", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "head", | |
"trigger": true, | |
"passed": [ | |
"trusted" | |
] | |
}, | |
{ | |
"put": "unit-2.1-status", | |
"params": { | |
"commit": "head", | |
"state": "pending" | |
} | |
}, | |
{ | |
"task": "tests", | |
"file": "head/ci/tasks/test-unit.yml", | |
"input_mapping": { | |
"bosh-src": "head" | |
}, | |
"params": { | |
"RUBY_VERSION": "2.1.7" | |
}, | |
"on_failure": { | |
"put": "unit-2.1-status", | |
"params": { | |
"commit": "head", | |
"state": "failure" | |
} | |
} | |
}, | |
{ | |
"put": "unit-2.1-status", | |
"params": { | |
"commit": "head", | |
"state": "success" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "integration-1.9-postgresql", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "head", | |
"trigger": true, | |
"passed": [ | |
"unit-success" | |
] | |
}, | |
{ | |
"put": "integration-1.9-postgresql-status", | |
"params": { | |
"commit": "head", | |
"state": "pending" | |
} | |
}, | |
{ | |
"task": "tests", | |
"file": "head/ci/tasks/test-integration.yml", | |
"input_mapping": { | |
"bosh-src": "head" | |
}, | |
"params": { | |
"DB": "postgresql", | |
"RUBY_VERSION": "1.9.3" | |
}, | |
"on_failure": { | |
"put": "integration-1.9-postgresql-status", | |
"params": { | |
"commit": "head", | |
"state": "failure" | |
} | |
} | |
}, | |
{ | |
"put": "integration-1.9-postgresql-status", | |
"params": { | |
"commit": "head", | |
"state": "success" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "integration-2.1-mysql", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "head", | |
"trigger": true, | |
"passed": [ | |
"unit-success" | |
] | |
}, | |
{ | |
"put": "integration-2.1-mysql-status", | |
"params": { | |
"commit": "head", | |
"state": "pending" | |
} | |
}, | |
{ | |
"task": "tests", | |
"file": "head/ci/tasks/test-integration.yml", | |
"input_mapping": { | |
"bosh-src": "head" | |
}, | |
"params": { | |
"DB": "mysql", | |
"RUBY_VERSION": "2.1.7" | |
}, | |
"on_failure": { | |
"put": "integration-2.1-mysql-status", | |
"params": { | |
"commit": "head", | |
"state": "failure" | |
} | |
} | |
}, | |
{ | |
"put": "integration-2.1-mysql-status", | |
"params": { | |
"commit": "head", | |
"state": "success" | |
} | |
} | |
] | |
}, | |
{ | |
"name": "integration-2.1-postgresql", | |
"public": true, | |
"plan": [ | |
{ | |
"get": "head", | |
"trigger": true, | |
"passed": [ | |
"unit-success" | |
] | |
}, | |
{ | |
"put": "integration-2.1-postgresql-status", | |
"params": { | |
"commit": "head", | |
"state": "pending" | |
} | |
}, | |
{ | |
"task": "tests", | |
"file": "head/ci/tasks/test-integration.yml", | |
"input_mapping": { | |
"bosh-src": "head" | |
}, | |
"params": { | |
"DB": "postgresql", | |
"RUBY_VERSION": "2.1.7" | |
}, | |
"on_failure": { | |
"put": "integration-2.1-postgresql-status", | |
"params": { | |
"commit": "head", | |
"state": "failure" | |
} | |
} | |
}, | |
{ | |
"put": "integration-2.1-postgresql-status", | |
"params": { | |
"commit": "head", | |
"state": "success" | |
} | |
} | |
] | |
} | |
], | |
"resources": [ | |
{ | |
"name": "trigger", | |
"type": "time", | |
"source": { | |
"interval": "15m", | |
"start": ( ( ( 6 + ( $offset | tonumber ) ) % 24 ) | tostring + ":00 +0000" ), | |
"stop": ( ( ( 7 + ( $offset | tonumber ) ) % 24 ) | tostring + ":00 +0000" ) | |
} | |
}, | |
{ | |
"name": "head", | |
"type": "git", | |
"source": { | |
"uri": ( "[email protected]:" + $github.head.repo.full_name + ".git" ), | |
"branch": $github.head.ref, | |
"private_key": $runtime.git_private_key | |
}, | |
"check_every": "1h" | |
}, | |
{ | |
"name": "unit-1.9-status", | |
"type": "github-status", | |
"source": { | |
"repository": $github.base.repo.full_name, | |
"access_token": $runtime.github_access_token, | |
"branch": ( "pull/" + ( $github.number | tostring ) + "/head" ), | |
"context": "ci/unit/ruby:1.9" | |
} | |
}, | |
{ | |
"name": "unit-2.1-status", | |
"type": "github-status", | |
"source": { | |
"repository": $github.base.repo.full_name, | |
"access_token": $runtime.github_access_token, | |
"branch": ( "pull/" + ( $github.number | tostring ) + "/head" ), | |
"context": "ci/unit/ruby:2.1" | |
} | |
}, | |
{ | |
"name": "integration-1.9-postgresql-status", | |
"type": "github-status", | |
"source": { | |
"repository": $github.base.repo.full_name, | |
"access_token": $runtime.github_access_token, | |
"branch": ( "pull/" + ( $github.number | tostring ) + "/head" ), | |
"context": "ci/integration/ruby:1.9,db:postgresql" | |
} | |
}, | |
{ | |
"name": "integration-2.1-postgresql-status", | |
"type": "github-status", | |
"source": { | |
"repository": $github.base.repo.full_name, | |
"access_token": $runtime.github_access_token, | |
"branch": ( "pull/" + ( $github.number | tostring ) + "/head" ), | |
"context": "ci/integration/ruby:2.1,db:postgresql" | |
} | |
}, | |
{ | |
"name": "integration-2.1-mysql-status", | |
"type": "github-status", | |
"source": { | |
"repository": $github.base.repo.full_name, | |
"access_token": $runtime.github_access_token, | |
"branch": ( "pull/" + ( $github.number | tostring ) + "/head" ), | |
"context": "ci/integration/ruby:2.1,db:mysql" | |
} | |
} | |
], | |
"resource_types": [ | |
{ | |
"name": "github-status", | |
"type": "docker-image", | |
"source": { | |
"repository": "dpb587/github-status-resource", | |
"tag": "master" | |
} | |
} | |
] | |
} as $p | $p + { "groups": ( [ { "name": "all", "jobs": ( $p.jobs | map(.name) ) } ] + $p.groups ) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment