-
Notifications
You must be signed in to change notification settings - Fork 4
feat: diode-sdk-python #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
da0f982
add .gitignore
mfiedorowicz 9c632f5
add CODEOWNERS
mfiedorowicz 2d4746f
.github: pull request labeler
mfiedorowicz dd12528
.github: lint and test workflow
mfiedorowicz e012eab
.github: release workflow
mfiedorowicz f4db359
LICENSE adjustments
mfiedorowicz 06e3d56
README and supported entities documentation
mfiedorowicz 16e46be
add pyproject.toml
mfiedorowicz df71c4a
migrate diode-sdk-python
mfiedorowicz f20bb5b
migrate tests
mfiedorowicz caa34e2
.github: update ruff command
mfiedorowicz 5a3a713
pyproject: exclude tests and proto generated code from coverage
mfiedorowicz 54a829b
fix: .github - set correct tag format for releaserc
mfiedorowicz 1d78202
fix: .github - tidy up release-version
mfiedorowicz b32417d
fix: client type hints
mfiedorowicz 6239191
fix: .github - code coverage
mfiedorowicz e9974f0
fix: .github - code coverage - omit generated code
mfiedorowicz 4974992
fix: .github - add concurrency, timeouts and python 3.10 to the matrix
mfiedorowicz 700e430
fix: README - tidy up development notes
mfiedorowicz fd4e25e
fix: pyproject - min python 3.10, classifiers adjustment
mfiedorowicz 9e4cf43
fix: README - document target requirement to not contain scheme
mfiedorowicz 4cde87f
fix: client - tidy up docstrings, naming + PEP 604
mfiedorowicz e4002d6
fix: ingester - PEP 604
mfiedorowicz bef8de9
fix: README - typo
mfiedorowicz 68b370e
refactor diode client target with grpc:// and grpcs://, removed redun…
mfiedorowicz 914bbff
tidy up
mfiedorowicz b459af8
README tidy up
mfiedorowicz 4fad1e4
README tidy up (indentation)
mfiedorowicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| * @mfiedorowicz @natm |
This file contains hidden or 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,54 @@ | ||
| documentation: | ||
| - changed-files: | ||
| - any-glob-to-any-file: | ||
| - '**/docs/**/*' | ||
|
|
||
| github-actions: | ||
| - changed-files: | ||
| - any-glob-to-any-file: | ||
| - '**/.github/workflows/*' | ||
| - '**/.github/workflows/**/*' | ||
| - '**/.github/dependabot.yaml' | ||
| - '**/.github/pull_request_labeler.yaml' | ||
|
|
||
| github-templates: | ||
| - changed-files: | ||
| - any-glob-to-any-file: | ||
| - '**/.github/ISSUE_TEMPLATE/*' | ||
| - '**/.github/PULL_REQUEST_TEMPLATE.md' | ||
| - '**/.github/.chglog/*' | ||
| - '**/.github/.chglog/**/*' | ||
|
|
||
| internal: | ||
| - changed-files: | ||
| - any-glob-to-any-file: | ||
| - '**/.flake8' | ||
| - '**/.bandit.baseline' | ||
| - '**/.gitignore' | ||
| - '**/.pre-commit-config.yaml' | ||
| - '**/MANIFEST.in' | ||
| - '**/Makefile' | ||
| - '**/CONTRIBUTING.md' | ||
| - '**/MAINTAINERS.md' | ||
| - '**/CODE_OF_CONDUCT.md' | ||
| - '**/LICENSE' | ||
| - '**/LICENSE.txt' | ||
| - '**/THIRD-PARTY-LICENSES' | ||
| - '**/.dockerignore' | ||
| - '**/.editorconfig' | ||
| - '**/setup.cfg' | ||
|
|
||
| dependencies: | ||
| - changed-files: | ||
| - any-glob-to-any-file: | ||
| - '**/pyproject.toml' | ||
| - '**/poetry.lock' | ||
| - '**/requirements.txt' | ||
|
|
||
| markdown: | ||
| - changed-files: | ||
| - any-glob-to-any-file: '**/*.md' | ||
|
|
||
| python: | ||
| - changed-files: | ||
| - any-glob-to-any-file: '**/*.py' |
This file contains hidden or 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,20 @@ | ||
| name: PR labeler | ||
| on: | ||
| - pull_request_target | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| triage: | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/labeler@v5 | ||
| with: | ||
| configuration-path: '.github/pull_request_labeler.yaml' |
This file contains hidden or 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,49 @@ | ||
| name: Lint and tests | ||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - "!release" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| tests: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| strategy: | ||
| matrix: | ||
| python: [ "3.10", "3.11" ] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install . | ||
| pip install .[dev] | ||
| pip install .[test] | ||
|
|
||
| - name: Run tests with coverage | ||
| run: | | ||
| set -o pipefail | ||
| pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=netboxlabs.diode.sdk tests/ | tee pytest-coverage.txt | ||
|
|
||
| - name: Pytest coverage comment | ||
| uses: MishaKav/pytest-coverage-comment@main | ||
| with: | ||
| pytest-coverage-path: ./pytest-coverage.txt | ||
| junitxml-path: ./pytest.xml | ||
|
|
||
| - name: Lint with Ruff | ||
| run: | | ||
| ruff check --output-format=github netboxlabs/ tests/ | ||
| continue-on-error: true | ||
This file contains hidden or 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,170 @@ | ||
| name: Release | ||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [ release ] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| GH_TOKEN: ${{ secrets.ORB_CI_GH_TOKEN }} | ||
| SEMANTIC_RELEASE_PACKAGE: ${{ github.repository }} | ||
| PYTHON_RUNTIME_VERSION: "3.11" | ||
| APP_NAME: diode-sdk-python | ||
| PYTHON_PACKAGE_NAME: netboxlabs-diode-sdk | ||
|
|
||
| jobs: | ||
| get-next-version: | ||
| name: Semantic release get next version | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "lts/*" | ||
| - name: Write package.json | ||
| uses: DamianReeves/write-file-action@master | ||
| with: | ||
| path: ./package.json | ||
| write-mode: overwrite | ||
| contents: | | ||
| { | ||
| "name": "${{ env.APP_NAME }}", | ||
| "version": "1.0.0", | ||
| "devDependencies": { | ||
| "semantic-release-export-data": "^1.0.1", | ||
| "@semantic-release/changelog": "^6.0.3" | ||
| } | ||
| } | ||
| - name: Write .releaserc.json | ||
| uses: DamianReeves/write-file-action@master | ||
| with: | ||
| path: ./.releaserc.json | ||
| write-mode: overwrite | ||
| contents: | | ||
| { | ||
| "branches": "release", | ||
| "repositoryUrl": "https://github.com/netboxlabs/diode-sdk-python", | ||
| "debug": "true", | ||
| "tagFormat": "v${version}", | ||
| "plugins": [ | ||
| ["semantic-release-export-data"], | ||
| ["@semantic-release/commit-analyzer", { | ||
| "releaseRules": [ | ||
| { "message": "*", "release": "patch"}, | ||
| { "message": "fix*", "release": "patch" }, | ||
| { "message": "feat*", "release": "minor" }, | ||
| { "message": "perf*", "release": "major" } | ||
| ] | ||
| }], | ||
| "@semantic-release/release-notes-generator", | ||
| [ | ||
| "@semantic-release/changelog", | ||
| { | ||
| "changelogFile": "CHANGELOG.md", | ||
| "changelogTitle": "# Semantic Versioning Changelog" | ||
| } | ||
| ], | ||
| [ | ||
| "@semantic-release/github", | ||
| { | ||
| "assets": [ | ||
| { | ||
| "path": "release/**" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| - name: setup semantic-release | ||
| run: npm i | ||
| - name: release dry-run | ||
| env: | ||
| SLACK_WEBHOOK: ${{ secrets.SLACK_SEMANTIC_RELEASE_WEBHOOK }} | ||
| run: npx semantic-release --debug --dry-run | ||
| id: get-next-version | ||
| - name: Set short sha output | ||
| id: short-sha | ||
| run: echo "::set-output name=short-sha::${GITHUB_SHA::7}" | ||
| - name: Set release version | ||
| id: release-version | ||
| run: | | ||
| echo "::set-output name=release-version::`echo ${{ steps.get-next-version.outputs.new-release-version }} | sed 's/v//g'`" | ||
| outputs: | ||
| new-release-published: ${{ steps.get-next-version.outputs.new-release-published }} | ||
| new-release-version: ${{ steps.release-version.outputs.release-version }} | ||
| short-sha: ${{ steps.short-sha.outputs.short-sha }} | ||
|
|
||
| confirm-version: | ||
| name: Next version ${{ needs.get-next-version.outputs.new-release-version }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| needs: get-next-version | ||
| if: needs.get-next-version.outputs.new-release-published == 'true' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - run: echo "The new release version is ${{ needs.get-next-version.outputs.new-release-version }} commit ${{ needs.get-next-version.outputs.short-sha }}" | ||
|
|
||
| build: | ||
| name: Build | ||
| needs: [ get-next-version ] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| env: | ||
| BUILD_VERSION: ${{ needs.get-next-version.outputs.new-release-version }} | ||
| BUILD_TRACK: release | ||
| BUILD_COMMIT: ${{ needs.get-next-version.outputs.short-sha }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ env.PYTHON_RUNTIME_VERSION }} | ||
| - name: Insert version variables into Python | ||
| run: | | ||
| sed -i "s/__commit_hash__ = .*/__commit_hash__ = \"${BUILD_COMMIT}\"/" netboxlabs/diode/sdk/version.py | ||
| sed -i "s/__track__ = .*/__track__ = \"${BUILD_TRACK}\"/" netboxlabs/diode/sdk/version.py | ||
| sed -i "s/__version__ = .*/__version__ = \"${BUILD_VERSION}\"/" netboxlabs/diode/sdk/version.py | ||
| - name: Display contents of version.py | ||
| run: cat netboxlabs/diode/sdk/version.py | ||
| - name: Build sdist package | ||
| run: | | ||
| pip install toml-cli | ||
| toml set --toml-path pyproject.toml project.version ${{ env.BUILD_VERSION }} | ||
| cat pyproject.toml | grep version | ||
| python3 -m pip install --upgrade build | ||
| python3 -m build --sdist --outdir dist/ | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ env.PYTHON_PACKAGE_NAME }}-${{ env.BUILD_VERSION }}.tar.gz | ||
| path: ./dist/${{ env.PYTHON_PACKAGE_NAME }}-${{ env.BUILD_VERSION }}.tar.gz | ||
| retention-days: 30 | ||
| if-no-files-found: error | ||
| - name: Publish release distributions to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| packages-dir: ./dist | ||
|
|
||
| semantic-release: | ||
| name: Semantic release | ||
| needs: [ build ] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "21.4.0" | ||
| - name: setup semantic-release | ||
| run: npm i | ||
| - name: Release | ||
| env: | ||
| SLACK_WEBHOOK: ${{ secrets.SLACK_OBSERVABILITY_RELEASE_WEBHOOK }} | ||
| run: npx semantic-release --debug |
This file contains hidden or 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,27 @@ | ||
| # IntelliJ | ||
| .idea/ | ||
|
|
||
| # VS Code | ||
| .vscode | ||
|
|
||
| # Environments | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| .Python | ||
| build/ | ||
| dist/ | ||
| .eggs/ | ||
| *.egg-info |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.