diff --git a/.github/.kodiak.toml b/.github/.kodiak.toml new file mode 100644 index 0000000..a963117 --- /dev/null +++ b/.github/.kodiak.toml @@ -0,0 +1,15 @@ +version = 1 + +[approve] +auto_approve_usernames = ["cq-bot"] + +[merge.message] +body = "pull_request_body" +cut_body_after = "Use the following steps to ensure your PR is ready to be reviewed" +cut_body_and_text = true +cut_body_before = "" +title = "pull_request_title" + +[merge] +blocking_labels = ["wip", "no automerge"] +notify_on_conflict = false diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 0000000..a139bff --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,3 @@ +{ + extends: ["github>cloudquery/.github//.github/renovate-python-default.json5"], +} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6d2bb3d..7ce2828 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,20 +7,15 @@ on: - main jobs: - build: - + lint: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 - - - name: Install Black - run: pip install black - - - name: Run Black - run: black --check . + python-version: "3.x" + - name: Install dependencies + run: pip install -r requirements.txt + - name: Check formatting + run: make fmt-check diff --git a/.github/workflows/pr_title.yml b/.github/workflows/pr_title.yml new file mode 100644 index 0000000..c44b736 --- /dev/null +++ b/.github/workflows/pr_title.yml @@ -0,0 +1,52 @@ +name: "Validate PR title" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + # Please look up the latest version from + # https://github.com/amannn/action-semantic-pull-request/releases + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # Configure which types are allowed. + # Default: https://github.com/commitizen/conventional-commit-types + types: | + fix + feat + chore + refactor + test + # Configure that a scope must always be provided. + requireScope: false + # Configure additional validation for the subject based on a regex. + # This example ensures the subject starts with an uppercase character. + subjectPattern: ^[A-Z].+$ + # If `subjectPattern` is configured, you can use this property to override + # the default error message that is shown when the pattern doesn't match. + # The variables `subject` and `title` can be used within the message. + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + starts with an uppercase character. + # For work-in-progress PRs you can typically use draft pull requests + # from Github. However, private repositories on the free plan don't have + # this option and therefore this action allows you to opt-in to using the + # special "[WIP]" prefix to indicate this state. This will avoid the + # validation of the PR title and the pull request checks remain pending. + # Note that a second check will be reported if this is enabled. + wip: true + # When using "Squash and merge" on a PR with only one commit, GitHub + # will suggest using that commit message instead of the PR title for the + # merge commit, and it's easy to commit this by mistake. Enable this option + # to also validate the commit message for one commit PRs. + validateSingleCommit: false diff --git a/.github/workflows/release_pr.yml b/.github/workflows/release_pr.yml new file mode 100644 index 0000000..7e4b9c9 --- /dev/null +++ b/.github/workflows/release_pr.yml @@ -0,0 +1,21 @@ +name: release-please +on: + push: + branches: + - main + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: python + package-name: plugin-sdk-python + token: ${{ secrets.GH_CQ_BOT }} + pull-request-title-pattern: "chore${scope}: Release${component} v${version}" + # Should breaking changes before 1.0.0 produce minor bumps? + bump-minor-pre-major: true + # Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? + bump-patch-for-minor-pre-major: true diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 9587295..eec37c9 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -13,11 +13,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - name: Set up Python + uses: actions/setup-python@v4 with: - python-version: "3.9" - cache: "pip" - cache-dependency-path: "./requirements.txt" + python-version: "3.x" - name: Install dependencies run: pip install -r requirements.txt - name: Run tests diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..36c33b2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +# Changelog + +## [0.0.6](https://github.com/cloudquery/plugin-sdk-python/compare/v0.0.5...v0.0.6) (2023-07-28) + + +### Features + +* Add minimal openapi transformer ([083b9ff](https://github.com/cloudquery/plugin-sdk-python/commit/083b9ff863979f8c6410df8e6980f76a53a71bb9)) + + +### Bug Fixes + +* Pytest to run all tests ([#4](https://github.com/cloudquery/plugin-sdk-python/issues/4)) ([1eb5c7f](https://github.com/cloudquery/plugin-sdk-python/commit/1eb5c7fb91e623fa9ab0bb187e4dddab824e8b08)) diff --git a/Makefile b/Makefile index cf4b3af..6b02a74 100644 --- a/Makefile +++ b/Makefile @@ -2,5 +2,7 @@ test: pytest . fmt: - pip install -q black black . + +fmt-check: + black --check . \ No newline at end of file diff --git a/cloudquery/sdk/transformers/openapi.py b/cloudquery/sdk/transformers/openapi.py new file mode 100644 index 0000000..831e1cd --- /dev/null +++ b/cloudquery/sdk/transformers/openapi.py @@ -0,0 +1,24 @@ +from typing import Dict, List +import pyarrow as pa +from cloudquery.sdk.schema import Column + + +def oapi_type_to_arrow_type(field) -> pa.DataType: + oapi_type = field.get("type") + if oapi_type == "string": + return pa.string() + elif oapi_type == "number": + return pa.int64() + elif oapi_type == "boolean": + return pa.bool_() + else: + return pa.string() + + +def oapi_properties_to_columns(properties: Dict) -> List[Column]: + columns = [] + for key, value in properties.items(): + columns.append( + Column(name=key, type=value, description=value.get("description")) + ) + return columns diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..7dab082 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +python_files = tests/*.py diff --git a/requirements.txt b/requirements.txt index 210396b..713b100 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +black==23.7.0 grpcio==1.56.2 grpcio-tools==1.56.2 cloudquery-plugin-pb==0.0.14 diff --git a/setup.py b/setup.py index c51c459..d507eec 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ ] setuptools.setup( name=name, - version="0.0.5", + version="0.0.6", description=description, long_description=long_description, author="CloudQuery LTD",