Skip to content

Commit

Permalink
chore: copy %%bigquery magics tests from google-cloud-bigquery (#8)
Browse files Browse the repository at this point in the history
* chore: copy magics unit tests from google-cloud-bigquery

* update tests to use bigquery_magics module

* remove auth from unit tests

* fix coverage
  • Loading branch information
tswast authored Apr 11, 2024
1 parent c3baea5 commit 30d05bc
Show file tree
Hide file tree
Showing 58 changed files with 3,541 additions and 852 deletions.
31 changes: 28 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
# -*- coding: utf-8 -*-
#
# Copyright 2023 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.

# Generated by synthtool. DO NOT EDIT!
[run]
branch = True
omit =
google/__init__.py
google/cloud/__init__.py

[report]
fail_under = 100
show_missing = True
omit =
google/cloud/bigquery/__init__.py
google/cloud/bigquery_v2/* # Legacy proto-based types.
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore abstract methods
raise NotImplementedError
omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
google/cloud/__init__.py
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:
- main
name: docs
jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- 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@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- 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:
- main
name: lint
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
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:
- main
name: unittest
jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.7', '3.8', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
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@v4
with:
name: coverage-artifact-${{ matrix.python }}
path: .coverage-${{ matrix.python }}

cover:
runs-on: ubuntu-latest
needs:
- unit
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
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@v4
with:
path: .coverage-results/
- name: Report coverage results
run: |
find .coverage-results -type f -name '*.zip' -exec unzip {} \;
coverage combine .coverage-results/**/.coverage*
coverage report --show-missing --fail-under=100
9 changes: 1 addition & 8 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
set -eo pipefail

if [[ -z "${PROJECT_ROOT:-}" ]]; then
PROJECT_ROOT="github/python-bigquery"
PROJECT_ROOT="github/python-bigquery-magics"
fi

cd "${PROJECT_ROOT}"
Expand All @@ -33,13 +33,6 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
# Setup project id.
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")

# Remove old nox
python3 -m pip uninstall --yes --quiet nox-automation

# Install nox
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
Expand Down
4 changes: 2 additions & 2 deletions .kokoro/continuous/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"

# Use the trampoline script to run in docker.
build_file: "python-bigquery/.kokoro/trampoline.sh"
build_file: "python-bigquery-magics/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
Expand All @@ -23,5 +23,5 @@ env_vars: {
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-bigquery/.kokoro/build.sh"
value: "github/python-bigquery-magics/.kokoro/build.sh"
}
4 changes: 4 additions & 0 deletions .kokoro/docker/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
# Test pip
RUN python3 -m pip

# Install build requirements
COPY requirements.txt /requirements.txt
RUN python3 -m pip install --require-hashes -r requirements.txt

CMD ["python3.8"]
1 change: 1 addition & 0 deletions .kokoro/docker/docs/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nox
38 changes: 38 additions & 0 deletions .kokoro/docker/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes requirements.in
#
argcomplete==3.2.3 \
--hash=sha256:bf7900329262e481be5a15f56f19736b376df6f82ed27576fa893652c5de6c23 \
--hash=sha256:c12355e0494c76a2a7b73e3a59b09024ca0ba1e279fb9ed6c1b82d5b74b6a70c
# via nox
colorlog==6.8.2 \
--hash=sha256:3e3e079a41feb5a1b64f978b5ea4f46040a94f11f0e8bbb8261e3dbbeca64d44 \
--hash=sha256:4dcbb62368e2800cb3c5abd348da7e53f6c362dda502ec27c560b2e58a66bd33
# via nox
distlib==0.3.8 \
--hash=sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784 \
--hash=sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64
# via virtualenv
filelock==3.13.1 \
--hash=sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e \
--hash=sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c
# via virtualenv
nox==2024.3.2 \
--hash=sha256:e53514173ac0b98dd47585096a55572fe504fecede58ced708979184d05440be \
--hash=sha256:f521ae08a15adbf5e11f16cb34e8d0e6ea521e0b92868f684e91677deb974553
# via -r requirements.in
packaging==24.0 \
--hash=sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5 \
--hash=sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9
# via nox
platformdirs==4.2.0 \
--hash=sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068 \
--hash=sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768
# via virtualenv
virtualenv==20.25.1 \
--hash=sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a \
--hash=sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197
# via nox
9 changes: 5 additions & 4 deletions .kokoro/docs/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ action {
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-bigquery/.kokoro/trampoline_v2.sh"
build_file: "python-bigquery-magics/.kokoro/trampoline_v2.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
Expand All @@ -20,7 +20,7 @@ env_vars: {
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-bigquery/.kokoro/publish-docs.sh"
value: "github/python-bigquery-magics/.kokoro/publish-docs.sh"
}

env_vars: {
Expand All @@ -30,8 +30,9 @@ env_vars: {

env_vars: {
key: "V2_STAGING_BUCKET"
# Push google cloud library docs to the Cloud RAD bucket `docs-staging-v2`
value: "docs-staging-v2"
# Push non-cloud library docs to `docs-staging-v2-staging` instead of the
# Cloud RAD bucket `docs-staging-v2`
value: "docs-staging-v2-staging"
}

# It will upload the docker image after successful builds.
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/docs/docs-presubmit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env_vars: {

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-bigquery/.kokoro/build.sh"
value: "github/python-bigquery-magics/.kokoro/build.sh"
}

# Only run this nox session.
Expand Down
4 changes: 2 additions & 2 deletions .kokoro/presubmit/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"

# Use the trampoline script to run in docker.
build_file: "python-bigquery/.kokoro/trampoline.sh"
build_file: "python-bigquery-magics/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
Expand All @@ -23,5 +23,5 @@ env_vars: {
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-bigquery/.kokoro/build.sh"
value: "github/python-bigquery-magics/.kokoro/build.sh"
}
12 changes: 1 addition & 11 deletions .kokoro/presubmit/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Disable system tests.
env_vars: {
key: "RUN_SYSTEM_TESTS"
value: "false"
}
env_vars: {
key: "RUN_SNIPPETS_TESTS"
value: "false"
}
# Format: //devtools/kokoro/config/proto/build.proto
7 changes: 0 additions & 7 deletions .kokoro/presubmit/snippets-3.12.cfg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "snippets-3.8"
}
value: "system-3.11"
}
4 changes: 2 additions & 2 deletions .kokoro/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
set -eo pipefail

# Start the releasetool reporter
python3 -m pip install --require-hashes -r github/python-bigquery/.kokoro/requirements.txt
python3 -m pip install --require-hashes -r github/python-bigquery-magics/.kokoro/requirements.txt
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1

# Move into the package, build the distribution and upload.
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1")
cd github/python-bigquery
cd github/python-bigquery-magics
python3 setup.py sdist bdist_wheel
twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*
8 changes: 4 additions & 4 deletions .kokoro/release/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ action {
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-bigquery/.kokoro/trampoline.sh"
build_file: "python-bigquery-magics/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
Expand All @@ -20,7 +20,7 @@ env_vars: {
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-bigquery/.kokoro/release.sh"
value: "github/python-bigquery-magics/.kokoro/release.sh"
}

# Fetch PyPI password
Expand All @@ -43,7 +43,7 @@ env_vars: {
# what we published, which we can use to generate SBOMs and attestations.
action {
define_artifacts {
regex: "github/python-bigquery/**/*.tar.gz"
strip_prefix: "github/python-bigquery"
regex: "github/python-bigquery-magics/**/*.tar.gz"
strip_prefix: "github/python-bigquery-magics"
}
}
3 changes: 2 additions & 1 deletion .kokoro/requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gcp-docuploader
gcp-releasetool>=1.10.5 # required for compatibility with cryptography>=39.x
gcp-releasetool>=2 # required for compatibility with cryptography>=42.x
importlib-metadata
typing-extensions
twine
Expand All @@ -8,3 +8,4 @@ setuptools
nox>=2022.11.21 # required to remove dependency on py
charset-normalizer<3
click<8.1.0
cryptography>=42.0.5
Loading

0 comments on commit 30d05bc

Please sign in to comment.