mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Taskcluster: run tidy on PRs
This commit is contained in:
parent
0700aeb4f7
commit
5d0dbd6355
3 changed files with 128 additions and 65 deletions
151
.taskcluster.yml
151
.taskcluster.yml
|
@ -2,64 +2,99 @@ version: 1
|
||||||
policy:
|
policy:
|
||||||
# https://docs.taskcluster.net/docs/reference/integrations/taskcluster-github/docs/taskcluster-yml-v1#pull-requests
|
# https://docs.taskcluster.net/docs/reference/integrations/taskcluster-github/docs/taskcluster-yml-v1#pull-requests
|
||||||
pullRequests: public
|
pullRequests: public
|
||||||
|
|
||||||
|
# NOTE: when updating this consider whether the daily hook needs similar changes:
|
||||||
|
# https://tools.taskcluster.net/hooks/project-servo/daily
|
||||||
tasks:
|
tasks:
|
||||||
- $if: 'tasks_for == "github-push"'
|
$let:
|
||||||
then:
|
task_common:
|
||||||
$if: >-
|
provisionerId: aws-provisioner-v1
|
||||||
event.ref in ["refs/heads/auto", "refs/heads/try", "refs/heads/master"] ||
|
created: {$fromNow: ''}
|
||||||
event.ref[:15] == "refs/heads/try-"
|
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:
|
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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -10,11 +10,11 @@ from decisionlib import CONFIG, SHARED
|
||||||
|
|
||||||
|
|
||||||
def main(task_for):
|
def main(task_for):
|
||||||
assert CONFIG.git_ref.startswith("refs/heads/")
|
if CONFIG.git_ref.startswith("refs/heads/"):
|
||||||
branch = CONFIG.git_ref[len("refs/heads/"):]
|
branch = CONFIG.git_ref[len("refs/heads/"):]
|
||||||
CONFIG.treeherder_repository_name = "servo-" + (
|
CONFIG.treeherder_repository_name = "servo-" + (
|
||||||
branch if not branch.startswith("try-") else "try"
|
branch if not branch.startswith("try-") else "try"
|
||||||
)
|
)
|
||||||
|
|
||||||
if task_for == "github-push":
|
if task_for == "github-push":
|
||||||
# FIXME https://github.com/servo/servo/issues/22325 implement these:
|
# FIXME https://github.com/servo/servo/issues/22325 implement these:
|
||||||
|
@ -72,6 +72,16 @@ def main(task_for):
|
||||||
for function in by_branch_name.get(branch, []):
|
for function in by_branch_name.get(branch, []):
|
||||||
function()
|
function()
|
||||||
|
|
||||||
|
elif task_for == "github-pull-request":
|
||||||
|
CONFIG.treeherder_repository_name = "servo-prs"
|
||||||
|
|
||||||
|
# We want the merge commit that GitHub creates for the PR.
|
||||||
|
# The event does contain a `pull_request.merge_commit_sha` key, but it is wrong:
|
||||||
|
# https://github.com/servo/servo/pull/22597#issuecomment-451518810
|
||||||
|
CONFIG.git_sha_is_current_head()
|
||||||
|
|
||||||
|
tidy_untrusted()
|
||||||
|
|
||||||
# https://tools.taskcluster.net/hooks/project-servo/daily
|
# https://tools.taskcluster.net/hooks/project-servo/daily
|
||||||
elif task_for == "daily":
|
elif task_for == "daily":
|
||||||
daily_tasks_setup()
|
daily_tasks_setup()
|
||||||
|
@ -120,6 +130,22 @@ windows_sparse_checkout = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def tidy_untrusted():
|
||||||
|
return (
|
||||||
|
decisionlib.DockerWorkerTask("Tidy")
|
||||||
|
.with_worker_type("servo-docker-untrusted")
|
||||||
|
.with_treeherder("Linux x64", "Tidy")
|
||||||
|
.with_max_run_time_minutes(60)
|
||||||
|
.with_dockerfile(dockerfile_path("build"))
|
||||||
|
.with_env(**build_env, **unix_build_env, **linux_build_env)
|
||||||
|
.with_repo()
|
||||||
|
.with_script("""
|
||||||
|
./mach test-tidy --no-progress --all
|
||||||
|
""")
|
||||||
|
.create()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def linux_tidy_unit_docs():
|
def linux_tidy_unit_docs():
|
||||||
return (
|
return (
|
||||||
linux_build_task("Tidy + dev build + unit tests + docs")
|
linux_build_task("Tidy + dev build + unit tests + docs")
|
||||||
|
@ -452,7 +478,7 @@ def daily_tasks_setup():
|
||||||
"expires": SHARED.from_now_json(log_artifacts_expire_in),
|
"expires": SHARED.from_now_json(log_artifacts_expire_in),
|
||||||
})
|
})
|
||||||
|
|
||||||
# Unlike when reacting to a GitHub event,
|
# Unlike when reacting to a GitHub push event,
|
||||||
# the commit hash is not known until we clone the repository.
|
# the commit hash is not known until we clone the repository.
|
||||||
CONFIG.git_sha_is_current_head()
|
CONFIG.git_sha_is_current_head()
|
||||||
|
|
||||||
|
@ -511,7 +537,6 @@ def linux_build_task(name, *, build_env=build_env):
|
||||||
.with_dockerfile(dockerfile_path("build"))
|
.with_dockerfile(dockerfile_path("build"))
|
||||||
.with_env(**build_env, **unix_build_env, **linux_build_env)
|
.with_env(**build_env, **unix_build_env, **linux_build_env)
|
||||||
.with_repo()
|
.with_repo()
|
||||||
.with_index_and_artifacts_expire_in(build_artifacts_expire_in)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@ os.environ.update(**{k: k for k in "TASK_ID TASK_OWNER TASK_SOURCE GIT_URL GIT_S
|
||||||
os.environ["GIT_REF"] = "refs/heads/auto"
|
os.environ["GIT_REF"] = "refs/heads/auto"
|
||||||
import decision_task
|
import decision_task
|
||||||
|
|
||||||
|
print("\n# PR:")
|
||||||
|
decision_task.main("github-pull-request")
|
||||||
|
|
||||||
print("\n# Push:")
|
print("\n# Push:")
|
||||||
decision_task.main("github-push")
|
decision_task.main("github-push")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue