-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
59 changed files
with
1,099 additions
and
658 deletions.
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 |
---|---|---|
|
@@ -26,6 +26,7 @@ exclude = | |
*_pb2.py | ||
|
||
# Standard linting exemptions. | ||
**/.nox/** | ||
__pycache__, | ||
.git, | ||
*.pyc, | ||
|
15 changes: 15 additions & 0 deletions
15
packages/google-cloud-monitoring-dashboards/.github/header-checker-lint.yml
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,15 @@ | ||
{"allowedCopyrightHolders": ["Google LLC"], | ||
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"], | ||
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"], | ||
"sourceFileExtensions": [ | ||
"ts", | ||
"js", | ||
"java", | ||
"sh", | ||
"Dockerfile", | ||
"yaml", | ||
"py", | ||
"html", | ||
"txt" | ||
] | ||
} |
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
11 changes: 11 additions & 0 deletions
11
packages/google-cloud-monitoring-dashboards/.kokoro/samples/python3.6/periodic-head.cfg
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,11 @@ | ||
# Format: //devtools/kokoro/config/proto/build.proto | ||
|
||
env_vars: { | ||
key: "INSTALL_LIBRARY_FROM_SOURCE" | ||
value: "True" | ||
} | ||
|
||
env_vars: { | ||
key: "TRAMPOLINE_BUILD_FILE" | ||
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh" | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/google-cloud-monitoring-dashboards/.kokoro/samples/python3.7/periodic-head.cfg
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,11 @@ | ||
# Format: //devtools/kokoro/config/proto/build.proto | ||
|
||
env_vars: { | ||
key: "INSTALL_LIBRARY_FROM_SOURCE" | ||
value: "True" | ||
} | ||
|
||
env_vars: { | ||
key: "TRAMPOLINE_BUILD_FILE" | ||
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh" | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/google-cloud-monitoring-dashboards/.kokoro/samples/python3.8/periodic-head.cfg
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,11 @@ | ||
# Format: //devtools/kokoro/config/proto/build.proto | ||
|
||
env_vars: { | ||
key: "INSTALL_LIBRARY_FROM_SOURCE" | ||
value: "True" | ||
} | ||
|
||
env_vars: { | ||
key: "TRAMPOLINE_BUILD_FILE" | ||
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh" | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/google-cloud-monitoring-dashboards/.kokoro/test-samples-against-head.sh
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,28 @@ | ||
#!/bin/bash | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
# A customized test runner for samples. | ||
# | ||
# For periodic builds, you can specify this file for testing against head. | ||
|
||
# `-e` enables the script to automatically fail when a command fails | ||
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero | ||
set -eo pipefail | ||
# Enables `**` to include files nested inside sub-folders | ||
shopt -s globstar | ||
|
||
cd github/python-monitoring-dashboards | ||
|
||
exec .kokoro/test-samples-impl.sh |
102 changes: 102 additions & 0 deletions
102
packages/google-cloud-monitoring-dashboards/.kokoro/test-samples-impl.sh
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,102 @@ | ||
#!/bin/bash | ||
# Copyright 2021 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
|
||
# `-e` enables the script to automatically fail when a command fails | ||
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero | ||
set -eo pipefail | ||
# Enables `**` to include files nested inside sub-folders | ||
shopt -s globstar | ||
|
||
# Exit early if samples directory doesn't exist | ||
if [ ! -d "./samples" ]; then | ||
echo "No tests run. `./samples` not found" | ||
exit 0 | ||
fi | ||
|
||
# Disable buffering, so that the logs stream through. | ||
export PYTHONUNBUFFERED=1 | ||
|
||
# Debug: show build environment | ||
env | grep KOKORO | ||
|
||
# Install nox | ||
python3.6 -m pip install --upgrade --quiet nox | ||
|
||
# Use secrets acessor service account to get secrets | ||
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then | ||
gcloud auth activate-service-account \ | ||
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \ | ||
--project="cloud-devrel-kokoro-resources" | ||
fi | ||
|
||
# This script will create 3 files: | ||
# - testing/test-env.sh | ||
# - testing/service-account.json | ||
# - testing/client-secrets.json | ||
./scripts/decrypt-secrets.sh | ||
|
||
source ./testing/test-env.sh | ||
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json | ||
|
||
# For cloud-run session, we activate the service account for gcloud sdk. | ||
gcloud auth activate-service-account \ | ||
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}" | ||
|
||
export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json | ||
|
||
echo -e "\n******************** TESTING PROJECTS ********************" | ||
|
||
# Switch to 'fail at end' to allow all tests to complete before exiting. | ||
set +e | ||
# Use RTN to return a non-zero value if the test fails. | ||
RTN=0 | ||
ROOT=$(pwd) | ||
# Find all requirements.txt in the samples directory (may break on whitespace). | ||
for file in samples/**/requirements.txt; do | ||
cd "$ROOT" | ||
# Navigate to the project folder. | ||
file=$(dirname "$file") | ||
cd "$file" | ||
|
||
echo "------------------------------------------------------------" | ||
echo "- testing $file" | ||
echo "------------------------------------------------------------" | ||
|
||
# Use nox to execute the tests for the project. | ||
python3.6 -m nox -s "$RUN_TESTS_SESSION" | ||
EXIT=$? | ||
|
||
# If this is a periodic build, send the test log to the FlakyBot. | ||
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot. | ||
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then | ||
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot | ||
$KOKORO_GFILE_DIR/linux_amd64/flakybot | ||
fi | ||
|
||
if [[ $EXIT -ne 0 ]]; then | ||
RTN=1 | ||
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n" | ||
else | ||
echo -e "\n Testing completed.\n" | ||
fi | ||
|
||
done | ||
cd "$ROOT" | ||
|
||
# Workaround for Kokoro permissions issue: delete secrets | ||
rm testing/{test-env.sh,client-secrets.json,service-account.json} | ||
|
||
exit "$RTN" |
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
17 changes: 17 additions & 0 deletions
17
packages/google-cloud-monitoring-dashboards/.pre-commit-config.yaml
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,17 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- repo: https://github.com/psf/black | ||
rev: 19.10b0 | ||
hooks: | ||
- id: black | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.9.0 | ||
hooks: | ||
- id: flake8 |
Oops, something went wrong.