Skip to content
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

Add pre-commit config and run in CI #177

Merged
merged 10 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ updates:
interval: "weekly"
labels:
- "maintenance"

- package-ecosystem: "pip" # See documentation for possible values
directory: "/ansys-grantami-serverapi-openapi/" # Location of package manifests
schedule:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/generate_library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
token: ${{ steps.get_workflow_token.outputs.token }}
ref: ${{ github.event.pull_request.head.ref }}

- name: "Set up JDK 11"
uses: actions/setup-java@v4
with:
Expand Down Expand Up @@ -58,11 +58,10 @@ jobs:
poetry lock --no-update
working-directory: ansys-grantami-serverapi-openapi

- name: "Install and run black"
- name: "Install and run pre-commit"
run: |
pip install black
black ./src ./tests
working-directory: ansys-grantami-serverapi-openapi
pip install pre-commit
! pre-commit run --all-files

- name: "Commit changes to library code"
uses: EndBug/add-and-commit@v9
Expand Down
6 changes: 6 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[settings]
profile=black
force_sort_within_sections=true
line_length=100
default_section=THIRDPARTY
src_paths=src,tests
2 changes: 1 addition & 1 deletion .m2/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</pluginRepositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
Expand Down
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
files: '^ansys-grantami-serverapi-openapi/(src|tests)'
args:
- '--line-length=100'

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
files: '^ansys-grantami-serverapi-openapi/(src|tests)'

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: debug-statements
- id: check-merge-conflict
- id: trailing-whitespace

- repo: https://github.com/ansys/pre-commit-hooks
rev: v0.2.8
hooks:
- id: add-license-headers
args:
- --start_year=2023
files: 'ansys-grantami-serverapi-openapi/(src|tests)/.*\.(py)'
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ Once the tag is pushed to GitHub, a workflow will build and publish the release.
As stated above, direct use of this package is unsupported. The recommended approach is to use the idiomatic
libraries written for specific API areas.

We do understand that internal or external users might want to experiment with Granta MI Server API functionality that
We do understand that internal or external users might want to experiment with Granta MI Server API functionality that
is not exposed via an idiomatic python library. To that extent, the following sections demonstrate how to install and
get started with the library.

### Requirements
The `ansys-grantami-serverapi-openapi` package requires Granta MI. The following table details compatibility between
The `ansys-grantami-serverapi-openapi` package requires Granta MI. The following table details compatibility between
Granta MI releases and versions of the Python package.

| Granta MI | ansys-grantami-serverapi-openapi |
Expand All @@ -69,8 +69,8 @@ Granta MI releases and versions of the Python package.

### Installation

During active development phases of Granta MI, this repository is kept up to date with new versions of the API
documentation. To use the most up-to-date version of this package in another project, add a dependency on the
During active development phases of Granta MI, this repository is kept up to date with new versions of the API
documentation. To use the most up-to-date version of this package in another project, add a dependency on the
repository's main branch, e.g. with poetry:

```console
Expand All @@ -84,7 +84,7 @@ Or with pip:
```

### Minimal setup
The following code snippet demonstrates how to perform the minimal setup required to interact with the API using this
The following code snippet demonstrates how to perform the minimal setup required to interact with the API using this
library.

```python
Expand Down Expand Up @@ -130,11 +130,11 @@ class Connection(ApiClientFactory):

if __name__ == '__main__':
from ansys.grantami.serverapi_openapi import api

# Update URL and connection method for your system
URL = "http://my_server_name/mi_servicelayer"
api_client = Connection(api_url=URL).with_autologon().connect()

schema_api = api.SchemaApi(api_client)
server_version = schema_api.v1alpha_schema_mi_version_get()
print(server_version.version)
Expand Down
2 changes: 1 addition & 1 deletion ansys-grantami-serverapi-openapi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "ansys-grantami-serverapi-openapi"
description = "Autogenerated client library for the Granta MI Server API."
version = "3.0.0.dev234"
version = "3.0.0.dev236"
license = "MIT"
authors = ["ANSYS, Inc. <pyansys.core@ansys.com>"]
maintainers = ["ANSYS, Inc. <pyansys.core@ansys.com>"]
Expand Down
Loading