Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/advanced-prechecks-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
if: ${{ github.event.label.name == 'ci' }}
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
name: Ubuntu prechecks - Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5

- uses: actions/setup-python@v3
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand All @@ -42,15 +42,15 @@ jobs:
if: ${{ github.event.label.name == 'ci' }}
strategy:
matrix:
python-version: [ '3.6', '3.8', '3.9', '3.10' ]
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEPLOYMENT_REGION }}

name: RHEL8 prechecks - Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5

- name: Install packer
uses: hashicorp-contrib/setup-packer@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v5

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/default-prechecks-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: "3.10"
architecture: x64

- name: Install pipenv
Expand Down
34 changes: 10 additions & 24 deletions .github/workflows/pypi-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,22 @@ jobs:
working-directory: unix

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- uses: actions/setup-python@v6
with:
python-version: "3.10"
architecture: x64

- name: Autobump version
run: |
# from refs/tags/v1.2.3 get 1.2.3
VERSION=${GITHUB_REF/refs\/tags\//}
PLACEHOLDER='__version__ = "v0.1.0"'
VERSION_FILE='src/machine_stats/_version.py'

# grep ensures the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$PLACEHOLDER" "$VERSION_FILE"

sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/g" "$VERSION_FILE"

- name: Install pypa/build and twine
run: |
python -m pip install build twine
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/ .
- name: Install the project
run: uv build

- name: Upload to PyPI via Twine
- name: Publish
env:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload --verbose -u '__token__' dist/*
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: uv publish
27 changes: 14 additions & 13 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
steps:
- uses: actions/checkout@v5

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd ./unix
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
- name: Test with pytest
run: |
pytest
enable-cache: true

- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Run tests
# For example, using `pytest`
run: uv run pytest tests
2 changes: 2 additions & 0 deletions unix/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ hosts
build/
dist/
machine_stats.egg-info
.devenv/
.direnv/
39 changes: 13 additions & 26 deletions unix/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,27 @@ Under the hood Machine Stats relies on the awesome [Ansible SDK](https://docs.an

## Technicalities

Development on the latest version of Python is preferred. As of this writing
it's 3.9. You can use any operating system.
Development on the latest version of Python is preferred. As of this
writing it's 3.14. You can use any operating system. We use the
wonder [uv tool](https://docs.astral.sh/uv/) for a modern take on
python package management. If you don't have it installed follow the
appropriate instructions for your OS/package manager of choice.

Install all development dependencies using:

```console
pipenv install --dev
```

If you haven't used `pipenv` before but are comfortable with virtualenvs, just
run `pip install pipenv` in the virtualenv you're already using and invoke the
command above from the `unix` directory of the cloned _Machine Stats_ repo. It
will do the correct thing.

Make changes in the source code (e.g in `src/machine_stats/__init__.py`) and
run `pipenv run machine_stats` to run it locally.

Non `pipenv` install works too:

```console
pip install -r requirements.txt
pip install -r dev-requirements.txt
pip install -e .
uv sync
```

### Tools

We use the following tools:

* `black` for code formatting (`pipenv run black .`)
* `isort` to sort imports (`pipenv run isort .`)
* `flake8` or `pylint` for code linting (`pipenv run flake8
src/machine_stats/*` or `pipenv run pylint src`)
* `bump2version` for version bumps (`pipenv run bump2version`)
* uv for modern python project management
* `black` for code formatting (`uv run black .`)
* `isort` to sort imports (`uv run isort .`)
* `flake8` or `pylint` for code linting (`uv run flake8
src/machine_stats/*` or `uv run pylint src`)

### Testing

Expand All @@ -56,7 +43,7 @@ pytest
or

```console
pipenv run pytest
uv run pytest
```

### How to release a new Machine Stats version
Expand All @@ -75,7 +62,7 @@ To deploy a new version of Machine Stats, you will need to create a release. The

When you create a PR, the GitHub workflows check for the linting and CodeQL. However, if you think you're introducing breaking changes, then please add the label `ci` with your PR. This will run the Advanced Prechecks workflow that checks Machine Stats' working in the following system environments:

* Ubuntu 20.04 - Python 3.7 to 3.10
* Ubuntu 24.04 - Python 3.7 to 3.10
* RHEL 8 - Python 3.6, 3.8 to 3.10

## Finally
Expand Down
26 changes: 0 additions & 26 deletions unix/Pipfile

This file was deleted.

Loading
Loading