Skip to content

Commit

Permalink
chore: set up CI on v1 branch (#541)
Browse files Browse the repository at this point in the history
* chore: add basic CI to v1 branch

* chore: use newer black

* chore: fix docfx
  • Loading branch information
busunkim96 authored Apr 4, 2022
1 parent 905f644 commit 40c0cd6
Show file tree
Hide file tree
Showing 19 changed files with 222 additions and 96 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
pull_request:
branches:
- v1
name: docs
jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run docs
run: |
nox -s docs
docfx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run docfx
run: |
nox -s docfx
25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
pull_request:
branches:
- v1
name: lint
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run lint
run: |
nox -s lint
- name: Run lint_setup_py
run: |
nox -s lint_setup_py
57 changes: 57 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
pull_request:
branches:
- v1
name: unittest
jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.6', '3.7', '3.8']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run unit tests
env:
COVERAGE_FILE: .coverage-${{ matrix.python }}
run: |
nox -s unit-${{ matrix.python }}
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: .coverage-${{ matrix.python }}

cover:
runs-on: ubuntu-latest
needs:
- unit
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install coverage
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install coverage
- name: Download coverage results
uses: actions/download-artifact@v3
with:
name: coverage-artifacts
path: .coverage-results/
- name: Report coverage results
run: |
coverage combine .coverage-results/.coverage*
coverage report --show-missing --fail-under=99
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pip-log.txt
.nox
.cache
.pytest_cache
*_sponge_log.xml


# Mac
Expand Down
4 changes: 2 additions & 2 deletions .kokoro/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools
export PYTHONUNBUFFERED=1

# Move into the package, build the distribution and upload.
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password")
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1")
cd github/python-bigtable
python3 setup.py sdist bdist_wheel
twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/*
twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*
18 changes: 9 additions & 9 deletions .kokoro/release/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ env_vars: {
value: "github/python-bigtable/.kokoro/release.sh"
}

# Fetch PyPI password
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "google_cloud_pypi_password"
}
}
# Fetch PyPI password
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "google-cloud-pypi-token-keystore-1"
}
}
}

# Tokens needed to report release status back to GitHub
env_vars: {
key: "SECRET_MANAGER_KEYS"
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
}
}
12 changes: 6 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
master_doc = "index"

# General information about the project.
project = u"google-cloud-bigtable"
copyright = u"2019, Google"
author = u"Google APIs"
project = "google-cloud-bigtable"
copyright = "2019, Google"
author = "Google APIs"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -268,7 +268,7 @@
(
master_doc,
"google-cloud-bigtable.tex",
u"google-cloud-bigtable Documentation",
"google-cloud-bigtable Documentation",
author,
"manual",
)
Expand Down Expand Up @@ -303,7 +303,7 @@
(
master_doc,
"google-cloud-bigtable",
u"google-cloud-bigtable Documentation",
"google-cloud-bigtable Documentation",
[author],
1,
)
Expand All @@ -322,7 +322,7 @@
(
master_doc,
"google-cloud-bigtable",
u"google-cloud-bigtable Documentation",
"google-cloud-bigtable Documentation",
author,
"google-cloud-bigtable",
"google-cloud-bigtable Library",
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
PRODUCTION = enums.Instance.Type.PRODUCTION
SERVER_NODES = 3
STORAGE_TYPE = enums.StorageType.SSD
LABEL_KEY = u"python-snippet"
LABEL_KEY = "python-snippet"
LABEL_STAMP = (
datetime.datetime.utcnow()
.replace(microsecond=0, tzinfo=UTC)
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
PRODUCTION = enums.Instance.Type.PRODUCTION
SERVER_NODES = 3
STORAGE_TYPE = enums.StorageType.SSD
LABEL_KEY = u"python-snippet"
LABEL_KEY = "python-snippet"
LABEL_STAMP = (
datetime.datetime.utcnow()
.replace(microsecond=0, tzinfo=UTC)
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigtable/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def delete(self):
client.instance_admin_client.delete_cluster(self.name)

def _to_pb(self):
""" Create cluster proto buff message for API calls """
"""Create cluster proto buff message for API calls"""
client = self._instance._client
location = client.instance_admin_client.location_path(
client.project, self.location_id
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/bigtable/row_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,15 @@ def build_updated_request(self):
return data_messages_v2_pb2.ReadRowsRequest(**r_kwargs)

def _filter_rows_keys(self):
""" Helper for :meth:`build_updated_request`"""
"""Helper for :meth:`build_updated_request`"""
return [
row_key
for row_key in self.message.rows.row_keys
if row_key > self.last_scanned_key
]

def _filter_row_ranges(self):
""" Helper for :meth:`build_updated_request`"""
"""Helper for :meth:`build_updated_request`"""
new_row_ranges = []

for row_range in self.message.rows.row_ranges:
Expand Down Expand Up @@ -689,17 +689,17 @@ def _filter_row_ranges(self):
return new_row_ranges

def _key_already_read(self, key):
""" Helper for :meth:`_filter_row_ranges`"""
"""Helper for :meth:`_filter_row_ranges`"""
return key <= self.last_scanned_key

@staticmethod
def _start_key_set(row_range):
""" Helper for :meth:`_filter_row_ranges`"""
"""Helper for :meth:`_filter_row_ranges`"""
return row_range.start_key_open or row_range.start_key_closed

@staticmethod
def _end_key_set(row_range):
""" Helper for :meth:`_filter_row_ranges`"""
"""Helper for :meth:`_filter_row_ranges`"""
return row_range.end_key_open or row_range.end_key_closed


Expand Down
9 changes: 7 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@

import nox

BLACK_VERSION = "black==22.3.0"

DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["2.7", "3.8"]
UNIT_TEST_PYTHON_VERSIONS = ["2.7", "3.5", "3.6", "3.7", "3.8"]
LOCAL_DEPS = ()

# Error if a python version is missing
nox.options.error_on_missing_interpreters = True


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint(session):
"""Run linters.
Expand All @@ -44,7 +49,7 @@ def lint(session):
session.run("flake8", "google", "tests")


@nox.session(python="3.6")
@nox.session(python=DEFAULT_PYTHON_VERSION)
def blacken(session):
"""Run black.
Expand Down Expand Up @@ -194,7 +199,7 @@ def docfx(session):
"""Build the docfx yaml files for this library."""

session.install("-e", ".")
session.install("sphinx", "alabaster", "recommonmark", "sphinx-docfx-yaml")
session.install("sphinx", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml")

shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
session.run(
Expand Down
10 changes: 5 additions & 5 deletions tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
CLUSTER_ID = INSTANCE_ID + "-cluster"
CLUSTER_ID_DATA = INSTANCE_ID_DATA + "-cluster"
SERVE_NODES = 3
COLUMN_FAMILY_ID1 = u"col-fam-id1"
COLUMN_FAMILY_ID2 = u"col-fam-id2"
COLUMN_FAMILY_ID1 = "col-fam-id1"
COLUMN_FAMILY_ID2 = "col-fam-id2"
COL_NAME1 = b"col-name1"
COL_NAME2 = b"col-name2"
COL_NAME3 = b"col-name3-but-other-fam"
Expand All @@ -65,7 +65,7 @@
ROW_KEY = b"row-key"
ROW_KEY_ALT = b"row-key-alt"
EXISTING_INSTANCES = []
LABEL_KEY = u"python-system"
LABEL_KEY = "python-system"
label_stamp = (
datetime.datetime.utcnow()
.replace(microsecond=0, tzinfo=UTC)
Expand Down Expand Up @@ -1202,13 +1202,13 @@ def test_read_with_label_applied(self):
row.commit()

# Combine a label with column 1.
label1 = u"label-red"
label1 = "label-red"
label1_filter = ApplyLabelFilter(label1)
col1_filter = ColumnQualifierRegexFilter(COL_NAME1)
chain1 = RowFilterChain(filters=[col1_filter, label1_filter])

# Combine a label with column 2.
label2 = u"label-blue"
label2 = "label-blue"
label2_filter = ApplyLabelFilter(label2)
col2_filter = ColumnQualifierRegexFilter(COL_NAME2)
chain2 = RowFilterChain(filters=[col2_filter, label2_filter])
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_column_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _make_client(self, *args, **kwargs):
return self._get_target_client_class()(*args, **kwargs)

def test_constructor(self):
column_family_id = u"column-family-id"
column_family_id = "column-family-id"
table = object()
gc_rule = object()
column_family = self._make_one(column_family_id, table, gc_rule=gc_rule)
Expand All @@ -293,7 +293,7 @@ def test_constructor(self):
self.assertIs(column_family.gc_rule, gc_rule)

def test_name_property(self):
column_family_id = u"column-family-id"
column_family_id = "column-family-id"
table_name = "table_name"
table = _Table(table_name)
column_family = self._make_one(column_family_id, table)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def test_reload(self):
instance = self._make_one(self.INSTANCE_ID, client)

# Create response_pb
DISPLAY_NAME = u"hey-hi-hello"
DISPLAY_NAME = "hey-hi-hello"
instance_type = enums.Instance.Type.PRODUCTION
response_pb = data_v2_pb2.Instance(
display_name=DISPLAY_NAME, type=instance_type, labels=self.LABELS
Expand Down
Loading

0 comments on commit 40c0cd6

Please sign in to comment.