Skip to content

Commit cd23574

Browse files
setup better python package builds for iriscasttools
update to latest python version
1 parent 212d7c5 commit cd23574

File tree

11 files changed

+239
-119
lines changed

11 files changed

+239
-119
lines changed

.github/workflows/iriscast_package_build.yaml

Lines changed: 65 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -14,124 +14,97 @@ on:
1414

1515
jobs:
1616
test_and_lint:
17-
runs-on: ubuntu-20.04
17+
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
python-version: ["3.x", "3.10", "3.6.8"]
20+
python-version: ["3.x", "3.10"]
2121
steps:
22-
- uses: actions/checkout@v5
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Navigate to Folder
26+
run: cd ./iriscasttools
27+
2328
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v6
29+
uses: actions/setup-python@v4
2530
with:
2631
python-version: ${{ matrix.python-version }}
27-
cache: "pip"
28-
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install -r iriscasttools/requirements.txt
33-
34-
- name: Run tests
35-
run: cd iriscasttools/ && python3 -m pytest .
36-
37-
- name: Analyse with pylint
38-
run: |
39-
cd iriscasttools && pylint --recursive yes test iriscasttools
40-
41-
build-wheel:
42-
runs-on: ubuntu-20.04
32+
33+
release:
34+
runs-on: ubuntu-latest
35+
if: github.ref == 'refs/heads/master'
4336
strategy:
4437
matrix:
4538
python-version: ["3.x"]
39+
4640
steps:
47-
- uses: actions/checkout@v5
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
4844
- name: Set up Python ${{ matrix.python-version }}
49-
uses: actions/setup-python@v6
45+
uses: actions/setup-python@v4
5046
with:
5147
python-version: ${{ matrix.python-version }}
52-
cache: "pip"
53-
- name: Get Package Version
54-
id: version
55-
run: echo "version=$(python iriscasttools/setup.py --version)" >> $GITHUB_ENV
48+
5649
- name: Install dependencies
5750
run: |
5851
python -m pip install --upgrade pip
59-
pip install setuptools wheel
60-
- name: Build Wheels
61-
run: cd iriscasttools && python setup.py bdist_wheel
62-
- name: Upload Wheel
63-
uses: actions/upload-artifact@v4
64-
with:
65-
name: iriscasttools-${{ env.version }}-py3-none-any.whl
66-
path: iriscasttools/dist/iriscasttools-${{ env.version }}-py3-none-any.whl
67-
if-no-files-found: error
52+
pip install setuptools wheel build
6853
69-
build-rpms:
70-
runs-on: ubuntu-20.04
71-
strategy:
72-
matrix:
73-
python-version: ["3.10", "3.6.8"]
74-
steps:
75-
- uses: actions/checkout@v5
76-
- name: Set up Python ${{ matrix.python-version }}
77-
uses: actions/setup-python@v6
78-
with:
79-
python-version: ${{ matrix.python-version }}
80-
cache: "pip"
81-
- name: Get Package Version
82-
id: version
83-
run: echo "version=$(python iriscasttools/setup.py --version)" >> $GITHUB_ENV
84-
- name: Install dependencies
54+
- name: Build package
8555
run: |
86-
sudo apt-get update && sudo apt-get install -y rpm
87-
- name: Build RPM
88-
run: |
89-
cd iriscasttools
90-
python_version=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
91-
echo -e "[install]\ninstall-lib=/usr/lib/python${python_version}/site-packages" > setup.cfg
92-
python setup.py bdist_rpm
93-
cd dist
94-
mv iriscasttools-${{ env.version }}-1.noarch.rpm iriscasttools-${{ env.version }}-py${{ matrix.python-version }}.noarch.rpm
95-
- uses: actions/upload-artifact@v4
56+
cd ./iriscasttools
57+
python -m build
58+
59+
- name: Upload artifacts
60+
uses: actions/upload-artifact@v4
9661
with:
97-
name: iriscasttools-${{ env.version }}-py${{ matrix.python-version }}.noarch.rpm
98-
path: iriscasttools/dist/iriscasttools-${{ env.version }}-py${{ matrix.python-version }}.noarch.rpm
99-
if-no-files-found: error
100-
62+
name: dist-${{ matrix.python-version }}
63+
path: ./iriscasttools/dist/
64+
10165
publish:
102-
runs-on: ubuntu-20.04
103-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
104-
needs:
105-
- test_and_lint
106-
- build-wheel
107-
- build-rpms
66+
needs: release
67+
runs-on: ubuntu-latest
68+
10869
steps:
109-
- name: Checkout
110-
uses: actions/checkout@v5
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Download all artifacts
74+
uses: actions/download-artifact@v4
11175
with:
112-
fetch-depth: 0
76+
path: dist
11377

114-
- name: Configure Git
78+
- name: Get version from pyproject.toml
79+
id: get_version
11580
run: |
116-
git config user.name "$GITHUB_ACTOR"
117-
git config user.email "$[email protected]"
81+
version=$(grep -m1 '^version' iriscasttools/pyproject.toml | sed -E 's/version *= *"([^"]+)"/\1/')
82+
echo "version=$version" >> "$GITHUB_OUTPUT"
11883
119-
- name: Get Package Version
120-
id: version
121-
run: echo "version=$(python iriscasttools/setup.py --version)" >> $GITHUB_ENV
84+
- name: Create tag for current version
85+
run: |
86+
version="${{ steps.get_version.outputs.version }}"
87+
tag_name="iriscasttools-v${version}"
12288
123-
- name: Download Artifacts
124-
id: download
125-
uses: actions/download-artifact@v5
126-
with:
127-
path: iriscasttools/dist
89+
git config user.name "github-actions"
90+
git config user.email "[email protected]"
12891
129-
- name: Make Release
130-
uses: ncipollo/release-action@v1
131-
with:
132-
artifacts: iriscasttools/dist/*/*
133-
tag: ${{ env.version }}
134-
name: iriscasttools-${{ env.version }}
135-
skipIfReleaseExists: true
92+
# Only tag if it doesn't already exist
93+
if git rev-parse "$tag_name" >/dev/null 2>&1; then
94+
echo "Tag $tag_name already exists. Skipping."
95+
else
96+
git tag "$tag_name"
97+
git push origin "$tag_name"
98+
fi
13699
100+
- name: Create GitHub Release
101+
uses: softprops/action-gh-release@v1
102+
with:
103+
tag_name: iriscasttools-v${{ steps.get_version.outputs.version }}
104+
files: |
105+
dist/**/*.whl
106+
dist/**/*.tar.gz
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137109

110+

iriscasttools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
dist/*

iriscasttools/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# IRISCAST Tools
2+
3+
> [!Warning]
4+
> This package is deprecated and is not supported.
5+
6+
A python package that bundlels together a collection of energy usage monitoring scripts to be run on cloud hypervisors.
7+
8+
These scripts will collect power usage data using IPMI.
9+
10+
This package is intended to be installed onto HVs and a cronjob written to run this every 15mins to populate a csv - which can be read by filebeat/fluentd to a datastore.
11+
12+
## Installation
13+
14+
```bash
15+
pip install "iriscasttools @ git+https://github.com/stfc/SCD-OpenStack-Utils.git"
16+
```
17+
18+
## Usage
19+
20+
Run as a cron job:
21+
```
22+
python3 -m iriscasttols --as-csv >> /var/cache/iriscast/ipmi-stats-$(date -I).csv
23+
24+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Metadata-Version: 2.4
2+
Name: iriscasttools
3+
Version: 1.0.0
4+
Summary: python package for IRISCAST Tools
5+
Author-email: STFC Cloud Team <[email protected]>
6+
Project-URL: Repository, https://github.com/stfc/SCD-Openstack-Utils
7+
Project-URL: Documentation, https://github.com/stfc/SCD-Openstack-Utils/iriscasttools/README.md
8+
Project-URL: Issues, https://github.com/stfc/SCD-Openstack-Utils/issues
9+
Keywords: python,openstack
10+
Classifier: Development Status :: 4 - Beta
11+
Classifier: Intended Audience :: Openstack Admins :: Monitoring Tools
12+
Classifier: Programming Language :: Python :: 3
13+
Requires-Python: >=3.10
14+
Description-Content-Type: text/markdown
15+
Requires-Dist: psutil
16+
Provides-Extra: test
17+
Requires-Dist: pytest; extra == "test"
18+
Requires-Dist: pytest-cov; extra == "test"
19+
Requires-Dist: black; extra == "test"
20+
Requires-Dist: pylint; extra == "test"
21+
Provides-Extra: dev
22+
Requires-Dist: bumpversion; extra == "dev"
23+
24+
# IRISCAST Tools
25+
26+
> [!Warning]
27+
> This package is deprecated and is not supported.
28+
29+
A python package that bundlels together a collection of energy usage monitoring scripts to be run on cloud hypervisors.
30+
31+
These scripts will collect power usage data using IPMI.
32+
33+
This package is intended to be installed onto HVs and a cronjob written to run this every 15mins to populate a csv - which can be read by filebeat/fluentd to a datastore.
34+
35+
## Installation
36+
37+
```bash
38+
pip install "iriscasttools @ git+https://github.com/stfc/SCD-OpenStack-Utils.git"
39+
```
40+
41+
## Usage
42+
43+
Run as a cron job:
44+
```
45+
python3 -m iriscasttols --as-csv >> /var/cache/iriscast/ipmi-stats-$(date -I).csv
46+
47+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
README.md
2+
pyproject.toml
3+
iriscasttools/iriscasttools.egg-info/PKG-INFO
4+
iriscasttools/iriscasttools.egg-info/SOURCES.txt
5+
iriscasttools/iriscasttools.egg-info/dependency_links.txt
6+
iriscasttools/iriscasttools.egg-info/requires.txt
7+
iriscasttools/iriscasttools.egg-info/top_level.txt
8+
test/test_stats.py
9+
test/test_utils.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
psutil
2+
3+
[dev]
4+
bumpversion
5+
6+
[test]
7+
pytest
8+
pytest-cov
9+
black
10+
pylint
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

iriscasttools/pyproject.toml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools.packages.find]
6+
where = ["iriscasttools"]
7+
8+
[project]
9+
name = "iriscasttools"
10+
version = "1.0.0"
11+
description = "python package for IRISCAST Tools"
12+
authors = [{name = "STFC Cloud Team", email = "[email protected]"}]
13+
readme = "README.md"
14+
requires-python = ">=3.10"
15+
keywords = ["python", "openstack"]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Intended Audience :: Openstack Admins :: Monitoring Tools",
19+
"Programming Language :: Python :: 3",
20+
]
21+
dependencies = [
22+
"psutil",
23+
]
24+
25+
[project.urls]
26+
Repository = "https://github.com/stfc/SCD-Openstack-Utils"
27+
Documentation = "https://github.com/stfc/SCD-Openstack-Utils/iriscasttools/README.md"
28+
Issues = "https://github.com/stfc/SCD-Openstack-Utils/issues"
29+
30+
# Optional dependency groups
31+
[project.optional-dependencies]
32+
test = [
33+
"pytest",
34+
"pytest-cov",
35+
"black",
36+
"pylint",
37+
]
38+
39+
dev = [
40+
"bumpversion"
41+
]
42+
43+
[tool.pytest.ini_options]
44+
pythonpath = ["iriscasttools"]
45+
testpaths = ["tests"]
46+
python_files = ["*.py"]
47+
python_functions = ["test_*"]
48+
49+
50+
[tool.black]
51+
line-length = 88
52+
target-version = ['py38']
53+
include = '\.pyi?$'
54+
55+
[tool.pylint.format]
56+
max-line-length=118
57+
disable=[
58+
"C00114", # Missing module string - we don't need module strings for the small repo
59+
"W1401", # Influxdb required backslashes
60+
"R0801" # Duplicate code due to test case
61+
]
62+
63+
[tool.bumpversion]
64+
current_version = "1.0.0"
65+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
66+
serialize = ["{major}.{minor}.{patch}"]
67+
search = "{current_version}"
68+
replace = "{new_version}"
69+
regex = false
70+
ignore_missing_version = false
71+
ignore_missing_files = false
72+
tag = false
73+
allow_dirty = true
74+
commit = true
75+
message = "Bump version: {current_version} → {new_version}"
76+
moveable_tags = []
77+
commit_args = "--no-verify"
78+
setup_hooks = []
79+
pre_commit_hooks = []
80+
post_commit_hooks = []

iriscasttools/requirements.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)