Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
chore(tests): ensure test harness is up-to-date (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKevJames authored Jun 18, 2019
1 parent baa7fc4 commit bf6af90
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 167 deletions.
81 changes: 38 additions & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
version: 2
version: 2.1

jobs:
lint-py2:
docker:
- image: python:2.7.14
steps:
- checkout
- run: pip install pre-commit
- restore_cache:
keys:
- cache-pre-commit2-{{ checksum ".pre-commit-config.yaml" }}
- run: pre-commit run --all-files
- save_cache:
key: cache-pre-commit2-{{ checksum ".pre-commit-config.yaml" }}
paths:
- ~/.cache/pre-commit

lint-py3:
docker:
- image: python:3.6.2
steps:
- checkout
- run: pip install pre-commit
- restore_cache:
keys:
- cache-pre-commit3-{{ checksum ".pre-commit-config.yaml" }}
- run: pre-commit run --all-files
- save_cache:
key: cache-pre-commit3-{{ checksum ".pre-commit-config.yaml" }}
paths:
- ~/.cache/pre-commit
orbs:
linter: thekevjames/[email protected]

jobs:
test:
docker:
- image: googleapis/nox:0.17.0
- image: thekevjames/nox:2019.5.30
environment:
GOOGLE_APPLICATION_CREDENTIALS: /key.json
steps:
- run: echo ${GOOGLE_SERVICE_JSON} | base64 -d > ${GOOGLE_APPLICATION_CREDENTIALS}
- run: echo ${GOOGLE_SERVICE_PUBLIC} | base64 -d > ${GOOGLE_APPLICATION_CREDENTIALS}
- checkout
- run: nox

pypi:
docker:
- image: python:3.7.0-slim
- image: python:3.7.3-slim
steps:
- run: pip install twine
- run: pip install pyopenssl twine
- checkout
- deploy:
name: upload to pypi
Expand All @@ -53,7 +28,7 @@ jobs:
github:
docker:
- image: python:3.7.0-alpine3.8
- image: python:3.7.3-alpine3.8
steps:
- run: apk add --no-cache curl git openssh-client
- checkout
Expand All @@ -75,14 +50,30 @@ jobs:
cat release-description.md | ./bin/linux/amd64/github-release edit -t ${CIRCLE_TAG} -d -
workflows:
version: 2
run-jobs:
jobs:
- lint-py2:
- linter/pre-commit:
name: lint-py27
config_file: .pre-commit-config.py27.yaml
python_version: 2.7.14
filters:
tags:
only: /.*/
- linter/pre-commit:
name: lint-py35
python_version: 3.5.7
filters:
tags:
only: /.*/
- linter/pre-commit:
name: lint-py36
python_version: 3.6.8
filters:
tags:
only: /.*/
- lint-py3:
- linter/pre-commit:
name: lint-py37
python_version: 3.7.3
filters:
tags:
only: /.*/
Expand All @@ -100,8 +91,10 @@ workflows:
tags:
only: /[0-9]+\.[0-9]+\.[0-9]+/
requires:
- lint-py2
- lint-py3
- lint-py27
- lint-py35
- lint-py36
- lint-py37
- test
- github:
context: org-global
Expand All @@ -111,6 +104,8 @@ workflows:
tags:
only: /[0-9]+\.[0-9]+\.[0-9]+/
requires:
- lint-py2
- lint-py3
- lint-py27
- lint-py35
- lint-py36
- lint-py37
- test
9 changes: 5 additions & 4 deletions .github/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Contributing to ``gcloud-rest``
==============================
===============================

Thanks for contributing to ``gcloud-rest``! We appreciate contributions of any
size and hope to make it easy for you to dive in. Here's the thousand-foot
Expand All @@ -8,10 +8,11 @@ overview of how we've set this project up.
Testing
-------

Tests are run with `nox`_. See ``nox.py`` for the scaffolding and the ``tests/unit`` and
``tests/integration`` folders for the actual test code.
Tests are run with `nox`_. See ``noxfile.py`` for the scaffolding and the
``tests/unit`` and ``tests/integration`` folders for the actual test code.

You can get nox with ``pip install nox`` and run the project's tests with ``nox -f nox.py``.
You can get nox with ``pip install nox`` and run the project's tests with
``nox``.

Local Development
~~~~~~~~~~~~~~~~~
Expand Down
6 changes: 4 additions & 2 deletions .github/RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Releasing New Versions

CircleCI manages the entire release process for us. Here's what you need to do:

Make sure ``setup.py`` gets a version bump. `Semantic versioning`_ (``x.y.z``) is great.
Make sure ``setup.py`` gets a version bump. `Semantic versioning`_ (``x.y.z``)
is great.

Commit those changes to master and make sure CI is successful. Once it is, you
can create a release tag:
Expand All @@ -13,7 +14,8 @@ can create a release tag:
git tag 1.2.3
git push --tags
The tag format is "x.y.z"; that will kick off CI jobs for releasing the project and version to PyPI.
The tag format is "x.y.z"; that will kick off CI jobs for releasing the project
and version to PyPI.

CircleCI will also create a `GitHub release`_. Release notes are auto-generated
from commit messages, but you may want to check the new release and clean the
Expand Down
64 changes: 64 additions & 0 deletions .pre-commit-config.py27.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
args: [--allow-multiple-documents]
- id: debug-statements
- id: detect-private-key
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: file-contents-sorter
files: .(docker|git)ignore
- id: mixed-line-ending
args: [--fix=lf]
- id: name-tests-test
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v1.9.1
hooks:
- id: pylint
args:
- --max-line-length=79
- --ignore-imports=yes
- -d fixme
- -d import-error
- -d invalid-name
- -d locally-disabled
- -d missing-docstring
- -d too-few-public-methods
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.6
hooks:
- id: remove-crlf
- id: remove-tabs
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.5.0
hooks:
- id: reorder-python-imports
args: [--py26-plus]
- repo: https://github.com/asottile/yesqa
rev: v0.0.11
hooks:
- id: yesqa
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.4.4
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.4.0
hooks:
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
57 changes: 46 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: v1.2.3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: check-ast
- id: check-builtin-literals
args: [--no-allow-dict-kwargs]
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
Expand All @@ -19,29 +19,64 @@ repos:
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: file-contents-sorter
files: .gitignore
files: .(docker|git)ignore
- id: mixed-line-ending
args: [--fix=lf]
- id: name-tests-test
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: git://github.com/pre-commit/mirrors-pylint
sha: v1.8.4
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1
hooks:
- id: pylint
args:
- -d duplicate-code
- --max-line-length=79
- --ignore-imports=yes
- -d fixme
- -d import-error
- -d invalid-name
- -d locally-disabled
- -d missing-docstring
- repo: git://github.com/Lucas-C/pre-commit-hooks
sha: v1.1.5
- -d too-few-public-methods
- -d useless-object-inheritance # necessary for Python 2 compatibility
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.6
hooks:
- id: remove-crlf
- id: remove-tabs
- repo: git://github.com/asottile/reorder_python_imports
sha: v1.0.1
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.5.0
hooks:
- id: reorder-python-imports
args: [--py26-plus]
- repo: https://github.com/asottile/yesqa
rev: v0.0.11
hooks:
- id: yesqa
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.4.4
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/pydocstyle
rev: 792b8d92 # TODO: >3.0.0
hooks:
- id: pydocstyle
args:
- --ignore=D1,D203,D205,D212,D400,D401,D404
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
hooks:
- id: flake8
args:
- --ignore=E501,W503,F401,F811
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.4.0
hooks:
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- id: rst-backticks
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.0
hooks:
- id: rst-linter
3 changes: 0 additions & 3 deletions gcloud/rest/auth/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ def assertion(self):
algorithm='RS256')

def acquire(self):
"""
acquires a new token
"""
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
body = urlencode((
('grant_type', 'urn:ietf:params:oauth:grant-type:jwt-bearer'),
Expand Down
3 changes: 2 additions & 1 deletion gcloud/rest/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@


def backoff(base=2, factor=1.1, max_value=None):
"""Generator for exponential decay.
"""
Generator for exponential decay.
The Google docs warn to back off from polling their API if there is no
work available in a task queue. So we do.
Expand Down
Loading

0 comments on commit bf6af90

Please sign in to comment.