Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared tc dir #5

Merged
merged 31 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
939744e
update .taskcluster.yml for shared
escapewindow Apr 15, 2020
14e14c0
nuke taskcluster/
escapewindow Apr 15, 2020
7794c5a
move GITHUB_CLONE_SECRET to .taskcluster.yml
escapewindow Apr 15, 2020
5413569
add new template parameters
escapewindow Apr 15, 2020
2ceb953
fix
escapewindow Apr 15, 2020
faa2c7e
to_unicode
escapewindow Apr 15, 2020
68feeb3
try backing out the new params
escapewindow Apr 15, 2020
ac74b17
try text_type(...)
escapewindow Apr 15, 2020
d69630a
project-regex
escapewindow Apr 15, 2020
c19cefb
ugh
escapewindow Apr 15, 2020
cd6002c
get env from decision task
escapewindow Apr 15, 2020
82ab504
point at real repo master (commented atm)
escapewindow Apr 15, 2020
f7b3f3a
fix githubCloneSecret
escapewindow Apr 15, 2020
6e3938c
use project-regex for xpi
escapewindow Apr 17, 2020
800d4fc
add checkout: to build and test
escapewindow Apr 17, 2020
b8b9686
default-repository for xpi-template
escapewindow Apr 17, 2020
ca54111
xpi {}
escapewindow Apr 17, 2020
2068ecb
get rid of special template parameter handling
escapewindow Apr 17, 2020
9a2e2ec
fix
escapewindow Apr 17, 2020
0e5a9d7
use --root instead of rm/ln taskcluster
escapewindow Apr 17, 2020
08431f1
back out to ca54111
escapewindow Apr 22, 2020
68d1fb9
re-add parameters.py
escapewindow Apr 22, 2020
7bd92b9
revert back to 0e5a9d7
escapewindow Apr 23, 2020
41b3133
add docker-image kind
escapewindow Apr 27, 2020
b744e36
add docker dir
escapewindow Apr 27, 2020
d196347
use johan's taskgraph-try 12d2c3fb3c584209b9caef89691e81dbffb8129e
escapewindow Apr 27, 2020
94903b9
0dbd05252def2df5c6b5e3322d196499c61ada5a
escapewindow Apr 27, 2020
c511f4e
back out to 9a2e2ec, fix one thing at a time
escapewindow Apr 27, 2020
202ec73
bump to taskgraph c78d65237c6ed064b9cbb3cd063b22e9e052a06a
escapewindow Apr 27, 2020
85da87f
back to b34543ca2f42771117fa9da33c31994913587636
escapewindow Apr 27, 2020
dbe107d
c78d65237c6ed064b9cbb3cd063b22e9e052a06a again
escapewindow Apr 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ tasks:
- $let:
taskgraph:
branch: taskgraph
revision: 2b32db7d303dd175ed4c4abf5fcfe00c6c593acd
revision: b34543ca2f42771117fa9da33c31994913587636
template:
# XXX uncomment to merge
# repo: https://github.com/mozilla-releng/xpi-template
# branch: master
repo: https://github.com/escapewindow/xpi-template
branch: shared-tc-dir
trustDomain: xpi
# XXX for private repos, uncomment this line, and comment out the next
# githubCloneSecret: project/xpi/xpi-github-clone-ssh
githubCloneSecret: ""
in:
$if: 'tasks_for in ["github-pull-request", "github-push", "action", "cron"]'
then:
Expand Down Expand Up @@ -173,12 +182,18 @@ tasks:
XPI_HEAD_REF: '${head_branch}'
XPI_HEAD_REV: '${head_sha}'
XPI_REPOSITORY_TYPE: git
TEMPLATE_BASE_REPOSITORY: '${template.repo}'
TEMPLATE_HEAD_REPOSITORY: '${template.repo}'
TEMPLATE_HEAD_REV: '${template.branch}'
TEMPLATE_HEAD_REF: '${template.branch}'
TEMPLATE_REPOSITORY_TYPE: git
TASKGRAPH_BASE_REPOSITORY: https://hg.mozilla.org/ci/taskgraph
TASKGRAPH_HEAD_REPOSITORY: https://hg.mozilla.org/ci/${taskgraph.branch}
TASKGRAPH_HEAD_REV: '${taskgraph.revision}'
TASKGRAPH_REPOSITORY_TYPE: hg
REPOSITORIES: {$json: {xpi: "XPI Manifest", taskgraph: "Taskgraph"}}
REPOSITORIES: {$json: {xpi: "XPI Manifest", taskgraph: "Taskgraph", template: "XPI Template"}}
HG_STORE_PATH: /builds/worker/checkouts/hg-store
GITHUB_CLONE_SECRET: '${githubCloneSecret}'
- $if: 'tasks_for in ["github-pull-request"]'
then:
XPI_PULL_REQUEST_NUMBER: '${event.pull_request.number}'
Expand All @@ -201,6 +216,7 @@ tasks:
command:
- /usr/local/bin/run-task
- '--xpi-checkout=/builds/worker/checkouts/src'
- '--template-checkout=/builds/worker/checkouts/template'
- '--taskgraph-checkout=/builds/worker/checkouts/taskgraph'
- '--task-cwd=/builds/worker/checkouts/src'
- '--'
Expand All @@ -215,10 +231,12 @@ tasks:
cd /builds/worker/checkouts/src &&
ln -s /builds/worker/artifacts artifacts &&
~/.local/bin/taskgraph action-callback
--root=/builds/worker/checkouts/taskgraph/taskcluster/ci
else: >
PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph &&
ln -s /builds/worker/artifacts artifacts &&
~/.local/bin/taskgraph decision
--root=/builds/worker/checkouts/taskgraph/taskcluster/ci
--pushlog-id='0'
--pushdate='0'
--project='${project}'
Expand Down
2 changes: 2 additions & 0 deletions taskcluster/ci/build/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ job-defaults:
docker-image:
indexed: xpi.cache.level-3.docker-images.v2.node-latest.latest
run:
checkout:
xpi: {}
use-caches: false

jobs:
Expand Down
13 changes: 10 additions & 3 deletions taskcluster/ci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ taskgraph:
repositories:
xpi:
name: "XPI source"
escapewindow marked this conversation as resolved.
Show resolved Hide resolved
project-regex: '(?!xpi-template)'
template:
name: "XPI template"
project-regex: 'xpi-template'
# XXX
#default-repository: https://github.com/mozilla-extensions/xpi-template
#default-ref: master
default-repository: https://github.com/escapewindow/xpi-template
default-ref: shared-tc-dir
type: git

workers:
aliases:
Expand All @@ -16,6 +26,3 @@ workers:
implementation: docker-worker
os: linux
worker-type: 'b-linux'

# Uncomment if this is a private repo
# github_clone_secret: project/xpi/xpi-github-clone-ssh
17 changes: 17 additions & 0 deletions taskcluster/ci/docker-image/kind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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 http://mozilla.org/MPL/2.0/.
---

loader: taskgraph.loader.transform:loader

transforms:
- taskgraph.transforms.docker_image:transforms
- taskgraph.transforms.cached_tasks:transforms
- taskgraph.transforms.task:transforms

jobs:
node-latest:
definition: node
args:
NODE_VERSION: "latest"
2 changes: 2 additions & 0 deletions taskcluster/ci/test/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ job-defaults:
docker-image:
indexed: xpi.cache.level-3.docker-images.v2.node-latest.latest
run:
checkout:
xpi: {}
use-caches: false

jobs:
Expand Down
1 change: 1 addition & 0 deletions taskcluster/docker/REGISTRY
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mozilla-mobile

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mozilla-mobile
mozilla-extensions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these two comments are regarding the xpi-manifest repository. I'll open a PR there to address these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

64 changes: 64 additions & 0 deletions taskcluster/docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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 http://mozilla.org/MPL/2.0/.

FROM ubuntu:18.04

MAINTAINER Tom Prince "mozilla@hocat.ca"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be updated (or removed, I'm not sure how much value it is providing).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mozilla-extensions/xpi-manifest#32 . (The tip of this PR doesn't have any taskcluster/docker; we use the docker image indexes from xpi-manifest. I tried copying the docker directory as part of trying to resolve the --root bustage.)


# Add worker user
RUN mkdir /builds && \
useradd -d /builds/worker -s /bin/bash -m worker && \
chown worker:worker /builds/worker && \
mkdir /builds/worker/artifacts && \
chown worker:worker /builds/worker/artifacts

WORKDIR /builds/worker/

#----------------------------------------------------------------------------------------------------------------------
#-- Configuration -----------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------------

ENV LANG en_US.UTF-8

# Do not use fancy output on taskcluster
ENV TERM dumb

#----------------------------------------------------------------------------------------------------------------------
#-- System ------------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------------

RUN apt-get update -qq \
# We need to install tzdata before all of the other packages. Otherwise it will show an interactive dialog that
# we cannot navigate while building the Docker image.
&& apt-get install -y tzdata \
&& apt-get install -y openjdk-8-jdk \
wget \
expect \
git \
curl \
python \
python-pip \
python3 \
locales \
unzip \
mercurial \
&& apt-get clean

RUN pip install --upgrade pip
RUN pip install 'taskcluster>=4,<5'

RUN locale-gen en_US.UTF-8

# %include-run-task

ENV SHELL=/bin/bash \
HOME=/builds/worker \
PATH=/builds/worker/.local/bin:$PATH


VOLUME /builds/worker/checkouts
VOLUME /builds/worker/.cache

# run-task expects to run as root
USER root
38 changes: 38 additions & 0 deletions taskcluster/docker/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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 http://mozilla.org/MPL/2.0/.

# %ARG NODE_VERSION
FROM node:$NODE_VERSION
MAINTAINER Aki Sasaki <aki@mozilla.com>

RUN echo "deb http://deb.debian.org/debian testing main" >> /etc/apt/sources.list
RUN apt-get update -qq \
&& apt-get remove -y python3 \
&& apt-get install -y zip \
&& apt-get install -y python3.7 \
&& apt-get clean

RUN rm /usr/bin/python3 && ln -s /usr/bin/python3.7 /usr/bin/python3

# Add worker user
RUN mkdir /builds && \
useradd -d /builds/worker -s /bin/bash -m worker -g 1000 -o -u 1000 && \
groupadd -g 1000 -o worker && \
mkdir /builds/worker/artifacts && \
chown worker:worker /builds/worker/artifacts

# %include-run-task

COPY build.py /usr/local/bin/build.py
COPY test.py /usr/local/bin/test.py

ENV SHELL=/bin/bash \
HOME=/builds/worker \
PATH=/builds/worker/.local/bin:$PATH

VOLUME /builds/worker/checkouts
VOLUME /builds/worker/.cache

# Set a default command useful for debugging
CMD ["/bin/bash", "--login"]
130 changes: 130 additions & 0 deletions taskcluster/docker/node/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env python
from __future__ import print_function

import functools
import glob
import hashlib
import json
import os
from pathlib import Path
import shutil
import subprocess
import sys


def test_is_subdir(parent_dir, target_dir):
p1 = Path(os.path.realpath(parent_dir))
p2 = Path(os.path.realpath(target_dir))
if p1 not in p2.parents:
raise Exception("{} is not under {}!".format(target_dir, parent_dir))


def test_var_set(varnames):
"""Test for `varnames` in `os.environ`"""
errors = []
for varname in varnames:
if varname not in os.environ:
errors.append(("error: {} is not set".format(varname)))
if errors:
print("\n".join(errors))
sys.exit(1)


def run_command(command, **kwargs):
print("Running {} ...".format(command))
subprocess.check_call(command, **kwargs)


def get_output(command, **kwargs):
print("Getting output from {} ...".format(command))
return subprocess.check_output(command, **kwargs)


def get_package_info():
if not os.path.exists("package.json"):
raise Exception("Can't find package.json in {}!".format(os.getcwd()))
with open("package.json") as fh:
contents = json.load(fh)
return contents


def cd(path):
print("Changing directory to {} ...".format(path))
os.chdir(path)


def mkdir(path):
print("mkdir {}".format(path))
os.makedirs(path, exist_ok=True)


def get_hash(path, hash_alg="sha256"):
h = hashlib.new(hash_alg)
with open(path, "rb") as fh:
for chunk in iter(functools.partial(fh.read, 4096), b''):
h.update(chunk)
return h.hexdigest()


def main():
test_var_set([
"ARTIFACT_PREFIX",
"XPI_NAME",
])

artifact_prefix = os.environ["ARTIFACT_PREFIX"]
xpi_name = os.environ["XPI_NAME"]
xpi_type = os.environ.get("XPI_TYPE")
repo_prefix = os.environ.get("REPO_PREFIX", "xpi")
head_repo_env_var = "{}_HEAD_REPOSITORY".format(repo_prefix.upper())
test_var_set([head_repo_env_var])

artifact_dir = "/builds/worker/artifacts"
base_src_dir = "/builds/worker/checkouts/src"

package_info = get_package_info()

revision = get_output(["git", "rev-parse", "HEAD"])

build_manifest = {
"name": xpi_name,
"addon-type": xpi_type,
"repo": os.environ[head_repo_env_var],
"revision": revision.decode("utf-8").rstrip(),
"directory": os.path.relpath(base_src_dir, os.getcwd()),
"version": package_info["version"],
"artifacts": [],
}

if os.environ.get("XPI_INSTALL_TYPE", "yarn") == "yarn":
run_command(["yarn", "install", "--frozen-lockfile"])
else:
run_command(["npm", "install"])

run_command(["yarn", "build"])

if 'XPI_ARTIFACTS' in os.environ:
xpi_artifacts = os.environ["XPI_ARTIFACTS"].split(";")
else:
xpi_artifacts = glob.glob('*.xpi')

for artifact in xpi_artifacts:
target_path = os.path.join(artifact_dir, os.path.basename(artifact))
if not os.path.exists(artifact):
raise Exception("Missing artifact {}".format(artifact))
test_is_subdir(os.getcwd(), artifact)
print("Copying {} to {}".format(artifact, target_path))
path = os.path.join(artifact_prefix, os.path.basename(target_path))
artifact_info = {
"path": os.path.join(artifact_prefix, os.path.basename(artifact)),
"filesize_bytes": int(os.path.getsize(artifact)),
"sha256": str(get_hash(artifact)),
}
build_manifest["artifacts"].append(artifact_info)
shutil.copyfile(artifact, target_path)

with open(os.path.join(artifact_dir, "manifest.json"), "w") as fh:
fh.write(json.dumps(build_manifest, indent=2, sort_keys=True))


__name__ == '__main__' and main()
Loading