Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Automated Website PR Fixes (#683)
Browse files Browse the repository at this point in the history
* Revert to installing pip3 with apt

* Temporarily disabling master-only releases to test

* Fixed name shadowing

* Fixed empty list of assets

* Removed old notifications

* Correct version number
  • Loading branch information
jonathan-j-lee authored and lawrencechen14 committed Mar 27, 2019
1 parent 145d568 commit 803be86
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
11 changes: 1 addition & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ matrix:
addons:
apt:
packages:
- python3-pip
- socat
env:
global:
Expand All @@ -46,7 +47,6 @@ before_install:
- popd
install:
- pushd $TEST_DIR
- command -v pip3 || sudo apt install python3-pip
- make install
- if [[ $DEPLOY_ARTIFACTS = 1 ]]; then make artifacts-install; fi
- popd
Expand All @@ -73,12 +73,3 @@ deploy:
branch: master
tags: true
condition: $DEPLOY_ARTIFACTS = 1
notifications:
slack:
rooms:
- secure: iByImumEaLfRhxD5wxER3qovftyqSeaQdtdp5y80MSPZMa9AL6NkpyhZPl8WaQxUYvvzWo4/dbal+Qb17ew4hRDsprKbvXh3SP/0SLSe0QAK3ShB+iLBAFX04ZoTRMxdgKvU4LZPbJGSizBWD6lHHz3JCILSpjXtfgL1g74vejVJY2VqMW4Vn4YXfPx39z5v23O9GNzx9S2zGb0dN77ilSRJr/wVzsYqZD8jcgaD63pZ/TCSgxJcVQAvztVaWKkbh19qrP6M4WV1rxIZN8ksnBe1gUJ/VIylMWnf3CRwLaJw4+Z+aqm1GUbD7tsi9BA2D7gmlJC/yv4vzejMCtOpU8z4ymBpvJ6A7uBdv5CMGcOWx35FEpB5LwSGKXk0/5/Ar3HjHzQtB/K7a7PuzvHUROdNUi+9Q6kUAZlEfzEsbEd/sxMy09m6kBKUpluDueJCBcS0qGYlZ+7roQwEs5CEPBqOUhZne3kNH+HXsyHgs4r83FlPEqqnhdswqQYgWYOdrIQVUXX3L8CnCpuFojevwdN+nb/ahwsl0XQl5lgaFcIsU4tZpYHxXExzpWJfN7Y3MvRbFOfNab8LSodAHjvvzXJrmh8lrlv3TYtW5mWDyPg56CTysMOuVRyc74bvvhidff3tUTw62VqH13XESVcdsOEv0g8Jz4ZnzInxJTimX9o=
template:
- "Build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) of %{repository}@%{branch} by %{author} %{result} in %{duration}"
- "@onibrow Your meatballs are ready!"
on_success: change
on_failure: always
2 changes: 1 addition & 1 deletion DevOps/pipeline/deploy-artifacts.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Usage: ./DevOps/pipeline/artifacts-pipeline.sh "<app-id>" "<tag>" "<artifacts-dir>"
# Usage: ./deploy-artifacts.sh "<app-id>" "<tag>" "<artifacts-dir>"

set -e
pushd DevOps
Expand Down
32 changes: 21 additions & 11 deletions DevOps/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@

SOFTWARE_PAGE = 'software/index.html'
PR_COMMIT_TEMPLATE = 'Software Release "{tag}"'
artifactS = {
PR_BODY_TEMPLATE = """
| Artifact Name | Size (KiB) | Content Type |
|-------------- | ---------- | ------------ |
""".strip()
ARTIFACTS = {
'dawn': {
re.compile(r'^dawn-win32'): 'dawn-win32-url',
re.compile(r'^dawn-darwin'): 'dawn-macos-url',
re.compile(r'^dawn-linux'): 'dawn-linux-url',
},
'runtime': {
re.compile(r'^frankfurter'): 'runtime-url',
re.compile(r'^frankfurter-update'): 'runtime-url',
}
}
TAG_PATTERN = re.compile(r'^(?P<project>dawn|runtime)/(?P<version>[\d\.]+)')
Expand Down Expand Up @@ -82,9 +86,9 @@ def get_repo(self, owner, repo):
return Github(access_token).get_repo(f'{owner}/{repo}')


def get_commit_from_tag(repo, tag):
def get_commit_from_tag(repo, target_tag):
for tag in repo.get_tags():
if tag.name == tag:
if tag.name == target_tag:
return tag.commit


Expand All @@ -99,7 +103,7 @@ def artifact_label(name):
def create_release(repo, tag, artifacts_dir, draft=False, prerelease=False):
commit = get_commit_from_tag(repo, tag)
if not commit:
logging.warn(f'Unable to find tag "{tag}". Skipping release.')
logging.warning(f'Unable to find tag "{tag}". Skipping release.')
return None, []
release = repo.create_git_release(tag, tag, commit.commit.message,
draft=draft, prerelease=prerelease)
Expand All @@ -108,9 +112,10 @@ def create_release(repo, tag, artifacts_dir, draft=False, prerelease=False):
artifact = os.path.join(artifacts_dir, filename)
if os.path.isfile(artifact):
artifact = release.upload_asset(artifact, label=artifact_label(filename))
logging.info(f'Uploading artifact "{artifact}" ...')
artifacts.append(artifact)
logging.info(f'Uploading artifact "{artifact.name}" ...')
else:
logging.warn(f'Cannot upload directory "{artifact}". Skipping.')
logging.warning(f'Cannot upload directory "{artifact}". Skipping.')
logging.info(f'Created release for tag "{tag}".')
return release, artifacts

Expand All @@ -124,16 +129,21 @@ def make_pull_request(repo, tag, artifacts, src_branch='master'):
page = repo.get_file_contents(SOFTWARE_PAGE, ref=branch_to_ref(src_branch))
contents = base64.b64decode(page.content.encode('utf-8')).decode('utf-8')

tag_match = TAG_PATTERN.match(tag)
tag_match, pr_body = TAG_PATTERN.match(tag), PR_BODY_TEMPLATE
project, version = tag_match.group('project'), tag_match.group('version')
for label_pattern, page_key in artifactS.get(project, {}).items():
for label_pattern, page_key in ARTIFACTS.get(project, {}).items():
for artifact in artifacts:
label = artifact.label or artifact_label(artifact.name)
if label_pattern.match(label):
contents = replace_page_key(contents, page_key, artifact.browser_download_url)
pr_body += ' | '.join([
f'[`{artifact.name}`]({artifact.browser_download_url})',
str(round(artifact.size/1024, 1)),
f'`{artifact.content_type}`',
]).strip() + '\n'
break
else:
logging.warn('Unable to find artifact for "{page_key}". Skipping.')
logging.warning(f'Unable to find artifact for "{page_key}". Skipping.')

today = datetime.date.today().strftime('%B %d, %Y')
contents = replace_page_key(contents, f'{project}-latest-ver', version)
Expand All @@ -142,7 +152,7 @@ def make_pull_request(repo, tag, artifacts, src_branch='master'):
ref = repo.create_git_ref(branch_to_ref(tag), sha=branch.commit.sha)
message = PR_COMMIT_TEMPLATE.format(tag=tag)
repo.update_file(SOFTWARE_PAGE, message, contents.encode('utf-8'), page.sha, branch=tag)
pr = repo.create_pull(title=message, base=src_branch, head=tag)
pr = repo.create_pull(title=message, body=pr_body, base=src_branch, head=tag)
logging.info(f'Created pull request #{pr.id} for "{repo.owner}/{repo.name}".')
return pr

Expand Down
3 changes: 1 addition & 2 deletions dawn/renderer/constants/Constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import keyMirror from 'keymirror';

// Read as YEAR.PUBLIC.INTERNAL
export const VERSION = '2019.1.0';
export const VERSION = '2.0.0';
export const PeripheralTypes = keyMirror({
MOTOR_SCALAR: null,
SENSOR_BOOLEAN: null,
Expand Down

0 comments on commit 803be86

Please sign in to comment.