This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
Artman Refactor #159
Merged
Merged
Artman Refactor #159
Changes from 40 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
4b51828
Improve output.
083b703
[WIP] GitHub clone task.
746e7d7
[WIP] GitHub PRs.
6f1a5f0
[wip] Nearly done with GitHub staging.
d6e5793
[wip] more github
06f4bb2
[wip] Got a successful PR!
5153700
[wip] Artman GitHub support.
d3b7f18
Move guts out of artman script for testability.
052d4b7
Fix imports that were not saved.
44a3e2f
[wip] unit tests
e63b934
Do not store .nox in git
43568da
More tests
22e0006
More tests
9716fb4
More work.
a64a244
Rename repo_subpath to gapic_subpath
982711d
wip
ffa20eb
Salt branch names.
6da2992
[wip]
da99675
Rename pipeline.* prefix to artman.*
3f761a2
Oops, did not remove everything.
f50e891
Move pipeline. to artman. at the top level.
53699a2
Fixing stuff.
39ca93e
Update docs and smoke tests.
ad91e29
More tests, readme changes
0972f86
Add tests; make long _pipeline names shorter.
e0b2818
More tests.
6da2036
Bugfix
lukesneeringer 394b7a0
wip
d371138
Many more tests.
2cb678a
Remove build subcommand; make configure-artman a separate thing.
e60a967
More
8292f58
Merge branch 'master' into github-pr
631e925
Test Python 3.4 also.
9eb42c8
Install codecov in Travis.
e1f37a9
Fix package name in README.
3492d8b
Handle a couple of @ethanbao's comments.
462dde7
Make REPOROOT explanation more specific.
14f0218
Per @ethanbao, finiah sentence in gapic_generation.py docstring.
6360fd5
Dockerfile is the canonical installation script.
8331fef
Added a logging.info call.
c05d6d8
Fix 2.7 compat.
9ddfdbf
Change ~/.artman.yml to ~/.artman/config.yml
cea14a7
Convert final instances of ~/.artman.yaml
4bac30e
Remove rm from Java copy task, and add TODO
michaelbausor 840dd8e
Fix readme.
23ca1aa
Merge branch 'github-pr' of github.com:lukesneeringer/artman into git…
65222ca
Remove out of date USAGE file. The commands are now covered in README.
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
[run] | ||
branch = True | ||
source = pipeline/ | ||
source = artman/ | ||
|
||
[report] | ||
# fail_under = 75 | ||
show_missing = True | ||
exclude_lines = | ||
# Re-enable the standard pragma | ||
pragma: no-cover | ||
|
||
# Ignore debug-only repr | ||
def __repr__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
# Copyright 2016 Google Inc. All Rights Reserved. | ||
# Copyright 2017 Google | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import absolute_import, unicode_literals | ||
|
||
from artman.cli import configure | ||
from artman.cli import main | ||
from artman.cli import support | ||
|
||
__all__ = ('configure', 'main', 'support') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# Copyright 2017 Google | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import absolute_import | ||
from copy import copy | ||
import getpass | ||
import importlib | ||
import io | ||
import logging | ||
import os | ||
|
||
import six | ||
|
||
from ruamel import yaml | ||
|
||
from artman.utils.logger import logger | ||
from artman.utils.logger import setup_logging | ||
|
||
__all__ = ('configure',) | ||
|
||
|
||
def configure(log_level=logging.INFO): | ||
"""Allow the user to write a new configuration file. | ||
|
||
Returns: | ||
int: An exit status. | ||
""" | ||
user_config = {} | ||
|
||
# Walk the user through basic configuration. | ||
setup_logging(log_level) | ||
logger.info('Welcome to artman. We will get you configured.') | ||
logger.info('When this is done, config will be stored in ~/.artman.yaml.') | ||
logger.info('') | ||
|
||
# Go through each step. | ||
# These are split out to make testing them easier. | ||
user_config['local_paths'] = _configure_local_paths( | ||
user_config.get('local_paths', {}), | ||
) | ||
user_config['publish'] = _configure_publish() | ||
if user_config['publish'] == 'github': | ||
user_config['github'] = _configure_github( | ||
user_config.get('github', {}), | ||
) | ||
|
||
# Write the final configuration. | ||
config_yaml = yaml.dump(user_config, | ||
block_seq_indent=2, | ||
default_flow_style=False, | ||
indent=2, | ||
) | ||
with io.open(os.path.expanduser('~/.artman.yaml'), 'w+') as file_: | ||
file_.write('---\n') | ||
file_.write(config_yaml) | ||
logger.success('Configuration written successfully to ~/.artman.yaml.') | ||
|
||
|
||
def _configure_local_paths(local_paths): | ||
"""Return a copy of user_config with local_paths set. | ||
|
||
Args: | ||
local_paths (dict): The starting local_paths portion ofuser config. | ||
|
||
Returns: | ||
dict: The new local_paths dictionary. | ||
""" | ||
answer = copy(local_paths) | ||
|
||
# Ask the user for a repository root. | ||
while not answer.get('reporoot'): | ||
logger.info('First, we need to know where you store most code on your ' | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong. |
||
'local machine.') | ||
logger.info('Other paths (example: toolkit) will derive from this, ' | ||
'but most are individually configurable.') | ||
logger.info('The use of ${REPOROOT} in GAPIC YAMLs will point here.') | ||
logger.info('Note: Use of ~ is fine here.') | ||
answer['reporoot'] = six.moves.input('Local code path: ') | ||
answer['reporoot'] = answer['reporoot'].rstrip('/').strip() | ||
|
||
# Set up dependent directories. | ||
reporoot = answer['reporoot'] | ||
for dep in ('api-client-staging', 'googleapis', 'toolkit'): | ||
location = six.moves.input( | ||
'Path for {0} (default: {1}/{0}): '.format(dep, reporoot) | ||
).rstrip('/').strip() | ||
if location: | ||
answer[dep.replace('-', '_')] = location | ||
|
||
# Done; return the answer. | ||
return answer | ||
|
||
|
||
def _configure_publish(publish=None): | ||
"""Determine and return the default publisher. | ||
|
||
Args: | ||
publish (str): The current default publisher (may be None). | ||
|
||
Returns: | ||
str: The new default publisher. | ||
""" | ||
# Set up publishing defaults. | ||
logger.info('Where do you want to publish code by default?') | ||
logger.info('The common valid options are "github" and "local".') | ||
publish = six.moves.input('Default publisher: ').lower() | ||
try: | ||
importlib.import_module('artman.tasks.publish.%s' % publish) | ||
return publish | ||
except ImportError: | ||
logger.error('Invalid publisher.') | ||
return _configure_publish() | ||
|
||
|
||
def _configure_github(github): | ||
"""Determine and return the GitHub configuration. | ||
|
||
Args: | ||
github (dict): The current GitHub configuration. | ||
|
||
Returns: | ||
dict: The new GitHub configuration. | ||
""" | ||
answer = copy(github) | ||
logger.info('Since you intend to publish to GitHub, you need to ' | ||
'supply credentials.') | ||
logger.info('Create an access token at: ' | ||
'https://github.com/settings/tokens') | ||
logger.info('It needs the "repo" scope and nothing else.') | ||
while not answer.get('username'): | ||
answer['username'] = six.moves.input('GitHub username: ') | ||
while not answer.get('token'): | ||
answer['token'] = getpass.getpass('GitHub token (input is hidden): ') | ||
return answer |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.