Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pipenv
run: pip install pipenv==2024.4.1

- name: Install dependencies
run: pipenv install --skip-lock -d
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Run acceptance minimal
run: pipenv run test
- name: Run acceptance minimal
run: uv run pytest tests/acceptance/minimal --capture=sys
45 changes: 18 additions & 27 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,26 @@ jobs:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Build a binary wheel and a source tarball
run: uv build --sdist --wheel --outdir dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
32 changes: 15 additions & 17 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ jobs:
python-version: ["3.13"]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pipenv
run: pip install pipenv==2024.4.1

- name: Install dependencies
run: pipenv install --skip-lock -d
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Check isort
run: pipenv run isort . --check-only --diff --quiet
run: uv run isort . --check-only --diff --quiet

- name: Check flake8
run: pipenv run lint
run: uv run flake8 .
unittest:
# ubuntu-24.04 later does not support Python 3.7
runs-on: ubuntu-22.04
Expand All @@ -34,18 +33,17 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pipenv
run: pip install pipenv==2024.4.1

- name: Install dependencies
run: pipenv install --skip-lock -d
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Run UnitTest
run: pipenv run unittest
run: uv run pytest tests/unit --capture=sys
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
/docs/source/reference/services/
__pycache__/
*.pyc
/.coverage
/.coverage.*
/htmlcov/
/.mypy_cache/
/.ruff_cache/
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Pre-commit hooks configuration
# Install with: pre-commit install
# Run manually with: pre-commit run --all-files

repos:
# Code formatting with ruff (combines flake8, isort, black)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
hooks:
- id: ruff
name: Ruff linter
args: ["--fix"]
- id: ruff-format
name: Ruff formatter

# Trailing whitespace and line ending fixes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=1000"]
- id: detect-private-key

# Type checking with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.0
hooks:
- id: mypy
args: ["--ignore-missing-imports", "--no-error-summary"]
exclude: ^(tests/|docs/)
additional_dependencies: []

ci:
autofix_commit_msg: "chore: auto fixes from pre-commit hooks"
autofix_prs: true
autoupdate_branch: ""
autoupdate_commit_msg: "chore: pre-commit autoupdate"
autoupdate_schedule: weekly
skip: []
submodules: false
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.13.2
FROM python:3.13-slim
WORKDIR /usr/local/app
RUN apt-get update && apt-get install -y groff-base
ADD Pipfile /usr/local/app
RUN pip install pipenv==2024.4.1 && pipenv install --skip-lock -d
ENTRYPOINT ["pipenv", "run"]
RUN pip install uv
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen
ENTRYPOINT ["uv", "run"]
21 changes: 0 additions & 21 deletions Pipfile

This file was deleted.

90 changes: 75 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,44 @@ It works by feeding AWS-SDK-compatible model JSONs to botocore module.

## Features

* :heavy_check_mark: Full support for NIFCLOUD Computing / RDB / NAS / ESS / DNS / ObjectStorageService / ServiceActivity / DevOps with GitLab APIs
* :heavy_check_mark: The nifcloud package is the foundation for the [NIFCLOUD CLI](https://github.com/nifcloud/nifcloud-cli).
* :heavy_check_mark: AWS-SDK-compatible data-driven architecture
- :heavy_check_mark: Full support for NIFCLOUD Computing / RDB / NAS / ESS / DNS / ObjectStorageService / ServiceActivity / DevOps with GitLab APIs
- :heavy_check_mark: The nifcloud package is the foundation for the [NIFCLOUD CLI](https://github.com/nifcloud/nifcloud-cli).
- :heavy_check_mark: AWS-SDK-compatible data-driven architecture
- :heavy_check_mark: Type hints and comprehensive documentation
- :heavy_check_mark: Modern Python development tools (uv, ruff, pytest)

## Requirements

- Python 3.8 or later

## How to Install
## Installation

```
### Using pip

```bash
pip install nifcloud
```

## Usage
### Development Setup with uv

For development, install dependencies using [uv](https://docs.astral.sh/uv/):

```bash
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone and setup
git clone https://github.com/nifcloud/nifcloud-sdk-python.git
cd nifcloud-sdk-python

# Sync dependencies
uv sync

# Install pre-commit hooks
pre-commit install
```

## Quick Start

Write your python program:

Expand All @@ -42,11 +65,13 @@ print(client.describe_instances())

Execute the program:

```bash
python test.py
```
$ python test.py
```

Credentials and region name can be also passed via environment variables.
### Environment Variables

Credentials and region name can be passed via environment variables:

```python
from nifcloud import session
Expand All @@ -55,15 +80,50 @@ client = session.get_session().create_client("computing")
print(client.describe_instances())
```

```bash
export NIFCLOUD_ACCESS_KEY_ID=<Your NIFCLOUD Access Key ID>
export NIFCLOUD_SECRET_ACCESS_KEY=<Your NIFCLOUD Secret Access Key>
export NIFCLOUD_DEFAULT_REGION=jp-east-1
python test.py
```

## Development

### Running Tests

```bash
# Run unit tests with uv
uv run pytest tests/unit

# Run with coverage report
uv run pytest tests/unit --cov=nifcloud --cov-report=term-missing

# Run acceptance tests (requires NIFCLOUD credentials)
uv run pytest tests/acceptance/minimal
```
$ export NIFCLOUD_ACCESS_KEY_ID=<Your NIFCLOUD Access Key ID>
$ export NIFCLOUD_SECRET_ACCESS_KEY=<Your NIFCLOUD Secret Access Key>
$ export NIFCLOUD_DEFAULT_REGION=jp-east-1
$ python test.py

### Code Quality

```bash
# Run linter (ruff)
uv run ruff check nifcloud/

# Format code
uv run ruff format nifcloud/

# Type checking
uv run mypy nifcloud/

# Run pre-commit hooks
pre-commit run --all-files
```

See [documentation](https://nifcloud-sdk-python.readthedocs.io/en/latest/) for detail.
## Documentation

See [official documentation](https://nifcloud-sdk-python.readthedocs.io/en/latest/) for detailed API reference and examples.

## License

See [LICENSE.txt](LICENSE.txt).
Apache License 2.0

See [LICENSE.txt](LICENSE.txt) for details.
1 change: 0 additions & 1 deletion docker-compose.yml → compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
app:
build: .
Expand Down
Loading
Loading