Skip to content

Commit 6cf0f84

Browse files
authored
chore: set up CI on v2 branch (#510)
* chore: add basic CI for v2 branch * fix: use anonymous credentials, blacken
1 parent 0c5d9aa commit 6cf0f84

File tree

36 files changed

+3099
-857
lines changed

36 files changed

+3099
-857
lines changed

.github/workflows/docs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- v2
5+
name: docs
6+
jobs:
7+
docs:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
- name: Setup Python
13+
uses: actions/setup-python@v3
14+
with:
15+
python-version: "3.8"
16+
- name: Install nox
17+
run: |
18+
python -m pip install --upgrade setuptools pip wheel
19+
python -m pip install nox
20+
- name: Run docs
21+
run: |
22+
nox -s docs
23+
docfx:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
- name: Setup Python
29+
uses: actions/setup-python@v3
30+
with:
31+
python-version: "3.8"
32+
- name: Install nox
33+
run: |
34+
python -m pip install --upgrade setuptools pip wheel
35+
python -m pip install nox
36+
- name: Run docfx
37+
run: |
38+
nox -s docfx

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- v2
5+
name: lint
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
- name: Setup Python
13+
uses: actions/setup-python@v3
14+
with:
15+
python-version: "3.8"
16+
- name: Install nox
17+
run: |
18+
python -m pip install --upgrade setuptools pip wheel
19+
python -m pip install nox
20+
- name: Run lint
21+
run: |
22+
nox -s lint
23+
- name: Run lint_setup_py
24+
run: |
25+
nox -s lint_setup_py

.github/workflows/unittest.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- v2
5+
name: unittest
6+
jobs:
7+
unit:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python: ['3.6', '3.7', '3.8']
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Setup Python
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: ${{ matrix.python }}
19+
- name: Install nox
20+
run: |
21+
python -m pip install --upgrade setuptools pip wheel
22+
python -m pip install nox
23+
- name: Run unit tests
24+
env:
25+
COVERAGE_FILE: .coverage-${{ matrix.python }}
26+
run: |
27+
nox -s unit-${{ matrix.python }}
28+
- name: Upload coverage results
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: coverage-artifacts
32+
path: .coverage-${{ matrix.python }}
33+
34+
cover:
35+
runs-on: ubuntu-latest
36+
needs:
37+
- unit
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v3
41+
- name: Setup Python
42+
uses: actions/setup-python@v3
43+
with:
44+
python-version: "3.8"
45+
- name: Install coverage
46+
run: |
47+
python -m pip install --upgrade setuptools pip wheel
48+
python -m pip install coverage
49+
- name: Download coverage results
50+
uses: actions/download-artifact@v3
51+
with:
52+
name: coverage-artifacts
53+
path: .coverage-results/
54+
- name: Report coverage results
55+
run: |
56+
coverage combine .coverage-results/.coverage*
57+
coverage report --show-missing --fail-under=99

.kokoro/release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools
2626
export PYTHONUNBUFFERED=1
2727

2828
# Move into the package, build the distribution and upload.
29-
TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token")
29+
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1")
3030
cd github/python-logging
3131
python3 setup.py sdist bdist_wheel
3232
twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*

.kokoro/release/common.cfg

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@ env_vars: {
2323
value: "github/python-logging/.kokoro/release.sh"
2424
}
2525

26+
# Fetch PyPI password
27+
before_action {
28+
fetch_keystore {
29+
keystore_resource {
30+
keystore_config_id: 73713
31+
keyname: "google-cloud-pypi-token-keystore-1"
32+
}
33+
}
34+
}
35+
2636
# Tokens needed to report release status back to GitHub
2737
env_vars: {
2838
key: "SECRET_MANAGER_KEYS"
29-
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token"
39+
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
3040
}

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@
361361
intersphinx_mapping = {
362362
"python": ("https://python.readthedocs.org/en/latest/", None),
363363
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
364-
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
364+
"google.api_core": (
365+
"https://googleapis.dev/python/google-api-core/latest/",
366+
None,
367+
),
365368
"grpc": ("https://grpc.github.io/grpc/python/", None),
366369
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
367370
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),

google/cloud/logging_v2/_gapic.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,12 @@ def sink_get(self, sink_name):
278278
)
279279

280280
def sink_update(
281-
self, sink_name, filter_, destination, *, unique_writer_identity=False,
281+
self,
282+
sink_name,
283+
filter_,
284+
destination,
285+
*,
286+
unique_writer_identity=False,
282287
):
283288
"""Update a sink resource.
284289
@@ -305,7 +310,11 @@ def sink_update(
305310
protobuf to a dictionary).
306311
"""
307312
name = sink_name.split("/")[-1] # parse name out of full resoure name
308-
sink_pb = LogSink(name=name, filter=filter_, destination=destination,)
313+
sink_pb = LogSink(
314+
name=name,
315+
filter=filter_,
316+
destination=destination,
317+
)
309318

310319
request = UpdateSinkRequest(
311320
sink_name=sink_name,
@@ -341,7 +350,7 @@ def sink_delete(self, sink_name):
341350

342351

343352
class _MetricsAPI(object):
344-
"""Helper mapping sink-related APIs. """
353+
"""Helper mapping sink-related APIs."""
345354

346355
def __init__(self, gapic_api, client):
347356
self._gapic_api = gapic_api
@@ -363,7 +372,9 @@ def list_metrics(self, project, *, page_size=0, page_token=None):
363372
"""
364373
path = f"projects/{project}"
365374
request = ListLogMetricsRequest(
366-
parent=path, page_size=page_size, page_token=page_token,
375+
parent=path,
376+
page_size=page_size,
377+
page_token=page_token,
367378
)
368379
response = self._gapic_api.list_log_metrics(request=request)
369380
page_iter = iter(response)
@@ -414,7 +425,11 @@ def metric_get(self, project, metric_name):
414425
)
415426

416427
def metric_update(
417-
self, project, metric_name, filter_, description,
428+
self,
429+
project,
430+
metric_name,
431+
filter_,
432+
description,
418433
):
419434
"""Update a metric resource.
420435
@@ -430,7 +445,11 @@ def metric_update(
430445
protobuf to a dictionary).
431446
"""
432447
path = f"projects/{project}/metrics/{metric_name}"
433-
metric_pb = LogMetric(name=path, filter=filter_, description=description,)
448+
metric_pb = LogMetric(
449+
name=path,
450+
filter=filter_,
451+
description=description,
452+
)
434453
metric_pb = self._gapic_api.update_log_metric(
435454
metric_name=path, metric=metric_pb
436455
)

google/cloud/logging_v2/_http.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -441,18 +441,18 @@ def metric_get(self, project, metric_name):
441441
def metric_update(self, project, metric_name, filter_, description):
442442
"""Update a metric resource.
443443
444-
See
445-
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/update
446-
447-
Args:
448-
project (str): ID of the project containing the metric.
449-
metric_name (str): the name of the metric
450-
filter_ (str): the advanced logs filter expression defining the
451-
entries exported by the metric.
452-
description (str): description of the metric.
444+
See
445+
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/update
453446
454-
Returns:
455-
dict: The returned (updated) resource.
447+
Args:
448+
project (str): ID of the project containing the metric.
449+
metric_name (str): the name of the metric
450+
filter_ (str): the advanced logs filter expression defining the
451+
entries exported by the metric.
452+
description (str): description of the metric.
453+
454+
Returns:
455+
dict: The returned (updated) resource.
456456
"""
457457
target = f"/projects/{project}/metrics/{metric_name}"
458458
data = {"name": metric_name, "filter": filter_, "description": description}

google/cloud/logging_v2/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(
114114
client_options (Optional[Union[dict, google.api_core.client_options.ClientOptions]]):
115115
Client options used to set user options
116116
on the client. API Endpoint should be set through client_options.
117-
"""
117+
"""
118118
super(Client, self).__init__(
119119
project=project,
120120
credentials=credentials,

google/cloud/logging_v2/handlers/transports/sync.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ def send(self, record, message, **kwargs):
4242
"""
4343
info = {"message": message, "python_logger": record.name}
4444
self.logger.log_struct(
45-
info, severity=_helpers._normalize_severity(record.levelno), **kwargs,
45+
info,
46+
severity=_helpers._normalize_severity(record.levelno),
47+
**kwargs,
4648
)

0 commit comments

Comments
 (0)