Skip to content

Commit 7e65c6b

Browse files
authored
Updated Pipeline To Support Multi-OS & Added Support for PyPI Release (#4)
1 parent 8359295 commit 7e65c6b

File tree

13 files changed

+168
-174
lines changed

13 files changed

+168
-174
lines changed

.github/workflows/pipeline.yml

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test & Build
1+
name: Lint, Test & Build
22

33
on:
44
push:
@@ -7,65 +7,112 @@ on:
77

88
jobs:
99
lint:
10-
name: Python Linux (flake8)
11-
runs-on: ubuntu-latest
12-
10+
name: Lint
11+
timeout-minutes: 20
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ ubuntu-latest ]
16+
python-version: [ '3.10' ]
17+
runs-on: ${{ matrix.os }}
1318
steps:
1419
- name: Checkout Repository
1520
uses: actions/checkout@v4
1621

17-
- name: Setup Python
22+
- name: Set up Python
1823
uses: actions/setup-python@v5
1924
with:
20-
python-version: '3.10'
25+
python-version: ${{ matrix.python-version }}
2126

2227
- name: Install Dependencies
2328
run: |
2429
python -m pip install --upgrade pip
2530
pip install flake8
2631
2732
- name: Run Lint
28-
run: flake8 --verbose --color auto --count --statistics --format=json --output-file=flake8-report.json || echo "::set-output name=flake8_failed::true"
29-
continue-on-error: true
33+
run: |
34+
flake8 --verbose --color auto --count --statistics --format=default --output-file=flake8-report
3035
3136
- name: Upload Report
3237
if: ${{ always() }}
3338
uses: actions/upload-artifact@v4
3439
with:
35-
name: flake8-report
36-
path: flake8-report.json
37-
38-
build_and_test:
39-
name: Build and Test
40-
runs-on: ubuntu-latest
41-
needs: lint
40+
name: lint-report-${{ matrix.python-version }}-${{ matrix.os }}
41+
path: flake8-report
4242

43+
test:
44+
name: Test
45+
timeout-minutes: 20
46+
strategy:
47+
fail-fast: true
48+
matrix:
49+
os: [ ubuntu-latest, windows-latest, macos-latest ]
50+
python-version: [ '3.10', '3.11', '3.12' ]
51+
runs-on: ${{ matrix.os }}
52+
needs: lint
4353
steps:
4454
- name: Checkout Repository
4555
uses: actions/checkout@v4
4656

47-
- name: Setup Python
57+
- name: Set up Python
4858
uses: actions/setup-python@v5
4959
with:
50-
python-version: '3.10'
60+
python-version: ${{ matrix.python-version }}
5161

5262
- name: Install Dependencies
5363
run: |
5464
python -m pip install --upgrade pip
55-
pip install setuptools wheel
65+
pip install pytest
66+
pip install -r requirements.txt
5667
57-
- name: Install Pytest
68+
- name: Run Tests
5869
run: |
59-
pip install pytest
70+
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes
71+
72+
build:
73+
name: Build
74+
timeout-minutes: 20
75+
strategy:
76+
fail-fast: true
77+
matrix:
78+
os: [ ubuntu-latest, windows-latest, macos-latest ]
79+
python-version: [ '3.10' ]
80+
runs-on: ${{ matrix.os }}
81+
needs: test
82+
steps:
83+
- name: Checkout Repository
84+
uses: actions/checkout@v4
85+
86+
- name: Set up Python
87+
uses: actions/setup-python@v5
88+
with:
89+
python-version: ${{ matrix.python-version }}
90+
91+
- name: Install Dependencies
92+
run: |
93+
python -m pip install --upgrade pip
94+
pip install setuptools wheel
6095
6196
- name: Build Package
6297
run: |
6398
python setup.py sdist
6499
65-
- name: Install Package
100+
- name: Get Package Name (Windows)
101+
if: matrix.os == 'windows-latest'
66102
run: |
67-
pip install dist/*
103+
$path_separator = "\\"
104+
$latestFile = Get-ChildItem -Path "dist\\" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
105+
Write-Host "Latest file: $latestFile"
106+
Write-Output "PACKAGE_NAME=dist$path_separator$($latestFile.Name)" | Out-File -FilePath $env:GITHUB_ENV -Append
68107
69-
- name: Run Tests
108+
- name: Get Package Name (Ubuntu and macOS)
109+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
110+
run: |
111+
path_separator="/"
112+
latestFile=$(ls -t dist/ | head -n 1)
113+
echo "Latest file: $latestFile"
114+
echo "PACKAGE_NAME=dist$path_separator$latestFile" >> $GITHUB_ENV
115+
116+
- name: Install Package
70117
run: |
71-
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes
118+
pip install ${{ env.PACKAGE_NAME }}

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
branches:
8+
- 'main'
9+
10+
jobs:
11+
publish:
12+
name: Release
13+
timeout-minutes: 20
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
os: [ ubuntu-latest ]
18+
python-version: [ '3.10' ]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install Dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install setuptools wheel twine
33+
34+
- name: Build Package
35+
run: |
36+
python setup.py sdist bdist_wheel
37+
38+
- name: Get Package Name (Windows)
39+
if: matrix.os == 'windows-latest'
40+
run: |
41+
$path_separator = "\\"
42+
$latestFile = Get-ChildItem -Path "dist\\" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
43+
Write-Host "Latest file: $latestFile"
44+
Write-Output "PACKAGE_NAME=dist$path_separator$($latestFile.Name)" | Out-File -FilePath $env:GITHUB_ENV -Append
45+
46+
- name: Get Package Name (Ubuntu and macOS)
47+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
48+
run: |
49+
path_separator="/"
50+
latestFile=$(ls -t dist/ | head -n 1)
51+
echo "Latest file: $latestFile"
52+
echo "PACKAGE_NAME=dist$path_separator$latestFile" >> $GITHUB_ENV
53+
54+
- name: Upload to PyPI
55+
env:
56+
TWINE_USERNAME: __token__
57+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
58+
run: |
59+
twine upload --repository pypi ${{ env.PACKAGE_NAME }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ cython_debug/
157157
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
#.idea/
160+
.idea/

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Version History
22

3-
- 0.1.0: Initial Release (latest)
3+
- 0.1.2: Updated Pipeline To Support Multi-OS & Added Support for PyPI Release (latest)
4+
- 0.1.1: Introduced Linting
5+
- 0.1.0: Initial Release

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ The pyconfigurationmanager package provides a set of utilities for managing conf
44
## Installation
55
Configuration Manager can be installed using pip:
66
```bash
7-
pip install git+https://github.com/coldsofttech/pyconfigurationmanager.git
7+
pip install pyconfigurationmanager
88
```
99

1010
## Usage
11+
1112
````python
1213
from pyconfigurationmanager import ConfigurationManager
1314

conftest.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
# Copyright (c) 2024 coldsofttech
2-
#
3-
# Permission is hereby granted, free of charge, to any person obtaining a copy
4-
# of this software and associated documentation files (the "Software"), to deal
5-
# in the Software without restriction, including without limitation the rights
6-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7-
# copies of the Software, and to permit persons to whom the Software is
8-
# furnished to do so, subject to the following conditions:
9-
#
10-
# The above copyright notice and this permission notice shall be included in all
11-
# copies or substantial portions of the Software.
12-
#
13-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19-
# SOFTWARE.
20-
211
def pytest_collection_modifyitems(config, items):
222
"""
233
Custom pytest hook to modify the collection of test items.

pyconfigurationmanager/__init__.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
# Copyright (c) 2024 coldsofttech
2-
#
3-
# Permission is hereby granted, free of charge, to any person obtaining a copy
4-
# of this software and associated documentation files (the "Software"), to deal
5-
# in the Software without restriction, including without limitation the rights
6-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7-
# copies of the Software, and to permit persons to whom the Software is
8-
# furnished to do so, subject to the following conditions:
9-
#
10-
# The above copyright notice and this permission notice shall be included in all
11-
# copies or substantial portions of the Software.
12-
#
13-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19-
# SOFTWARE.
20-
211
__all__ = [
222
"ConfigurationManager",
233
"ConfigurationManagerError",
@@ -33,6 +13,6 @@
3313
auditing configuration changes, and ensuring secure access to configuration files.
3414
"""
3515
__name__ = "pyconfigurationmanager"
36-
__version__ = "0.1.1"
16+
__version__ = "0.1.2"
3717

3818
from pyconfigurationmanager.__main__ import ConfigurationManager, ConfigurationManagerError

pyconfigurationmanager/__main__.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
# Copyright (c) 2024 coldsofttech
2-
#
3-
# Permission is hereby granted, free of charge, to any person obtaining a copy
4-
# of this software and associated documentation files (the "Software"), to deal
5-
# in the Software without restriction, including without limitation the rights
6-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7-
# copies of the Software, and to permit persons to whom the Software is
8-
# furnished to do so, subject to the following conditions:
9-
#
10-
# The above copyright notice and this permission notice shall be included in all
11-
# copies or substantial portions of the Software.
12-
#
13-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19-
# SOFTWARE.
20-
211
import getpass
222
import json
233
import os.path
@@ -41,8 +21,19 @@ def get_ip_address() -> str:
4121
:return: The IP address of the local machine as a string.
4222
:rtype: str
4323
"""
44-
hostname = socket.gethostname()
45-
ip_address = socket.gethostbyname(hostname)
24+
try:
25+
hostname = socket.gethostname()
26+
ip_address = socket.gethostbyname(hostname)
27+
return ip_address
28+
except socket.gaierror:
29+
try:
30+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
31+
s.connect(('8.8.8.8', 80))
32+
ip_address = s.getsockname()[0]
33+
s.close()
34+
except socket.error:
35+
ip_address = '127.0.0.1'
36+
4637
return ip_address
4738

4839
@staticmethod
@@ -141,7 +132,7 @@ def _check_file_permissions(cls, file_path: str) -> None:
141132
raise OSError(error)
142133
elif any(perm in permissions_list[0] for perm in ['(F)', '(M)']):
143134
raise OSError(error)
144-
elif platform.system().lower() == 'linux':
135+
elif platform.system().lower() == 'linux' or platform.system().lower() == 'darwin':
145136
file_stat = os.stat(file_path)
146137
if file_stat.st_mode & 0o777 != 0o400:
147138
raise OSError(error)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pyloggermanager@ git+https://github.com/coldsofttech/pyloggermanager.git
1+
pyloggermanager
22
pytest~=7.4.0
33
setuptools~=69.2.0

setup.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
# Copyright (c) 2024 coldsofttech
2-
#
3-
# Permission is hereby granted, free of charge, to any person obtaining a copy
4-
# of this software and associated documentation files (the "Software"), to deal
5-
# in the Software without restriction, including without limitation the rights
6-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7-
# copies of the Software, and to permit persons to whom the Software is
8-
# furnished to do so, subject to the following conditions:
9-
#
10-
# The above copyright notice and this permission notice shall be included in all
11-
# copies or substantial portions of the Software.
12-
#
13-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19-
# SOFTWARE.
20-
211
from setuptools import setup
222
import pyconfigurationmanager
233

@@ -32,6 +12,20 @@
3212
author='coldsofttech',
3313
description=pyconfigurationmanager.__description__,
3414
install_requires=[
35-
'pyloggermanager@ git+https://github.com/coldsofttech/pyloggermanager.git'
15+
'pyloggermanager'
16+
],
17+
requires_python=">=3.10",
18+
long_description=open('README.md').read(),
19+
long_description_content_type='text/markdown',
20+
keywords=["configuration", "configuration-management", "config-manager"],
21+
classifiers=[
22+
"Development Status :: 4 - Beta",
23+
"Intended Audience :: Developers",
24+
"Topic :: Software Development :: Libraries :: Python Modules",
25+
"Topic :: Utilities :: Configuration Management",
26+
"License :: OSI Approved :: MIT License",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12"
3630
]
3731
)

0 commit comments

Comments
 (0)