Skip to content

Commit 2c000af

Browse files
committed
feat(ci): connect repo to Community-TC
1 parent 1fc8f5f commit 2c000af

File tree

11 files changed

+708
-9
lines changed

11 files changed

+708
-9
lines changed

.git-template/hooks/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
if [ -f .pre-commit-config.yaml ]; then
3+
echo 'pre-commit configuration detected, but `pre-commit install` was never run' 1>&2
4+
exit 1
5+
fi

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.3.0
6+
hooks:
7+
# Trims trailing whitespace
8+
- id: trailing-whitespace
9+
# Makes sure files end in a newline and only a newline
10+
- id: end-of-file-fixer
11+
# Check for files that contain merge conflict strings
12+
- id: check-merge-conflict
13+
14+
- repo: https://github.com/marco-c/taskcluster_yml_validator
15+
rev: v0.0.9
16+
hooks:
17+
# Validates .taskcluster.yml file against possible GitHub events
18+
- id: taskcluster_yml
19+
20+
ci:
21+
skip: [taskcluster_yml]

.taskcluster.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
version: 1
3+
reporting: checks-v1
4+
policy:
5+
pullRequests: public
6+
tasks:
7+
- $let:
8+
ownerEmail:
9+
$if: 'tasks_for == "github-push"'
10+
then: '${event.pusher.email}'
11+
else:
12+
$if: 'tasks_for == "github-pull-request"'
13+
then: '${event.pull_request.user.login}@users.noreply.github.com'
14+
else:
15+
$if: 'tasks_for == "github-release"'
16+
then: '${event.sender.login}@users.noreply.github.com'
17+
baseRepoUrl:
18+
$if: 'tasks_for == "github-push"'
19+
then: '${event.repository.html_url}'
20+
else:
21+
$if: 'tasks_for == "github-pull-request"'
22+
then: '${event.pull_request.base.repo.html_url}'
23+
base_ref:
24+
$if: 'tasks_for[:19] == "github-pull-request"'
25+
then: ${event.pull_request.base.ref}
26+
else:
27+
# event.base_ref is barely documented[1]. Testing showed it's only
28+
# defined when creating a new branch. It's null when pushing to an
29+
# existing branch
30+
#
31+
# [1] https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push
32+
# [2] https://taskcluster-taskgraph.readthedocs.io/en/latest/reference/parameters.html#base-ref
33+
$if: 'tasks_for == "github-push" && event.base_ref'
34+
then: ${event.base_ref}
35+
else:
36+
$if: 'tasks_for == "github-push"'
37+
then: ${event.ref}
38+
else:
39+
$if: 'tasks_for in ["cron", "action"]'
40+
then: '${push.branch}'
41+
repoUrl:
42+
$if: 'tasks_for == "github-push"'
43+
then: '${event.repository.html_url}'
44+
else:
45+
$if: 'tasks_for == "github-pull-request"'
46+
then: '${event.pull_request.head.repo.html_url}'
47+
project:
48+
$if: 'tasks_for == "github-push"'
49+
then: '${event.repository.name}'
50+
else:
51+
$if: 'tasks_for == "github-pull-request"'
52+
then: '${event.pull_request.head.repo.name}'
53+
headBranch:
54+
$if: 'tasks_for == "github-pull-request"'
55+
then: ${event.pull_request.head.ref}
56+
else:
57+
$if: 'tasks_for == "github-push"'
58+
then: ${event.ref}
59+
headSha:
60+
$if: 'tasks_for == "github-push"'
61+
then: '${event.after}'
62+
else:
63+
$if: 'tasks_for == "github-pull-request"'
64+
then: '${event.pull_request.head.sha}'
65+
pullRequestAction:
66+
$if: 'tasks_for == "github-pull-request"'
67+
then: ${event.action}
68+
else: 'UNDEFINED'
69+
in:
70+
$if: >
71+
tasks_for == "github-push" && headBranch == "main"
72+
|| (tasks_for == "github-pull-request" && pullRequestAction in ["opened", "reopened", "synchronize"])
73+
then:
74+
taskId: {$eval: as_slugid("decision_task")}
75+
taskGroupId: {$eval: as_slugid("decision_task")}
76+
created: {$fromNow: ''}
77+
deadline: {$fromNow: '1 day'}
78+
expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors
79+
metadata:
80+
owner: "${ownerEmail}"
81+
name: Decision Task
82+
description: Task that generates a taskgraph and submits it to Taskcluster
83+
source: '${repoUrl}/raw/${headSha}/.taskcluster.yml'
84+
provisionerId: proj-taskcluster
85+
workerType: ci
86+
scopes:
87+
$if: 'tasks_for == "github-push"'
88+
then:
89+
# ${repoUrl[8:]} strips out the leading 'https://'
90+
# while ${headBranch[11:]} strips out 'refs/heads/'
91+
- 'assume:repo:${repoUrl[8:]}:branch:${headBranch[11:]}'
92+
else:
93+
$if: 'tasks_for == "github-pull-request"'
94+
then:
95+
- 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
96+
dependencies: []
97+
requires: all-completed
98+
payload:
99+
image: mozillareleases/taskgraph:decision-d1ddb5593679cec9d7d2cdd8e9b8e2228b14ebe9b844411276cc3cfe37d189aa@sha256:b236321d98367f9cdbbd28c47bad7c0df34884897b75d266185d2e9e569ac0fa
100+
features:
101+
taskclusterProxy: true
102+
maxRunTime: 300
103+
env:
104+
$merge:
105+
# run-task uses these environment variables to clone your
106+
# repo and checkout the proper revision
107+
- HOMEBREW_BASE_REPOSITORY: '${baseRepoUrl}'
108+
HOMEBREW_BASE_REF: '${base_ref}'
109+
HOMEBREW_HEAD_REPOSITORY: '${repoUrl}'
110+
HOMEBREW_HEAD_REF: '${headBranch}'
111+
HOMEBREW_HEAD_REV: '${headSha}'
112+
HOMEBREW_PIP_REQUIREMENTS: taskcluster/requirements.txt
113+
HOMEBREW_REPOSITORY_TYPE: git
114+
REPOSITORIES: {$json: {homebrew: "homebrew"}}
115+
command:
116+
- run-task
117+
- '--homebrew-checkout=/builds/worker/checkouts/src'
118+
- '--task-cwd=/builds/worker/checkouts/src'
119+
- '--'
120+
- bash
121+
- -cx
122+
- >
123+
~/.local/bin/taskgraph decision
124+
--pushlog-id='0'
125+
--pushdate='0'
126+
--project='${project}'
127+
--message=""
128+
--owner='${ownerEmail}'
129+
--level='1'
130+
--base-repository="$HOMEBREW_BASE_REPOSITORY"
131+
--base-ref="$HOMEBREW_BASE_REF"
132+
--head-repository="$HOMEBREW_HEAD_REPOSITORY"
133+
--head-ref="$HOMEBREW_HEAD_REF"
134+
--head-rev="$HOMEBREW_HEAD_REV"
135+
--repository-type="$HOMEBREW_REPOSITORY_TYPE"
136+
--tasks-for='${tasks_for}'
137+
artifacts:
138+
'public':
139+
type: 'directory'
140+
path: '/builds/worker/artifacts'
141+
expires: {$fromNow: '1 year'}

Formula/taskcluster.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
# Homebrew formula for taskcluster CLI
14
class Taskcluster < Formula
2-
desc "A Taskcluster client library for the command line"
5+
desc "Client library for the Taskcluster CLI"
36
homepage "https://github.com/taskcluster/taskcluster/tree/main/clients/client-shell"
4-
version "v44.17.2"
7+
version "44.23.4"
58
license "MPL-2.0"
69

710
if OS.mac?
811
if Hardware::CPU.physical_cpu_arm64?
9-
url "https://github.com/taskcluster/taskcluster/releases/download/#{version}/taskcluster-darwin-arm64", :using => :curl
10-
sha256 "1ccf56972988f45c88e9a21a536728f1064eabef49a9d085e16ac41db14214a5"
12+
url "https://github.com/taskcluster/taskcluster/releases/download/v#{version}/taskcluster-darwin-arm64"
13+
sha256 "fe1ae43849952a5797edcad202b12ca138498c8530057ec6e2add3c78f1ddee4"
1114
else
12-
url "https://github.com/taskcluster/taskcluster/releases/download/#{version}/taskcluster-darwin-amd64", :using => :curl
13-
sha256 "7897baf6c27350e5a6fe46e93f9bb4890f5dd98a117196acfb4267e639624a5c"
15+
url "https://github.com/taskcluster/taskcluster/releases/download/v#{version}/taskcluster-darwin-amd64"
16+
sha256 "c8c613d722122cce47a8df2189f5e278211ec71ad093533d363c88161d60f2e8"
1417
end
1518
elsif OS.linux?
16-
url "https://github.com/taskcluster/taskcluster/releases/download/#{version}/taskcluster-linux-amd64", :using => :curl
17-
sha256 "d12b40c048e96bd5376f9d28c4831075ee6b74b3c8b9bd3d85f57cc1a9ec1971"
19+
url "https://github.com/taskcluster/taskcluster/releases/download/v#{version}/taskcluster-linux-amd64"
20+
sha256 "618203d0fe3d6938b635b4d89d39507f608db5027fda55ebcabf251a1da0fa39"
1821
end
1922

2023
def install
@@ -30,6 +33,6 @@ def install
3033
end
3134

3235
test do
33-
system "#{bin}/taskcluster --help"
36+
system "#{bin}/taskcluster", "--help"
3437
end
3538
end

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ brew install taskcluster/tap/taskcluster
2727
brew install taskcluster
2828
```
2929

30+
### Testing Formulae
31+
32+
To test any changes to a specific formula, such as `taskcluster`, you can use the following commands:
33+
34+
```bash
35+
# check formula for Homebrew coding style violations
36+
brew audit --strict --online --formula ./Formula/taskcluster.rb
37+
```
38+
```bash
39+
# check to be sure formula can be installed still
40+
brew install --formula ./Formula/taskcluster.rb
41+
```
42+
```bash
43+
# run tests for formula
44+
brew test --verbose ./Formula/taskcluster.rb
45+
```
46+
3047
### Uninstalling Formulae
3148

3249
To uninstall a specific formula, such as `taskcluster`, you can use the following command:

taskcluster/ci/config.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
trust-domain: homebrew
3+
treeherder:
4+
group-names:
5+
'I': 'Docker Image Builds'
6+
7+
task-priority: low
8+
9+
taskgraph:
10+
repositories:
11+
ci:
12+
name: homebrew
13+
14+
workers:
15+
aliases:
16+
images:
17+
provisioner: proj-taskcluster
18+
os: linux
19+
implementation: docker-worker
20+
worker-type: ci
21+
ci:
22+
provisioner: proj-taskcluster
23+
os: linux
24+
implementation: docker-worker
25+
worker-type: ci

taskcluster/ci/docker-image/kind.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
loader: taskgraph.loader.transform:loader
2+
3+
transforms:
4+
- taskgraph.transforms.docker_image:transforms
5+
- taskgraph.transforms.cached_tasks:transforms
6+
- taskgraph.transforms.task:transforms
7+
8+
tasks:
9+
homebrew:
10+
symbol: I(homebrew-image)

taskcluster/ci/homebrew/kind.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
loader: taskgraph.loader.transform:loader
3+
4+
transforms:
5+
- taskgraph.transforms.job:transforms
6+
- taskgraph.transforms.task:transforms
7+
8+
tasks:
9+
homebrew:
10+
description: brew {audit, install, test}
11+
worker-type: ci
12+
worker:
13+
max-run-time: 300
14+
docker-image:
15+
in-tree: homebrew
16+
run:
17+
using: run-task
18+
cwd: '{checkout}'
19+
cache-dotcache: true
20+
command: >-
21+
brew audit --strict --online --formula ./Formula/taskcluster.rb &&
22+
brew install --formula ./Formula/taskcluster.rb &&
23+
brew test ./Formula/taskcluster.rb
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM homebrew/brew
2+
3+
RUN sudo apt-get update && \
4+
sudo apt-get upgrade -y && \
5+
brew update && \
6+
brew upgrade && \
7+
brew cleanup
8+
9+
VOLUME /builds/worker/checkouts
10+
VOLUME /builds/worker/.cache
11+
12+
# Set a default command useful for debugging
13+
CMD ["/bin/bash", "--login"]

taskcluster/requirements.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# For instructions on managing dependencies, see:
2+
# https://taskcluster-taskgraph.readthedocs.io/en/latest/howto/bootstrap-taskgraph.html
3+
4+
arrow
5+
pyyaml
6+
taskcluster
7+
taskcluster-taskgraph

0 commit comments

Comments
 (0)