Skip to content
This repository was archived by the owner on Feb 26, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.0] - 2017-12-14
### Added
- Changelog
- Support for processing release manifest from beetmover

### Fixed
- fixed some logging
27 changes: 24 additions & 3 deletions balrogscript/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,35 @@


def create_submitter(e, balrog_auth, config):
from balrog.submitter.cli import NightlySubmitterV4 # noqa: E402
from balrog.submitter.cli import NightlySubmitterV4, ReleaseSubmitterV4 # noqa: E402
auth = balrog_auth

if "tc_release" in e:
raise NotImplementedError("This logic piece has yet to be implemented")
log.info("Taskcluster Release style Balrog submission")

complete_info = e['completeInfo']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we always submit completes. I'd make them optional as well. Just add a check to make sure that either of them is set, aka any([complete_info, partial_info]).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

partial_info = e.get('partialInfo')
submitter = ReleaseSubmitterV4(api_root=config['api_root'], auth=auth,
dummy=config['dummy'])

data = {
'platform': e['platform'],
'productName': e['appName'],
'appVersion': e['appVersion'],
'version': e['version'],
'build_number': e['build_number'],
'locale': e['locale'],
'hashFunction': e['hashType'],
'extVersion': e['extVersion'],
'buildID': e['buildid'],
'completeInfo': complete_info
}
if partial_info:
data['partialInfo'] = partial_info
return submitter, data

elif "tc_nightly" in e:
log.info("Taskcluster Nightly Fennec style Balrog submission")
log.info("Taskcluster Nightly style Balrog submission")

complete_info = e['completeInfo']
partial_info = e.get('partialInfo')
Expand Down
65 changes: 65 additions & 0 deletions balrogscript/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import json
import os
import pytest
import shutil
import tempfile


# constants, helpers, and fixtures {{{1
NIGHTLY_MANIFEST_PATH = os.path.join(os.path.dirname(__file__), "data", "nightly_manifest.json")
NIGHTLY_TASK_PATH = os.path.join(os.path.dirname(__file__), "data", "nightly_task.json")


@pytest.fixture(scope='function')
def nightly_manifest():
with open(NIGHTLY_MANIFEST_PATH, "r") as fh:
return json.load(fh)


@pytest.yield_fixture(scope='function')
def config():
tmpdir = tempfile.mkdtemp()
try:
yield {
"work_dir": os.path.join(tmpdir, "work_dir"),
"artifact_dir": os.path.join(tmpdir, "artifact_dir"),
"schema_file": "balrogscript/data/balrog_task_schema.json",
"dummy": False,
"api_root": "BALROG_API_ROOT",
"server_config": {
"nightly": {
"balrog_username": "BALROG_USERNAME",
"balrog_password": "BALROG_PASSWORD",
"allowed_channels": ["nightly"]
},
"release": {
"balrog_username": "BALROG_USERNAME",
"balrog_password": "BALROG_PASSWORD",
"allowed_channels": ["release", "release-localtest", "release-cdntest"]
},
"dep": {
"balrog_username": "BALROG_USERNAME",
"balrog_password": "BALROG_PASSWORD",
"allowed_channels": ["nightly", "release", "beta", "etc"]
},

},
"disable_certs": False,
"verbose": True
}
finally:
shutil.rmtree(tmpdir)


@pytest.yield_fixture(scope='function')
def nightly_config(config):
os.makedirs(os.path.join(config['work_dir'], "upstream-task-id", "public"))
shutil.copyfile(
NIGHTLY_MANIFEST_PATH,
os.path.join(config['work_dir'], "upstream-task-id", "public", "manifest.json")
)
shutil.copyfile(
NIGHTLY_TASK_PATH,
os.path.join(config['work_dir'], "task.json")
)
yield config
55 changes: 5 additions & 50 deletions balrogscript/test/test_script.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-

import json
import logging
import pytest
import os
import shutil
import sys
import tempfile
import balrogscript.script as balrogscript

from balrogscript.test import (nightly_manifest, config, nightly_config)
from balrogscript.task import (get_task, validate_task_schema, get_task_server)

sys.path.insert(0, os.path.join(
Expand All @@ -17,53 +16,9 @@

logging.basicConfig()

# constants, helpers, and fixtures {{{1
NIGHTLY_MANIFEST_PATH = os.path.join(os.path.dirname(__file__), "data", "nightly_manifest.json")
NIGHTLY_TASK_PATH = os.path.join(os.path.dirname(__file__), "data", "nightly_task.json")


@pytest.fixture(scope='function')
def nightly_manifest():
with open(NIGHTLY_MANIFEST_PATH, "r") as fh:
return json.load(fh)


@pytest.yield_fixture(scope='function')
def config():
tmpdir = tempfile.mkdtemp()
try:
yield {
"work_dir": os.path.join(tmpdir, "work_dir"),
"artifact_dir": os.path.join(tmpdir, "artifact_dir"),
"schema_file": "balrogscript/data/balrog_task_schema.json",
"dummy": False,
"api_root": "BALROG_API_ROOT",
"server_config": {
"nightly": {
"balrog_username": "BALROG_USERNAME",
"balrog_password": "BALROG_PASSWORD",
"allowed_channels": ["nightly"]
},
},
"disable_certs": False,
"verbose": True
}
finally:
shutil.rmtree(tmpdir)


@pytest.yield_fixture(scope='function')
def nightly_config(config):
os.makedirs(os.path.join(config['work_dir'], "upstream-task-id", "public"))
shutil.copyfile(
NIGHTLY_MANIFEST_PATH,
os.path.join(config['work_dir'], "upstream-task-id", "public", "manifest.json")
)
shutil.copyfile(
NIGHTLY_TASK_PATH,
os.path.join(config['work_dir'], "task.json")
)
yield config
assert nightly_config # silence pyflakes
assert config # silence pyflakes
assert nightly_manifest # silence pyflakes


# get_task {{{1
Expand Down
51 changes: 51 additions & 0 deletions balrogscript/test/test_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
import pytest

from balrogscript.test import config, nightly_config
from balrogscript.task import (get_task, get_task_channel, get_task_server,
get_upstream_artifacts)

assert nightly_config # silence pyflakes
assert config # silence pyflakes


def test_get_task_channel(nightly_config):
task = get_task(nightly_config)
with pytest.raises(NotImplementedError):
get_task_channel(task, nightly_config)


@pytest.mark.parametrize("scopes,expected,raises", ((
["project:releng:balrog:server:dep", "project:releng:balrog:server:release"],
None, True,
), (
["project:releng:balrog:server:!!"],
None, True
), (
["project:releng:balrog:server:foo", "project:releng:balrog:action:foo"],
None, True
), (
["project:releng:balrog:server:dep", "project:releng:balrog:action:foo"],
"dep", False
)))
def test_get_task_server(nightly_config, scopes, expected, raises):
task = get_task(nightly_config)
task['scopes'] = scopes

if raises:
with pytest.raises(ValueError):
get_task_server(task, nightly_config)
else:
assert expected == get_task_server(task, nightly_config)


@pytest.mark.parametrize("expected", ([
[{
u'paths': [u'public/manifest.json'],
u'taskId': u'upstream-task-id',
u'taskType': u'baz'
}]
]))
def test_get_upstream_artifacts(nightly_config, expected):
task = get_task(nightly_config)
assert get_upstream_artifacts(task) == expected
6 changes: 3 additions & 3 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": [
0,
1,
1
0,
0
],
"version_string": "0.1.1"
"version_string": "1.0.0"
}