-
Notifications
You must be signed in to change notification settings - Fork 1
Core: Added base code and tests #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
8 commits
Select commit
Hold shift + click to select a range
5a2c8da
Core: Added base code and tests
Seluj78 c5a5c08
CI/CD: Added config for pep8speaks
Seluj78 0c59ac1
Chore: Updated code for typing with mypy strict
Seluj78 44efbbd
CI/CD: Added workflow to create GH release on merge
Seluj78 ae055f1
Core: Added token refreshing
Seluj78 5ba3906
CI/CD: Added tox for multi-version checks
Seluj78 158e910
Tests: Removed useless comment
Seluj78 ad99a1a
Core: Updated exceptions
Seluj78 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,32 @@ | ||
| name: Build package | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| artifact-name: | ||
| description: "Name of an artifact" | ||
| type: "string" | ||
| required: false | ||
| default: "package" | ||
|
|
||
| jobs: | ||
| build-pkg: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.x' | ||
|
|
||
| - name: Install dependencies | ||
| run: pip install -U build twine | ||
| - name: Build 📦 package | ||
| run: python -m build | ||
| - name: Check 📦 package | ||
| run: twine check dist/* | ||
|
|
||
| - uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: ${{ inputs.artifact-name }} | ||
| path: dist |
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,36 @@ | ||
| name: Deploy | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| set_version: | ||
| name: Set the version of the release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set version | ||
| id: set_version | ||
| run: | | ||
| echo version=$( sed -e 's/__version__ = "\(.*\)"/\1/g' <<< $(grep -E '__version__ = ' shellhub/__init__.py)) >> "$GITHUB_OUTPUT" | ||
| outputs: | ||
| version: ${{ steps.set_version.outputs.version }} | ||
|
|
||
| gh-release: | ||
| name: Create a release in GitHub | ||
| needs: | ||
| - set_version | ||
| runs-on: ubuntu-latest | ||
| if: test -z "${{ needs.set_version.outputs.version }}" | ||
| steps: | ||
| - name: Create Release | ||
| id: create_release | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| draft: false | ||
| prerelease: false | ||
| tag_name: v${{ needs.set_version.outputs.version }} | ||
| generate_release_notes: 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,55 @@ | ||
| name: Tests | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| merge_group: | ||
|
|
||
| jobs: | ||
|
|
||
| build: | ||
| uses: "./.github/workflows/build_pkg.yml" | ||
| with: | ||
| artifact-name: package | ||
|
|
||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| name: test (Python ${{ matrix.python-version }} on ${{ matrix.os-label }}) | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # keep it sync with tox.ini [gh-actions] section | ||
| python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"] | ||
| os: ["ubuntu-latest"] | ||
| os-label: ["Ubuntu"] | ||
| include: | ||
| - {python-version: "3.8", os: "windows-latest", os-label: "Windows"} | ||
| - {python-version: "3.8", os: "macos-latest", os-label: "macOS"} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: "${{ matrix.python-version }}" | ||
| - name: Install tox | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install tox tox-gh-actions | ||
| - name: Run tests | ||
| run: tox | ||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v3 | ||
| env: | ||
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
|
||
| test_success: | ||
| # this aggregates success state of all jobs listed in `needs` | ||
| # this is the only required check to pass CI | ||
| name: "Test success" | ||
| runs-on: ubuntu-latest | ||
| needs: [test] | ||
| steps: | ||
| - name: "Noop" | ||
| run: true | ||
| shell: bash |
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,4 @@ | ||
| pycodestyle: # Same as scanner.linter value. Other option is flake8 | ||
| max-line-length: 120 # Default is 79 in PEP 8 | ||
|
|
||
| no_blank_comment: True # If True, no comment is made on PR without any errors. |
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
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
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,8 @@ | ||
| comment: | ||
| after_n_builds: 4 | ||
|
|
||
| codecov: | ||
| disable_default_path_fixes: true # Automatic detection does not discover all files | ||
|
|
||
| fixes: | ||
| - "::shellhub/" |
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
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 |
|---|---|---|
| @@ -1,5 +1,16 @@ | ||
| black | ||
| reorder-python-imports | ||
| flake8 | ||
| mypy | ||
| types-requests | ||
| pre-commit | ||
| -r requirements.txt | ||
|
|
||
| pytest | ||
| requests-mock | ||
| pytest-cov | ||
| tox | ||
| build | ||
| setuptools | ||
| wheel | ||
| twine |
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 |
|---|---|---|
| @@ -1,12 +1,22 @@ | ||
| # Increment versions here according to SemVer | ||
| __version__ = "0.0.1" | ||
|
|
||
| # Import here what you want to be able to import from this package and place it in __all__ | ||
| from shellhub.models.device import ShellHubDevice, ShellHubDeviceInfo | ||
| from shellhub.models.base import ShellHub | ||
| from .models.device import ShellHubDevice, ShellHubDeviceInfo | ||
| from .models.base import ShellHub | ||
| from .exceptions import ( | ||
| ShellHubApiError, | ||
| ShellHubAuthenticationError, | ||
| DeviceNotFoundError, | ||
| ShellHubBaseException, | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "ShellHub", | ||
| "ShellHubDevice", | ||
| "ShellHubDeviceInfo", | ||
| "ShellHubApiError", | ||
| "ShellHubAuthenticationError", | ||
| "DeviceNotFoundError", | ||
| "ShellHubBaseException", | ||
| ] |
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,14 @@ | ||
| class ShellHubBaseException(Exception): | ||
| pass | ||
|
|
||
|
|
||
| class ShellHubApiError(ShellHubBaseException): | ||
| pass | ||
|
|
||
|
|
||
| class ShellHubAuthenticationError(ShellHubBaseException): | ||
| pass | ||
|
|
||
|
|
||
| class DeviceNotFoundError(ShellHubApiError): | ||
| pass |
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.