Skip to content

Commit

Permalink
chore: improve GitHub integration, add CI config, code QL (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored and AndyBryson committed Mar 18, 2024
1 parent fbd036b commit 163cee8
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 18 deletions.
128 changes: 128 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
version: 2.1

commands:
client-test:
description: "Run tests"
parameters:
python-image:
type: string
steps:
- restore_cache:
name: Restoring Pip Cache
keys:
- &cache-key pip-cache-v11-<< parameters.python-image >>-{{ checksum "setup.py" }}
- pip-cache-v11-<< parameters.python-image >>-
- run:
name: "Running tests"
command: |
python --version
mkdir test-reports || true
pip install . --user
pip install .\[dataframe\] --user
pip install pytest pytest-cov --user
pytest tests --junitxml=test-reports/junit.xml --cov=./ --cov-report xml:coverage.xml
- save_cache:
name: Saving Pip Cache
key: *cache-key
paths:
- ".venv"
- "~/.cache/pip"
- "/usr/local/lib/site-python"
when: always
jobs:
tests-python:
parameters:
python-image:
type: string
default: &default-python "cimg/python:3.7"
docker:
- image: << parameters.python-image >>
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- client-test:
python-image: << parameters.python-image >>
- store_test_results:
path: test-reports
- run:
name: Collecting coverage reports
command: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
curl -s https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod +x ./codecov
./codecov
check-code-style:
docker:
- image: *default-python
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run:
name: Checks style consistency across sources.
command: |
pip install flake8 --user
flake8 influxdb_client_3/
check-twine:
docker:
- image: *default-python
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run:
name: Checks that the description will render correctly on PyPI.
command: |
pip install --upgrade pip
pip install twine --user
python setup.py sdist bdist_wheel
twine check dist/*
check-docstyle:
docker:
- image: *default-python
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run:
name: Checks compliance with Python docstring convention.
command: |
pip install pydocstyle --user
pydocstyle --count influxdb_client_3
workflows:
version: 2
build:
when:
not:
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
jobs:
# - check-code-style
# - check-docstyle
- check-twine
- tests-python:
name: test-3.8
python-image: "cimg/python:3.8"
- tests-python:
name: test-3.9
python-image: "cimg/python:3.9"
- tests-python:
name: test-3.10
python-image: "cimg/python:3.10"
- tests-python:
name: test-3.11
python-image: "cimg/python:3.11"
- tests-python:
name: test-3.12
python-image: "cimg/python:3.12"

nightly:
when:
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
jobs:
- tests-python
54 changes: 54 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Bug Report
description: Create a bug report to help us improve
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking time to fill out this bug report! We reserve this repository issues for bugs with reproducible problems.
Please redirect any questions about the client usage to our [Community Slack](https://app.slack.com/huddle/TH8RGQX5Z/C02UDUPLQKA) or [Community Page](https://community.influxdata.com/) we have a lot of talented community members there who could help answer your question more quickly.
* Please add a :+1: or comment on a similar existing bug report instead of opening a new one.
* Please check whether the bug can be reproduced with the latest release.
- type: textarea
id: specifications
attributes:
label: Specifications
description: Describe the steps to reproduce the bug.
value: |
* Client Version:
* InfluxDB Version:
* Platform:
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Code sample to reproduce problem
description: Provide a code sample that reproduces the problem
value: |
```python
```
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: Describe what you expected to happen when you performed the above steps.
validations:
required: true
- type: textarea
id: actual-behavior
attributes:
label: Actual behavior
description: Describe what actually happened when you performed the above steps.
validations:
required: true
- type: textarea
id: additional-info
attributes:
label: Additional info
description: Include gist of relevant config, logs, etc.
validations:
required: false
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Feature request
description: Create a feature request to make client more awesome
labels: ["feature request"]
body:
- type: markdown
attributes:
value: |
Thanks for taking time to share with us this feature request! Please describe why you would like this feature to be added to the client, how you plan to use it to make your life better.
- type: textarea
id: use-case
attributes:
label: Use Case
description: Describe how you plan to use this feature.
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: Describe what you expected to happen when you performed the above steps.
validations:
required: true
- type: textarea
id: actual-behavior
attributes:
label: Actual behavior
description: Describe what actually happened when you performed the above steps.
validations:
required: true
- type: textarea
id: additional-info
attributes:
label: Additional info
description: Include gist of relevant config, logs, etc.
validations:
required: false

17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/SUPPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Support request
description: Open a support request
labels: ["support"]
body:
- type: markdown
attributes:
value: |
WOAHH, hold up. This isn't the best place for support questions.
You can get a faster response on slack or forums:
Please redirect any QUESTIONS about Client usage to
- InfluxData Slack Channel: https://app.slack.com/huddle/TH8RGQX5Z/C02UDUPLQKA
- InfluxData Community Site: https://community.influxdata.com
- type: textarea
attributes:
label: "Please direct all support questions to slack or the forums. Thank you."
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Closes #

## Proposed Changes

_Briefly describe your proposed changes:_

## Checklist

<!-- Checkboxes below this note can be erased if not applicable to your Pull Request. -->

- [ ] CHANGELOG.md updated
- [ ] Rebased/mergeable
- [ ] A test has been added if appropriate
- [ ] Tests pass
- [ ] Commit messages are [conventional](https://www.conventionalcommits.org/en/v1.0.0/)
- [ ] Sign [CLA](https://www.influxdata.com/legal/cla/) (if not already signed)
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
31 changes: 31 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
CodeQL-Build:
runs-on: ubuntu-latest

permissions:
security-events: write
actions: read
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
14 changes: 14 additions & 0 deletions .github/workflows/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: "Semantic PR and Commit Messages"

on:
pull_request:
types: [opened, reopened, synchronize, edited]
branches:
- main

jobs:
semantic:
uses: influxdata/validate-semantic-github-messages/.github/workflows/semantic.yml@main
with:
CHECK_PR_TITLE_OR_ONE_COMMIT: true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ dist
build
pyinflux3*.egg-info
.DS_store
__pycache__
__pycache__
.idea
*.egg-info/
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
<a href="https://pypi.org/project/influxdb3-python/">
<img src="https://img.shields.io/pypi/dm/influxdb3-python.svg" alt="PyPI downloads">
</a>
<a href="https://github.com/InfluxCommunity/influxdb3-python/actions/workflows/pylint.yml">
<img src="https://github.com/InfluxCommunity/influxdb3-python/actions/workflows/pylint.yml/badge.svg" alt="Lint Code Base">
<a href="https://github.com/InfluxCommunity/influxdb3-python/actions/workflows/codeql-analysis.yml">
<img src="https://github.com/InfluxCommunity/influxdb3-python/actions/workflows/codeql-analysis.yml/badge.svg?branch=main" alt="CodeQL analysis">
</a>
<a href="https://github.com/InfluxCommunity/influxdb3-python/actions/workflows/python-publish.yml">
<img src="https://github.com/InfluxCommunity/influxdb3-python/actions/workflows/python-publish.yml/badge.svg" alt="Lint Code Base">
<a href="https://dl.circleci.com/status-badge/redirect/gh/InfluxCommunity/influxdb3-python/tree/main">
<img src="https://dl.circleci.com/status-badge/img/gh/InfluxCommunity/influxdb3-python/tree/main.svg?style=svg" alt="CircleCI">
</a>
<a href="https://codecov.io/gh/InfluxCommunity/influxdb3-python">
<img src="https://codecov.io/gh/InfluxCommunity/influxdb3-python/branch/main/graph/badge.svg" alt="Code Cov"/>
</a>
<a href="https://influxcommunity.slack.com">
<img src="https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social" alt="Community Slack">
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ def get_version():
packages=find_packages(exclude=['tests', 'tests.*', 'examples', 'examples.*']),
extras_require={'pandas': ['pandas'], 'polars': ['polars'], 'dataframe': ['pandas', 'polars']},
install_requires=requires,
python_requires='>=3.7',
python_requires='>=3.8',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
]
)
)
11 changes: 1 addition & 10 deletions tests/test_influxdb_client_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,5 @@ def test_init(self):
self.assertEqual(self.client._write_api, self.mock_write_api.return_value)
self.assertEqual(self.client._flight_client, self.mock_flight_client.return_value)

@patch('influxdb_client_3._WriteApi.write')
def test_write(self, mock_write):
record = "test_record"
self.client.write(record=record)
mock_write.assert_called_once_with(bucket=self.client._database, record=record)

# Add more tests for other methods


if __name__ == '__main__':
unittest.main()
unittest.main()

0 comments on commit 163cee8

Please sign in to comment.