Skip to content

Commit 92a38b2

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

File tree

11 files changed

+754
-9
lines changed

11 files changed

+754
-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: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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+
schedulerId: homebrew-level-1
77+
created: {$fromNow: ''}
78+
deadline: {$fromNow: '1 day'}
79+
expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors
80+
metadata:
81+
owner: "${ownerEmail}"
82+
name: Decision Task
83+
description: Task that generates a taskgraph and submits it to Taskcluster
84+
source: '${repoUrl}/raw/${headSha}/.taskcluster.yml'
85+
provisionerId: proj-taskcluster
86+
workerType: ci
87+
scopes:
88+
$if: 'tasks_for == "github-push"'
89+
then:
90+
# ${repoUrl[8:]} strips out the leading 'https://'
91+
# while ${headBranch[11:]} strips out 'refs/heads/'
92+
- 'assume:repo:${repoUrl[8:]}:branch:${headBranch[11:]}'
93+
else:
94+
$if: 'tasks_for == "github-pull-request"'
95+
then:
96+
- 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
97+
dependencies: []
98+
requires: all-completed
99+
payload:
100+
image: mozillareleases/taskgraph:decision-d1ddb5593679cec9d7d2cdd8e9b8e2228b14ebe9b844411276cc3cfe37d189aa@sha256:b236321d98367f9cdbbd28c47bad7c0df34884897b75d266185d2e9e569ac0fa
101+
cache:
102+
homebrew-level-1-checkouts-sparse-v2: /builds/worker/checkouts
103+
features:
104+
taskclusterProxy: true
105+
# chainOfTrust: true
106+
maxRunTime: 300
107+
env:
108+
$merge:
109+
# run-task uses these environment variables to clone your
110+
# repo and checkout the proper revision
111+
- HOMEBREW_BASE_REPOSITORY: '${baseRepoUrl}'
112+
HOMEBREW_BASE_REF: '${base_ref}'
113+
HOMEBREW_HEAD_REPOSITORY: '${repoUrl}'
114+
HOMEBREW_HEAD_REF: '${headBranch}'
115+
HOMEBREW_HEAD_REV: '${headSha}'
116+
HOMEBREW_PIP_REQUIREMENTS: taskcluster/requirements.txt
117+
HOMEBREW_REPOSITORY_TYPE: git
118+
REPOSITORIES: {$json: {homebrew: "homebrew"}}
119+
command:
120+
- run-task
121+
- '--homebrew-checkout=/builds/worker/checkouts/src'
122+
- '--task-cwd=/builds/worker/checkouts/src'
123+
- '--'
124+
- bash
125+
- -cx
126+
- >
127+
~/.local/bin/taskgraph decision
128+
--pushlog-id='0'
129+
--pushdate='0'
130+
--project='${project}'
131+
--message=""
132+
--owner='${ownerEmail}'
133+
--level='1'
134+
--base-repository="$HOMEBREW_BASE_REPOSITORY"
135+
--base-ref="$HOMEBREW_BASE_REF"
136+
--head-repository="$HOMEBREW_HEAD_REPOSITORY"
137+
--head-ref="$HOMEBREW_HEAD_REF"
138+
--head-rev="$HOMEBREW_HEAD_REV"
139+
--repository-type="$HOMEBREW_REPOSITORY_TYPE"
140+
--tasks-for='${tasks_for}'
141+
artifacts:
142+
'public':
143+
type: 'directory'
144+
path: '/builds/worker/artifacts'
145+
expires: {$fromNow: '1 year'}
146+
'public/docker-contexts':
147+
type: 'directory'
148+
path: '/builds/worker/checkouts/src/docker-contexts'
149+
# This needs to be at least the deadline of the
150+
# decision task + the docker-image task deadlines.
151+
# It is set to a week to allow for some time for
152+
# debugging, but they are not useful long-term.
153+
expires: {$fromNow: '7 day'}

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+
tests:
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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM homebrew/brew
2+
3+
USER root
4+
5+
# Add worker user and setup its workspace.
6+
RUN mkdir /builds && \
7+
groupadd -g 1001 worker && \
8+
useradd -u 1001 -g 1001 -d /builds/worker -s /bin/bash -m worker && \
9+
mkdir -p /builds/worker/workspace && \
10+
chown -R worker:worker /builds && \
11+
apt-get update && \
12+
apt-get upgrade -y
13+
14+
USER linuxbrew
15+
16+
RUN brew update && \
17+
brew upgrade && \
18+
brew cleanup
19+
20+
# Declare default working folder
21+
WORKDIR /builds/worker
22+
23+
ENV SHELL=/bin/bash \
24+
HOME=/builds/worker \
25+
PATH=/builds/worker/.local/bin:$PATH
26+
27+
VOLUME /builds/worker/checkouts
28+
VOLUME /builds/worker/.cache
29+
30+
# Set a default command useful for debugging
31+
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)