This commit is contained in:
Rok Garbas 2016-08-24 17:53:02 +02:00
Родитель e6dd2d1359
Коммит b3eb9950fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A0E01EF44C27BF00
75 изменённых файлов: 231 добавлений и 265 удалений

Просмотреть файл

@ -1,3 +0,0 @@
src/relengapi_tools=https://github.com/heroku/heroku-buildpack-nodejs
src/relengapi_tools=https://github.com/garbas/heroku-buildpack-neo
https://github.com/heroku/heroku-buildpack-python

Просмотреть файл

@ -1,30 +1,14 @@
#* *.db
*.o
*.pyc
*.pyo
*~
env/
extern/
node_modules/
elm-stuff/
tmp
vendor/
*.pyc *.pyc
*.swp *.swp
.-rplugin~
/TODO.txt /.floo
/dist/
/docs/build/ /docs/build/
/env/ /result*
/requirements-flatten.txt /src/**/*.egg-info/
/src/relengapi/.coverage /src/**/.coverage
/src/relengapi/.coverage-html /src/**/.coverage-html
/src/relengapi/docs_build_dir/ /src/**/build
/src/relengapi/relengapi.egg-info/ /src/**/elm-stuff/
/src/relengapi/result /src/**/node_modules/
/src/relengapi_clobberer/env/
/src/relengapi_clobberer/relengapi_clobberer.egg-info/
/src/relengapi_common/relengapi_common.egg-info/
/src/relengapi_frontend/.coverage
/src/relengapi_frontend/elm-stuff/
/src/relengapi_frontend/build

2
.gitignore поставляемый
Просмотреть файл

@ -1,8 +1,8 @@
*.db *.db
*.pyc *.pyc
*.swp *.swp
.-rplugin~
/.-rplugin~
/.floo /.floo
/docs/build/ /docs/build/
/result* /result*

Просмотреть файл

@ -1,18 +0,0 @@
language: python
sudo: false
branches:
only:
- master
python:
- "2.7"
env:
- DATABASE_URL=sqlite:///$PWD/app.db
install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 6
- git clone https://github.com/garbas/neo
- cd neo && npm install && cd ..
- sed -i -e 's|file:../../../neo|file:../../neo|' src/relengapi_tools/package.json
- make install
script: "make lint check docs"
after_success:
- codecov

Просмотреть файл

@ -1,23 +1,27 @@
.PHONY: help develop build-all build docker \ .PHONY: help develop build docker \
deploy-staging-all deploy-staging \ deploy-staging-all deploy-staging \
deploy-production-all deploy-production \ deploy-production-all deploy-production \
update-all update-all
APP= APP=
APPS=relengapi_clobberer \ APPS=\
relengapi_frontend \ releng_frontend \
releng_clobberer \
shipit_dashboard shipit_dashboard
TOOL= TOOL=
TOOLS=pypi2nix awscli \ TOOLS=\
pypi2nix \
awscli \
node2nix \ node2nix \
mysql2sqlite \ mysql2sqlite \
mysql2pgsql mysql2pgsql
APP_PORT_relengapi_clobberer=8000
APP_PORT_relengapi_frontend=8001 APP_PORT_releng_frontend=8001
APP_PORT_shipit_dashboard=8002 APP_PORT_releng_clobberer=8002
APP_PORT_shipit_frontend=8003 APP_PORT_shipit_frontend=8003
APP_PORT_shipit_dashboard=8004
help: help:
@ -47,8 +51,8 @@ develop-run-FRONTEND: require-APP
NEO_BASE_URL=https://localhost:$$APP_PORT_$(APP) \ NEO_BASE_URL=https://localhost:$$APP_PORT_$(APP) \
nix-shell nix/default.nix -A $(APP) --run "neo start --config webpack.config.js" nix-shell nix/default.nix -A $(APP) --run "neo start --config webpack.config.js"
develop-run-relengapi_clobberer: develop-run-BACKEND develop-run-releng_clobberer: develop-run-BACKEND
develop-run-relengapi_frontend: develop-run-FRONTEND develop-run-releng_frontend: develop-run-FRONTEND
develop-run-shipit_dashboard: develop-run-BACKEND develop-run-shipit_dashboard: develop-run-BACKEND
develop-run-shipit_frontend: develop-run-BACKEND develop-run-shipit_frontend: develop-run-BACKEND
@ -79,7 +83,7 @@ deploy-staging-all: $(foreach app, $(APPS), deploy-staging-$(app)) deploy-stagin
deploy-staging: require-APP deploy-staging-$(APP) deploy-staging: require-APP deploy-staging-$(APP)
deploy-staging-relengapi_clobberer: docker-relengapi_clobberer deploy-staging-releng_clobberer: docker-releng_clobberer
if [[ -n "`docker images -q $(subst deploy-staging-,,$@)`" ]]; then \ if [[ -n "`docker images -q $(subst deploy-staging-,,$@)`" ]]; then \
docker rmi -f `docker images -q $(subst deploy-staging-,,$@)`; \ docker rmi -f `docker images -q $(subst deploy-staging-,,$@)`; \
fi fi
@ -90,7 +94,7 @@ deploy-staging-relengapi_clobberer: docker-relengapi_clobberer
docker push \ docker push \
registry.heroku.com/releng-staging-$(subst deploy-staging-,,$@)/web registry.heroku.com/releng-staging-$(subst deploy-staging-,,$@)/web
deploy-staging-relengapi_frontend: require-AWS build-app-relengapi_frontend build-tool-awscli deploy-staging-releng_frontend: require-AWS build-app-releng_frontend build-tool-awscli
./result-tool-awscli/bin/aws s3 sync \ ./result-tool-awscli/bin/aws s3 sync \
--delete \ --delete \
--acl public-read \ --acl public-read \
@ -113,7 +117,7 @@ deploy-production-all: $(foreach app, $(APPS), deploy-production-$(app)) deploy-
deploy-production: require-APP deploy-production-$(APP) deploy-production: require-APP deploy-production-$(APP)
deploy-production-relengapi_clobberer: docker-relengapi_clobberer deploy-production-releng_clobberer: docker-releng_clobberer
if [[ -n "`docker images -q $(subst deploy-production-,,$@)`" ]]; then \ if [[ -n "`docker images -q $(subst deploy-production-,,$@)`" ]]; then \
docker rmi -f `docker images -q $(subst deploy-production-,,$@)`; \ docker rmi -f `docker images -q $(subst deploy-production-,,$@)`; \
fi fi
@ -124,7 +128,7 @@ deploy-production-relengapi_clobberer: docker-relengapi_clobberer
docker push \ docker push \
registry.heroku.com/releng-production-$(subst deploy-production-,,$@)/web registry.heroku.com/releng-production-$(subst deploy-production-,,$@)/web
deploy-production-relengapi_frontend: require-AWS build-app-relengapi_frontend build-tool-awscli deploy-production-releng_frontend: require-AWS build-app-releng_frontend build-tool-awscli
./result-tool-awscli/bin/aws s3 sync \ ./result-tool-awscli/bin/aws s3 sync \
--delete \ --delete \
--acl public-read \ --acl public-read \
@ -189,8 +193,8 @@ require-APP:
@if [[ -z "$(APP)" ]]; then \ @if [[ -z "$(APP)" ]]; then \
echo ""; \ echo ""; \
echo "You need to specify which APP, eg:"; \ echo "You need to specify which APP, eg:"; \
echo " make develop APP=relengapi_clobberer"; \ echo " make develop APP=releng_clobberer"; \
echo " make build-app APP=relengapi_clobberer"; \ echo " make build-app APP=releng_clobberer"; \
echo " ..."; \ echo " ..."; \
echo ""; \ echo ""; \
echo "Available APPS are: "; \ echo "Available APPS are: "; \
@ -207,7 +211,7 @@ require-AWS:
[[ -z "$$AWS_SECRET_ACCESS_KEY" ]]; then \ [[ -z "$$AWS_SECRET_ACCESS_KEY" ]]; then \
echo ""; \ echo ""; \
echo "You need to specify AWS credentials, eg:"; \ echo "You need to specify AWS credentials, eg:"; \
echo " make deploy-production-relengapi_clobberer \\"; \ echo " make deploy-production-releng_clobberer \\"; \
echo " AWS_ACCESS_KEY_ID=\"...\" \\"; \ echo " AWS_ACCESS_KEY_ID=\"...\" \\"; \
echo " AWS_SECRET_ACCESS_KEY=\"...\""; \ echo " AWS_SECRET_ACCESS_KEY=\"...\""; \
echo ""; \ echo ""; \

Просмотреть файл

@ -1,11 +1,12 @@
Welcome to relengapi Welcome to releng
==================== =================
Purspose of relengapi ... TODO Purspose of releng ... TODO
- Documentation: https://docs.mozilla-releng.org
- Issues: https://gitub.com/garbas/mozilla-releng/issues
- Code: https://gitub.com/garbas/mozilla-releng
- Documentation: https://docs.relengapi.mozilla.org
- Issues: https://gitub.com/mozilla/build-relengapi/issues
- Code: https://gitub.com/mozilla/build-relengapi
Repository structure Repository structure
==================== ====================
@ -81,18 +82,18 @@ Repository structure
- ``settings.py`` - ``settings.py``
Production relengapi settings file for Heroku. Production releng settings file for Heroku.
- ``src/`` - ``src/``
Directory where we keep all our source code Directory where we keep all our source code
- ``relengapi_frontend/`` - ``releng_frontend/``
Read its `README<src/relengapi_frontend/README.md` for more info. Read its `README<src/releng_frontend/README.md` for more info.
- ``relengapi_clobberer/`` - ``releng_clobberer/``
Read its `README<src/relengapi_clobberer/README.md` for more info. Read its `README<src/releng_clobberer/README.md` for more info.
.. _pip: https://pip.pypa.io .. _pip: https://pip.pypa.io

Просмотреть файл

@ -224,7 +224,7 @@ latex_elements = {
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'RelengAPI.tex', u'RelengAPI Documentation', (master_doc, 'Releng.tex', u'Release Engineering Documentation',
u'Rok Garbas', 'manual'), u'Rok Garbas', 'manual'),
] ]
@ -254,7 +254,7 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
(master_doc, 'relengapi', u'RelengAPI Documentation', (master_doc, 'releng', u'Release Engineering Documentation',
[author], 1) [author], 1)
] ]
@ -268,8 +268,8 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'RelengAPI', u'RelengAPI Documentation', (master_doc, 'RelEng', u'Release Engineering Documentation',
author, 'RelengAPI', 'One line description of project.', author, 'RelEng', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]

Просмотреть файл

@ -12,24 +12,24 @@ Quick overview of all releng services with short description.
.. todo:: write about AWS policies (production/staging) .. todo:: write about AWS policies (production/staging)
relengapi_frontend releng_frontend
------------------ ---------------
Staging: Staging:
- Url: https://staging.mozilla-releng.org - Url: https://staging.mozilla-releng.org
- S3: https://console.aws.amazon.com/s3/home?region=us-west-2&bucket=releng-staging-relengapi-frontend - S3: https://console.aws.amazon.com/s3/home?region=us-west-2&bucket=releng-staging-frontend
- CloudFront: https://console.aws.amazon.com/cloudfront/home?region=us-west-2#distribution-settings:E21OUD0VFT2UQ6 - CloudFront: https://console.aws.amazon.com/cloudfront/home?region=us-west-2#distribution-settings:E21OUD0VFT2UQ6
Production: Production:
- Url: https://mozilla-releng.org - Url: https://mozilla-releng.org
- S3: https://console.aws.amazon.com/s3/home?region=us-west-2&bucket=releng-production-relengapi-frontend - S3: https://console.aws.amazon.com/s3/home?region=us-west-2&bucket=releng-production-frontend
- CloudFront: https://console.aws.amazon.com/cloudfront/home?region=us-west-2#distribution-settings:E7SMSK9P6UW3N - CloudFront: https://console.aws.amazon.com/cloudfront/home?region=us-west-2#distribution-settings:E7SMSK9P6UW3N
relengapi_clobberer releng_clobberer
------------------- ----------------
.. todo:: mention that newrelic and papertrail addons are used .. todo:: mention that newrelic and papertrail addons are used

Просмотреть файл

@ -31,5 +31,5 @@ current implementation
Technical stuff: Technical stuff:
- relengapi stack - releng stack
- relengapi repo - releng repo

Просмотреть файл

@ -22,20 +22,17 @@ let
}; };
lib = import ./lib/default.nix { inherit releng_pkgs; }; lib = import ./lib/default.nix { inherit releng_pkgs; };
tools = import ./tools/default.nix { inherit releng_pkgs; }; tools = import ./tools/default.nix { inherit releng_pkgs; };
elmPackages = pkgs.elmPackages.override { nodejs = pkgs."nodejs-6_x"; }; elmPackages = pkgs.elmPackages.override { nodejs = pkgs."nodejs-6_x"; };
releng_docs = import ./../docs { inherit releng_pkgs; }; releng_docs = import ./../docs { inherit releng_pkgs; };
relengapi_clobberer = import ./../src/relengapi_clobberer { inherit releng_pkgs; }; releng_frontend = import ./../src/releng_frontend { inherit releng_pkgs; };
releng_clobberer = import ./../src/releng_clobberer { inherit releng_pkgs; };
relengapi_frontend = import ./../src/relengapi_frontend { inherit releng_pkgs; };
#shipit_frontend = import ./../src/shipit_frontend { inherit releng_pkgs; };
shipit_dashboard = import ./../src/shipit_dashboard { inherit releng_pkgs; }; shipit_dashboard = import ./../src/shipit_dashboard { inherit releng_pkgs; };
#shipit = import ./../src/shipit { inherit releng_pkgs; };
}; };
in releng_pkgs in releng_pkgs

Просмотреть файл

@ -1,7 +1,7 @@
recursive-include relengapi_clobberer/* recursive-include releng_clobberer/*
include VERSION include VERSION
include relengapi_clobberer/*.yml include releng_clobberer/*.yml
recursive-exclude * __pycache__ recursive-exclude * __pycache__
recursive-exclude * *.py[co] recursive-exclude * *.py[co]

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,109 @@
{ releng_pkgs }:
let
inherit (builtins) readFile concatStringsSep;
inherit (releng_pkgs.lib) fromRequirementsFile;
inherit (releng_pkgs.pkgs) makeWrapper writeScriptBin;
inherit (releng_pkgs.pkgs.lib) removeSuffix inNixShell;
inherit (releng_pkgs.tools) pypi2nix;
name = "releng_clobberer";
version = removeSuffix "\n" (readFile ./VERSION);
beforeSQL = ''
DROP TABLE IF EXISTS clobberer_builds;
DROP TABLE IF EXISTS clobberer_times;
DROP TABLE IF EXISTS builds;
DROP TABLE IF EXISTS clobber_times;
'';
afterSQL = ''
ALTER TABLE builds RENAME TO clobberer_builds;
ALTER TABLE clobber_times RENAME TO clobberer_times;
'';
python = import ./requirements.nix { inherit (releng_pkgs) pkgs; };
# TODO: move this migrate scripts to releng_pkgs.tools
migrate = import ./migrate.nix { inherit releng_pkgs; };
srcs = [
"./../releng_common"
"./../${name}"
];
self = python.mkDerivation {
namePrefix = "";
name = "${name}-${version}";
srcs = if inNixShell then null else (map (x: ./. + ("/" + x)) srcs);
sourceRoot = ".";
buildInputs = [ makeWrapper ] ++
fromRequirementsFile [ ./requirements-dev.txt
./requirements-setup.txt ] python.packages;
propagatedBuildInputs =
fromRequirementsFile [ ./../releng_common/requirements.txt
./requirements.txt
./requirements-prod.txt ] python.packages;
postInstall = ''
mkdir -p $out/bin $out/etc
ln -s ${python.interpreter.interpreter} $out/bin
ln -s ${python.packages."gunicorn"}/bin/gunicorn $out/bin
ln -s ${python.packages."newrelic"}/bin/newrelic-admin $out/bin
cp ./src-*-releng_clobberer/settings.py $out/etc
for i in $out/bin/*; do
wrapProgram $i --set PYTHONPATH $PYTHONPATH
done
'';
checkPhase = ''
flake8 settings.py setup.py releng_clobberer/
# TODO: pytest ${name}/
'';
shellHook = ''
export CACHE_DEFAULT_TIMEOUT=3600
export CACHE_TYPE=filesystem
export CACHE_DIR=$PWD/cache
export DATABASE_URL=sqlite:///$PWD/app.db
for i in ${concatStringsSep " " srcs}; do
if test -e src/''${i:5}/setup.py; then
echo "Setting \"''${i:5}\" in development mode ..."
pushd src/''${i:5} >> /dev/null
tmp_path=$(mktemp -d)
export PATH="$tmp_path/bin:$PATH"
export PYTHONPATH="$tmp_path/${python.__old.python.sitePackages}:$PYTHONPATH"
mkdir -p $tmp_path/${python.__old.python.sitePackages}
${python.__old.bootstrapped-pip}/bin/pip install -q -e . --prefix $tmp_path
popd >> /dev/null
fi
done
'';
passthru.mysql2sqlite = migrate.mysql2sqlite { inherit name beforeSQL afterSQL; };
passthru.mysql2postgresql = migrate.mysql2postgresql { inherit name beforeSQL afterSQL; };
passthru.python = python;
passthru.dockerEnvs = [
"APP_SETTINGS=${self}/etc/settings.py"
];
passthru.dockerConfig = {
Cmd = [
"newrelic-admin" "run-program"
"gunicorn" "${name}:app"
"--timeout" "300" "--log-file" "-"
];
};
passthru.updateSrc = writeScriptBin "update" ''
pushd src/${name}
${pypi2nix}/bin/pypi2nix -v \
-V 3.5 \
-E "postgresql" \
-r requirements.txt \
-r requirements-setup.txt \
-r requirements-dev.txt \
-r requirements-prod.txt
popd
'';
};
in self

Просмотреть файл

Просмотреть файл

@ -6,7 +6,7 @@ from __future__ import absolute_import
import os import os
from relengapi_common import db, create_app from releng_common import db, create_app
DEBUG = bool(os.environ.get('DEBUG', __name__ == '__main__')) DEBUG = bool(os.environ.get('DEBUG', __name__ == '__main__'))
@ -29,7 +29,7 @@ if not os.environ.get('APP_SETTINGS') and \
app = create_app( app = create_app(
"relengapi_clobberer", "releng_clobberer",
extensions=[init_app, db], extensions=[init_app, db],
debug=DEBUG, debug=DEBUG,
debug_src=HERE, debug_src=HERE,

Просмотреть файл

@ -5,7 +5,7 @@
from __future__ import absolute_import from __future__ import absolute_import
from flask import g, current_app from flask import g, current_app
from relengapi_clobberer import models from releng_clobberer import models
def get_buildbot(): def get_buildbot():
@ -24,7 +24,7 @@ def get_buildbot():
# who = 'automation' # who = 'automation'
# TODO: require scopes # TODO: require scopes
# relengapi_common.auth.auth.require_scope('releng???/api/clobberer/buildbot/post) # releng_common.auth.auth.require_scope('releng???/api/clobberer/buildbot/post)
def post_buildbot(body): def post_buildbot(body):
result = [] result = []

Просмотреть файл

@ -9,7 +9,7 @@ import sqlalchemy as sa
import taskcluster as tc import taskcluster as tc
import time import time
from relengapi_common.db import db from releng_common.db import db
BUILDBOT_BUILDDIR_REL_PREFIX = 'rel-' BUILDBOT_BUILDDIR_REL_PREFIX = 'rel-'

Просмотреть файл

@ -8,7 +8,7 @@ paths:
/buildbot: /buildbot:
get: get:
operationId: "relengapi_clobberer.api.get_buildbot" operationId: "releng_clobberer.api.get_buildbot"
responses: responses:
200: 200:
description: An array of branches description: An array of branches
@ -18,7 +18,7 @@ paths:
$ref: '#/definitions/Branch' $ref: '#/definitions/Branch'
post: post:
operationId: "relengapi_clobberer.api.post_buildbot" operationId: "releng_clobberer.api.post_buildbot"
parameters: parameters:
- name: body - name: body
in: body in: body
@ -52,13 +52,13 @@ paths:
/taskcluster: /taskcluster:
get: get:
operationId: "relengapi_clobberer.api.get_taskcluster" operationId: "releng_clobberer.api.get_taskcluster"
responses: responses:
200: 200:
description: An array of branches description: An array of branches
post: post:
operationId: "relengapi_clobberer.api.post_taskcluster" operationId: "releng_clobberer.api.post_taskcluster"
responses: responses:
200: 200:
description: Branches clobbered description: Branches clobbered

Просмотреть файл

@ -0,0 +1,2 @@
-r ../releng_common/requirements.txt
-e ../releng_common

Просмотреть файл

Просмотреть файл

@ -21,7 +21,7 @@ with open(os.path.join(here, 'requirements.txt')) as f:
) )
setup( setup(
name='relengapi_clobberer', name='releng_clobberer',
version=open(os.path.join(here, 'VERSION')).read().strip(), version=open(os.path.join(here, 'VERSION')).read().strip(),
description='The code behind https://clobberer.mozilla-releng.net', description='The code behind https://clobberer.mozilla-releng.net',
author='Rok Garbas', author='Rok Garbas',

Просмотреть файл

Просмотреть файл

@ -11,11 +11,11 @@ import sys
from flask import Flask, send_from_directory from flask import Flask, send_from_directory
from relengapi_common import api, log, cors from releng_common import api, log, cors
__APP = dict() __APP = dict()
logger = logging.getLogger('relengapi_common') logger = logging.getLogger('releng_common')
def create_app(name, extensions=[], config=None, debug=False, debug_src=None, def create_app(name, extensions=[], config=None, debug=False, debug_src=None,
@ -38,7 +38,7 @@ def create_app(name, extensions=[], config=None, debug=False, debug_src=None,
elif os.environ.get('APP_SETTINGS'): # noqa elif os.environ.get('APP_SETTINGS'): # noqa
app.config.from_envvar('APP_SETTINGS') app.config.from_envvar('APP_SETTINGS')
else: else:
print("Using default settings; to configure relengapi, set " print("Using default settings; to configure releng, set "
"APP_SETTINGS to point to your settings file") "APP_SETTINGS to point to your settings file")
sys.exit(1) sys.exit(1)

Просмотреть файл

@ -10,7 +10,7 @@ import pathlib
import werkzeug.exceptions import werkzeug.exceptions
logger = logging.getLogger('relengapi_common.api') logger = logging.getLogger('releng_common.api')
def common_error_handler(exception): def common_error_handler(exception):

Просмотреть файл

@ -24,7 +24,7 @@ class UnstructuredRenderer(structlog.processors.KeyValueRenderer):
def setup_console_logging(quiet=False): def setup_console_logging(quiet=False):
root = logging.getLogger('relengapi_common') root = logging.getLogger('releng_common')
if quiet: if quiet:
root.setLevel(logging.WARNING) root.setLevel(logging.WARNING)
else: else:

Просмотреть файл

@ -19,13 +19,12 @@ with open(os.path.join(here, 'requirements.txt')) as f:
setup( setup(
name='relengapi_common', name='releng_common',
version=version, version=version,
description='Common code for all services behind ' description='Services behind https://mozilla-releng.net',
'https://mozilla-releng.net',
author='Mozilla Release Engineering', author='Mozilla Release Engineering',
author_email='release@mozilla.com', author_email='release@mozilla.com',
url='https://github.com/mozilla/build-relengapi', url='https://github.com/garbas/mozilla-releng',
install_requires=install_requires, install_requires=install_requires,
packages=find_packages(), packages=find_packages(),
include_package_data=True, include_package_data=True,

Просмотреть файл

Просмотреть файл

@ -3,26 +3,33 @@
let let
inherit (releng_pkgs) elmPackages; inherit (builtins) fromJSON readFile filterSource attrValues concatStringsSep;
inherit (releng_pkgs.elmPackages) elm;
inherit (releng_pkgs.elmPackages.lib) makeElmStuff;
inherit (releng_pkgs.pkgs) writeScriptBin cacert;
inherit (releng_pkgs.pkgs.stdenv) mkDerivation; inherit (releng_pkgs.pkgs.stdenv) mkDerivation;
inherit (releng_pkgs.tools) node2nix elm2nix;
pkg = fromJSON (readFile ./package.json);
name = pkg.name;
version = pkg.version;
pkg = builtins.fromJSON (builtins.readFile ./package.json);
node_modules = import ./package.nix { inherit (releng_pkgs) pkgs; }; node_modules = import ./package.nix { inherit (releng_pkgs) pkgs; };
self = mkDerivation { self = mkDerivation {
name = "${pkg.name}-${pkg.version}"; name = "${name}-${version}";
src = builtins.filterSource src = filterSource
(path: type: baseNameOf path != "elm-stuff" (path: type: baseNameOf path != "elm-stuff"
&& baseNameOf path != "node_modules" && baseNameOf path != "node_modules"
) )
./.; ./.;
buildInputs = [ elmPackages.elm ] ++ (builtins.attrValues node_modules); buildInputs = [ elm ] ++ (attrValues node_modules);
configurePhase = '' configurePhase = ''
rm -rf node_modules rm -rf node_modules
rm -rf elm-stuff rm -rf elm-stuff
'' + elmPackages.lib.makeElmStuff (import ./elm-package.nix) + '' '' + (makeElmStuff (import ./elm-package.nix)) + ''
mkdir node_modules mkdir node_modules
for item in ${builtins.concatStringsSep " " (builtins.attrValues node_modules)}; do for item in ${concatStringsSep " " (attrValues node_modules)}; do
ln -s $item/lib/node_modules/* ./node_modules ln -s $item/lib/node_modules/* ./node_modules
done done
''; '';
@ -34,12 +41,12 @@ let
cp build/* $out/ -R cp build/* $out/ -R
''; '';
shellHook = '' shellHook = ''
cd src/${pkg.name} cd src/${name}
'' + self.configurePhase; '' + self.configurePhase;
passthru.updateSrc = releng_pkgs.pkgs.writeScriptBin "update" '' passthru.updateSrc = writeScriptBin "update" ''
export SSL_CERT_FILE="${releng_pkgs.pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" export SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"
pushd src/relengapi_frontend pushd src/${name}
${releng_pkgs.tools.node2nix}/bin/node2nix \ ${node2nix}/bin/node2nix \
--composition package.nix \ --composition package.nix \
--input node-packages.json \ --input node-packages.json \
--output node-packages.nix \ --output node-packages.nix \
@ -47,8 +54,8 @@ let
--flatten \ --flatten \
--pkg-name nodejs-6_x --pkg-name nodejs-6_x
rm -rf elm-stuff rm -rf elm-stuff
${elmPackages.elm}/bin/elm-package install -y ${elm}/bin/elm-package install -y
${releng_pkgs.tools.elm2nix}/bin/elm2nix elm-package.nix ${elm2nix}/bin/elm2nix elm-package.nix
popd popd
''; '';
}; };

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,10 +1,10 @@
{ {
"name": "relengapi_frontend", "name": "releng_frontend",
"version": "0.1.0", "version": "0.1.0",
"description": "relengapi frontend", "description": "releng frontend",
"main": "src/index.js", "main": "src/index.js",
"author": "Rok Garbas <rok@garbas.si>", "author": "Rok Garbas <rok@garbas.si>",
"repository": "https://github.com/mozilla/build-relengapi", "repository": "https://github.com/garbas/mozilla-releng",
"license": "MPL-2.0", "license": "MPL-2.0",
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=6.0.0"
@ -25,7 +25,7 @@
}, },
"keywords": [ "keywords": [
"mozilla", "mozilla",
"relengapi" "releng"
], ],
"dependencies": { "dependencies": {
"bootstrap": "4.0.0-alpha.2", "bootstrap": "4.0.0-alpha.2",

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,111 +0,0 @@
{ releng_pkgs }:
let
name = "relengapi_clobberer";
beforeSQL = ''
DROP TABLE IF EXISTS clobberer_builds;
DROP TABLE IF EXISTS clobberer_times;
DROP TABLE IF EXISTS builds;
DROP TABLE IF EXISTS clobber_times;
'';
afterSQL = ''
ALTER TABLE builds RENAME TO clobberer_builds;
ALTER TABLE clobber_times RENAME TO clobberer_times;
'';
inherit (builtins) readFile concatStringsSep;
inherit (releng_pkgs.lib) fromRequirementsFile;
inherit (releng_pkgs.pkgs) makeWrapper;
inherit (releng_pkgs.pkgs.lib) removeSuffix inNixShell;
python = import ./requirements.nix { inherit (releng_pkgs) pkgs; };
migrate = import ./migrate.nix { inherit releng_pkgs; };
version = removeSuffix "\n" (readFile ./VERSION);
srcs = [
"./../relengapi_common"
"./../relengapi_clobberer"
];
self = python.mkDerivation {
namePrefix = "";
name = "${name}-${version}";
srcs = if inNixShell then null else (map (x: ./. + ("/" + x)) srcs);
sourceRoot = ".";
buildInputs = [ makeWrapper ] ++
fromRequirementsFile [ ./requirements-dev.txt
./requirements-setup.txt ] python.packages;
propagatedBuildInputs =
fromRequirementsFile [ ./../relengapi_common/requirements.txt
./requirements.txt
./requirements-prod.txt ] python.packages;
postInstall = ''
mkdir -p $out/bin $out/etc
ln -s ${python.interpreter.interpreter} $out/bin
ln -s ${python.packages."gunicorn"}/bin/gunicorn $out/bin
ln -s ${python.packages."newrelic"}/bin/newrelic-admin $out/bin
cp ./src-*-relengapi_clobberer/settings.py $out/etc
for i in $out/bin/*; do
wrapProgram $i --set PYTHONPATH $PYTHONPATH
done
'';
checkPhase = ''
flake8 settings.py setup.py relengapi_clobberer/
# TODO: pytest relengapi_clobberer/
'';
shellHook = ''
export CACHE_DEFAULT_TIMEOUT=3600
export CACHE_TYPE=filesystem
export CACHE_DIR=$PWD/cache
export DATABASE_URL=sqlite:///$PWD/app.db
for i in ${concatStringsSep " " srcs}; do
if test -e src/''${i:5}/setup.py; then
echo "Setting \"''${i:5}\" in development mode ..."
pushd src/''${i:5} >> /dev/null
tmp_path=$(mktemp -d)
export PATH="$tmp_path/bin:$PATH"
export PYTHONPATH="$tmp_path/${python.__old.python.sitePackages}:$PYTHONPATH"
mkdir -p $tmp_path/${python.__old.python.sitePackages}
${python.__old.bootstrapped-pip}/bin/pip install -q -e . --prefix $tmp_path
popd >> /dev/null
fi
done
'';
passthru.mysql2sqlite = migrate.mysql2sqlite {
inherit name beforeSQL afterSQL;
};
passthru.mysql2postgresql = migrate.mysql2postgresql {
inherit name beforeSQL afterSQL;
};
passthru.python = python;
passthru.dockerEnvs = [
"APP_SETTINGS=${self}/etc/settings.py"
];
passthru.dockerConfig = {
Cmd = [
"newrelic-admin" "run-program"
"gunicorn" "relengapi_clobberer:app"
"--timeout" "300" "--log-file" "-"
];
};
passthru.updateSrc = releng_pkgs.pkgs.writeScriptBin "update" ''
pushd src/relengapi_clobberer
${releng_pkgs.tools.pypi2nix}/bin/pypi2nix -v \
-V 3.5 \
-E "postgresql" \
-r requirements.txt \
-r requirements-setup.txt \
-r requirements-dev.txt \
-r requirements-prod.txt
popd
'';
};
in self

Просмотреть файл

@ -1,2 +0,0 @@
-r ../relengapi_common/requirements.txt
-e ../relengapi_common

Просмотреть файл

@ -19,7 +19,7 @@ setup(
author_email='release@mozilla.com', author_email='release@mozilla.com',
url='https://ship-it.mozilla-releng.net', url='https://ship-it.mozilla-releng.net',
install_requires=[ install_requires=[
"relengapi_common", "releng_common",
], ],
extras_require={ extras_require={
}, },
@ -28,7 +28,7 @@ setup(
zip_safe=False, zip_safe=False,
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [
'relengapi = relengapi.cmd:main', 'releng = releng.cmd:main',
], ],
}, },
license='MPL2', license='MPL2',

Просмотреть файл

@ -2,21 +2,18 @@
let let
name = "shipit_dashboard";
inherit (builtins) readFile concatStringsSep; inherit (builtins) readFile concatStringsSep;
inherit (releng_pkgs.lib) fromRequirementsFile; inherit (releng_pkgs.lib) fromRequirementsFile;
inherit (releng_pkgs.pkgs) makeWrapper; inherit (releng_pkgs.pkgs) makeWrapper;
inherit (releng_pkgs.pkgs.lib) removeSuffix inNixShell; inherit (releng_pkgs.pkgs.lib) removeSuffix inNixShell;
python = import ./requirements.nix { name = "shipit_dashboard";
inherit (releng_pkgs) pkgs;
};
version = removeSuffix "\n" (readFile ./VERSION); version = removeSuffix "\n" (readFile ./VERSION);
python = import ./requirements.nix { inherit (releng_pkgs) pkgs; };
srcs = [ srcs = [
"./../relengapi_common" "./../releng_common"
"./../${name}" "./../${name}"
]; ];
@ -29,7 +26,7 @@ let
fromRequirementsFile [ ./requirements-dev.txt fromRequirementsFile [ ./requirements-dev.txt
./requirements-setup.txt ] python.packages; ./requirements-setup.txt ] python.packages;
propagatedBuildInputs = [ python.packages."clouseau" ] ++ propagatedBuildInputs = [ python.packages."clouseau" ] ++
fromRequirementsFile [ ./../relengapi_common/requirements.txt fromRequirementsFile [ ./../releng_common/requirements.txt
./requirements.txt ./requirements.txt
./requirements-prod.txt ] python.packages; ./requirements-prod.txt ] python.packages;
postInstall = '' postInstall = ''

Просмотреть файл

@ -1,5 +1,5 @@
-r ../relengapi_common/requirements.txt -r ../releng_common/requirements.txt
-e ../relengapi_common -e ../releng_common
# from https://github.com/calixteman/clouseau/blob/master/requirements.txt # from https://github.com/calixteman/clouseau/blob/master/requirements.txt
requests>=2.7.0 requests>=2.7.0

Просмотреть файл

@ -6,7 +6,7 @@ from __future__ import absolute_import
import os import os
from relengapi_common import db, create_app from releng_common import db, create_app
from shipit_dashboard.workflow import run_workflow from shipit_dashboard.workflow import run_workflow

Просмотреть файл

@ -6,7 +6,7 @@ from __future__ import absolute_import
import sqlalchemy as sa import sqlalchemy as sa
from relengapi_common.db import db from releng_common.db import db
import datetime import datetime
import pickle import pickle

Просмотреть файл

@ -1,5 +1,5 @@
# coding=utf-8 # coding=utf-8
from relengapi_common.db import db from releng_common.db import db
from shipit_dashboard.models import BugAnalysis, BugResult from shipit_dashboard.models import BugAnalysis, BugResult
from shipit_dashboard.helpers import compute_dict_hash from shipit_dashboard.helpers import compute_dict_hash
from clouseau.bugzilla import Bugzilla from clouseau.bugzilla import Bugzilla

Просмотреть файл

@ -4,5 +4,5 @@ PLAN:
- example: https://people.mozilla.org/~sledru/relman-dashboard/ - example: https://people.mozilla.org/~sledru/relman-dashboard/
- bootstrap the project - bootstrap the project
- copy login from relengapi_tools - copy login from releng_tools
- create a route for dashboard - create a route for dashboard