-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #22597 - servo:tc-pr, r=jdm
Taskcluster: run tidy on PRs Taskcluster: run tasks for PRs from everyone These tasks should be untrusted, since they run before review. The `repo:github.com/servo/servo:pull-request` role determines what scopes (permissions) those tasks have. https://tools.taskcluster.net/auth/roles/repo%3Agithub.com%2Fservo%2Fservo%3Apull-request ~For more paranoia, we could run these tasks on entirely separate worker types (machine pools). For now, maybe being careful to to give scopes for any kind of write access is hopefully enough.~ There seems to be no way to disable the "docker-in-docker" feature, which could allow tasks to escalate to root on the host worker. So this uses a separate `servo-docker-untrusted` worker type. To manage cost, these workers are configured with `minCapacity: 0` and to shut down after 2 minutes idle. (This is a trade-off with the latency of spinning up new AWS EC2 instances.) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22597) <!-- Reviewable:end -->
- Loading branch information
Showing
5 changed files
with
205 additions
and
69 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 |
---|---|---|
@@ -1,67 +1,100 @@ | ||
version: 1 | ||
policy: | ||
# https://docs.taskcluster.net/docs/reference/integrations/taskcluster-github/docs/taskcluster-yml-v1#pull-requests | ||
pullRequests: collaborators | ||
pullRequests: public | ||
|
||
# NOTE: when updating this consider whether the daily hook needs similar changes: | ||
# https://tools.taskcluster.net/hooks/project-servo/daily | ||
tasks: | ||
- $if: 'tasks_for == "github-push"' | ||
then: | ||
$if: >- | ||
event.ref in ["refs/heads/auto", "refs/heads/try", "refs/heads/master"] || | ||
event.ref[:15] == "refs/heads/try-" | ||
$let: | ||
task_common: | ||
provisionerId: aws-provisioner-v1 | ||
created: {$fromNow: ''} | ||
deadline: {$fromNow: '1 day'} | ||
extra: | ||
treeherder: | ||
machine: {platform: Linux} | ||
labels: [x64] | ||
symbol: Decision | ||
payload: | ||
maxRunTime: {$eval: '20 * 60'} | ||
# https://github.com/servo/taskcluster-bootstrap-docker-images#decision-task | ||
image: "servobrowser/taskcluster-bootstrap:decision-task@sha256:28045b7ec0485ef363f8cb14f194008b47e9ede99f2ea40a1e945e921fce976e" | ||
features: | ||
taskclusterProxy: true | ||
env: | ||
GIT_URL: ${event.repository.clone_url} | ||
TASK_FOR: ${tasks_for} | ||
command: | ||
- /bin/bash | ||
- '--login' | ||
- '-e' | ||
- '-c' | ||
- >- | ||
git init repo && | ||
cd repo && | ||
git fetch --depth 1 "$GIT_URL" "$GIT_REF" && | ||
git reset --hard "$GIT_SHA" && | ||
python3 etc/taskcluster/decision_task.py | ||
in: | ||
- $if: "tasks_for == 'github-push'" | ||
then: | ||
$let: | ||
branch: | ||
$if: "event.ref[:11] == 'refs/heads/'" | ||
then: "${event.ref[11:]}" | ||
in: | ||
$if: "branch in ['auto', 'try', 'master'] || branch[:4] == 'try-'" | ||
then: | ||
$mergeDeep: | ||
- {$eval: "task_common"} | ||
- metadata: | ||
name: "Servo: GitHub push decision task" | ||
description: "" | ||
owner: ${event.pusher.name}@users.noreply.github.com | ||
source: ${event.compare} | ||
workerType: servo-docker-worker | ||
scopes: | ||
- "assume:repo:github.com/servo/servo:branch:${branch}" | ||
routes: | ||
$let: | ||
treeherder_repo: | ||
$if: "branch[:4] == 'try-'" | ||
then: "servo-${branch}" | ||
else: "servo-try" | ||
in: | ||
- "tc-treeherder.v2._/${treeherder_repo}.${event.after}" | ||
- "tc-treeherder-staging.v2._/${treeherder_repo}.${event.after}" | ||
payload: | ||
env: | ||
GIT_REF: ${event.ref} | ||
GIT_SHA: ${event.after} | ||
TASK_OWNER: ${event.pusher.name}@users.noreply.github.com | ||
TASK_SOURCE: ${event.compare} | ||
- $if: >- | ||
tasks_for == 'github-pull-request' && | ||
event['action'] in ['opened', 'reopened', 'synchronize'] | ||
then: | ||
$mergeDeep: | ||
- {$eval: "task_common"} | ||
- metadata: | ||
name: "Servo: GitHub PR decision task" | ||
description: "" | ||
owner: ${event.sender.login}@users.noreply.github.com | ||
source: ${event.pull_request.url} | ||
workerType: servo-docker-untrusted | ||
scopes: | ||
- "assume:repo:github.com/servo/servo:pull-request" | ||
routes: | ||
- "tc-treeherder.v2._/servo-prs.${event.pull_request.head.sha}" | ||
- "tc-treeherder-staging.v2._/servo-prs.${event.pull_request.head.sha}" | ||
payload: | ||
env: | ||
# We use the merge commit made by GitHub, not the PR’s branch | ||
GIT_REF: refs/pull/${event.pull_request.number}/merge | ||
# `event.pull_request.merge_commit_sha` is tempting but not what we want: | ||
# https://github.com/servo/servo/pull/22597#issuecomment-451518810 | ||
GIT_SHA: FETCH_HEAD | ||
TASK_OWNER: ${event.sender.login}@users.noreply.github.com | ||
TASK_SOURCE: ${event.pull_request.url} | ||
# NOTE: when updating this consider whether the daily hook needs similar changes: | ||
# https://tools.taskcluster.net/hooks/project-servo/daily | ||
|
||
taskGroupId: {$eval: as_slugid("decision_task")} | ||
taskId: {$eval: as_slugid("decision_task")} | ||
provisionerId: aws-provisioner-v1 | ||
workerType: servo-docker-worker | ||
created: {$fromNow: ''} | ||
deadline: {$fromNow: '1 day'} | ||
metadata: | ||
name: "Servo: GitHub push decision task" | ||
description: "" | ||
owner: &task_owner ${event.pusher.name}@users.noreply.github.com | ||
source: &task_source ${event.compare} | ||
scopes: | ||
- "assume:repo:github.com/servo/servo:branch:${event.ref[11:]}" | ||
routes: | ||
$let: | ||
treeherder_repo: | ||
$if: "event.ref[:15] != 'refs/heads/try-'" | ||
then: "servo-${event.ref[11:]}" | ||
else: "servo-try" | ||
in: | ||
- "tc-treeherder.v2._/${treeherder_repo}.${event.after}" | ||
- "tc-treeherder-staging.v2._/${treeherder_repo}.${event.after}" | ||
extra: | ||
treeherder: | ||
machine: {platform: Linux} | ||
labels: [x64] | ||
symbol: Decision | ||
|
||
payload: | ||
maxRunTime: {$eval: '20 * 60'} | ||
# https://github.com/servo/taskcluster-bootstrap-docker-images#decision-task | ||
image: "servobrowser/taskcluster-bootstrap:decision-task@sha256:28045b7ec0485ef363f8cb14f194008b47e9ede99f2ea40a1e945e921fce976e" | ||
features: | ||
taskclusterProxy: true | ||
env: | ||
GIT_URL: ${event.repository.clone_url} | ||
GIT_REF: ${event.ref} | ||
GIT_SHA: ${event.after} | ||
TASK_FOR: ${tasks_for} | ||
TASK_OWNER: *task_owner | ||
TASK_SOURCE: *task_source | ||
command: | ||
- /bin/bash | ||
- '--login' | ||
- '-e' | ||
- '-c' | ||
- >- | ||
git init repo && | ||
cd repo && | ||
git fetch --depth 1 "$GIT_URL" "$GIT_REF" && | ||
git reset --hard "$GIT_SHA" && | ||
python3 etc/taskcluster/decision_task.py |
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
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,72 @@ | ||
#!/bin/bash | ||
|
||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
''''set -e | ||
cd "$(dirname $0)" | ||
exec ../../python/_virtualenv/bin/python "$(basename $0)" | ||
''' | ||
try: | ||
import jsone | ||
except ImportError: | ||
import sys | ||
sys.exit("pip install git+https://github.com/taskcluster/json-e") | ||
import yaml | ||
import json | ||
template = yaml.load(open("../../.taskcluster.yml").read().decode("utf8")) | ||
repo = dict( | ||
repository=dict( | ||
clone_url="https://github.com/servo/servo.git", | ||
), | ||
) | ||
contexts = [ | ||
dict( | ||
tasks_for="github-release", | ||
event=repo, | ||
), | ||
dict( | ||
tasks_for="github-pull-request", | ||
event=dict( | ||
action="comment", | ||
**repo | ||
), | ||
), | ||
dict( | ||
tasks_for="github-push", | ||
event=dict( | ||
ref="refs/heads/master", | ||
compare="https://github.com/servo/servo/compare/1753cda...de09c8f", | ||
after="de09c8fb6ef87dec5932d5fab4adcb421d291a54", | ||
pusher=dict( | ||
name="bors-servo", | ||
), | ||
**repo | ||
), | ||
), | ||
dict( | ||
tasks_for="github-pull-request", | ||
event=dict( | ||
action="synchronize", | ||
pull_request=dict( | ||
number=22583, | ||
url="https://github.com/servo/servo/pull/22583", | ||
head=dict( | ||
sha="51a422c9ef47420eb69c802643b7686bdb498652", | ||
), | ||
merge_commit_sha="876fcf7a5fe971a9ac0a4ce117906c552c08c095", | ||
), | ||
sender=dict( | ||
login="jdm", | ||
), | ||
**repo | ||
), | ||
), | ||
] | ||
for context in contexts: | ||
print(context["tasks_for"]) | ||
print(json.dumps(jsone.render(template, context), indent=2)) |