Skip to content

Commit a9ec685

Browse files
authored
Initial Release (#1)
1 parent a02da57 commit a9ec685

File tree

16 files changed

+1160
-2
lines changed

16 files changed

+1160
-2
lines changed

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 120
3+
exclude = .git,__pycache__,venv

.github/workflows/pipeline.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Lint, Test & Build
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
lint:
10+
name: Lint
11+
timeout-minutes: 20
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ ubuntu-latest ]
16+
python-version: [ '3.10' ]
17+
runs-on: ${{ matrix.os }}
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Install Dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install flake8
31+
32+
- name: Run Lint
33+
run: |
34+
flake8 --verbose --color auto --count --statistics --format=default --output-file=flake8-report
35+
36+
- name: Upload Report
37+
if: ${{ always() }}
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: lint-report-${{ matrix.python-version }}-${{ matrix.os }}
41+
path: flake8-report
42+
43+
test:
44+
name: Test
45+
timeout-minutes: 20
46+
strategy:
47+
fail-fast: false
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
53+
steps:
54+
- name: Checkout Repository
55+
uses: actions/checkout@v4
56+
57+
- name: Set up Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
62+
- name: Install Dependencies
63+
run: |
64+
python -m pip install --upgrade pip
65+
pip install pytest
66+
pip install pytest-html
67+
pip install -r requirements.txt
68+
69+
- name: Run Tests
70+
run: |
71+
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes --html=pytest_results.html --self-contained-html
72+
73+
- name: Upload Report
74+
if: ${{ always() }}
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: test-${{ matrix.os }}-${{ matrix.python-version }}
78+
path: pytest_results.html
79+
80+
build:
81+
name: Build
82+
timeout-minutes: 20
83+
strategy:
84+
fail-fast: false
85+
matrix:
86+
os: [ ubuntu-latest, windows-latest, macos-latest ]
87+
python-version: [ '3.10' ]
88+
runs-on: ${{ matrix.os }}
89+
needs: test
90+
steps:
91+
- name: Checkout Repository
92+
uses: actions/checkout@v4
93+
94+
- name: Set up Python
95+
uses: actions/setup-python@v5
96+
with:
97+
python-version: ${{ matrix.python-version }}
98+
99+
- name: Install Dependencies
100+
run: |
101+
python -m pip install --upgrade pip
102+
pip install setuptools wheel
103+
104+
- name: Build Package
105+
run: |
106+
python setup.py sdist
107+
108+
- name: Get Package Name (Windows)
109+
if: matrix.os == 'windows-latest'
110+
run: |
111+
$path_separator = "\\"
112+
$latestFile = Get-ChildItem -Path "dist\\" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
113+
Write-Host "Latest file: $latestFile"
114+
Write-Output "PACKAGE_NAME=dist$path_separator$($latestFile.Name)" | Out-File -FilePath $env:GITHUB_ENV -Append
115+
116+
- name: Get Package Name (Ubuntu and macOS)
117+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
118+
run: |
119+
path_separator="/"
120+
latestFile=$(ls -t dist/ | head -n 1)
121+
echo "Latest file: $latestFile"
122+
echo "PACKAGE_NAME=dist$path_separator$latestFile" >> $GITHUB_ENV
123+
124+
- name: Install Package
125+
run: |
126+
pip install ${{ env.PACKAGE_NAME }}
127+
128+
release_check:
129+
name: Release Check
130+
timeout-minutes: 20
131+
strategy:
132+
fail-fast: true
133+
matrix:
134+
os: [ ubuntu-latest ]
135+
python-version: [ '3.10' ]
136+
runs-on: ${{ matrix.os }}
137+
needs: build
138+
steps:
139+
- name: Checkout Repository
140+
uses: actions/checkout@v4
141+
142+
- name: Set up Python
143+
uses: actions/setup-python@v5
144+
with:
145+
python-version: ${{ matrix.python-version }}
146+
147+
- name: Install Dependencies
148+
run: |
149+
python -m pip install --upgrade pip
150+
pip install setuptools wheel twine
151+
152+
- name: Build Package
153+
run: |
154+
python setup.py sdist bdist_wheel
155+
156+
- name: Get Package Name (Windows)
157+
if: matrix.os == 'windows-latest'
158+
run: |
159+
$path_separator = "\\"
160+
$latestFile = Get-ChildItem -Path "dist\\" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
161+
Write-Host "Latest file: $latestFile"
162+
Write-Output "PACKAGE_NAME=dist$path_separator$($latestFile.Name)" | Out-File -FilePath $env:GITHUB_ENV -Append
163+
164+
- name: Get Package Name (Ubuntu and macOS)
165+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
166+
run: |
167+
path_separator="/"
168+
latestFile=$(ls -t dist/ | head -n 1)
169+
echo "Latest file: $latestFile"
170+
echo "PACKAGE_NAME=dist$path_separator$latestFile" >> $GITHUB_ENV
171+
172+
- name: Release Check
173+
run: |
174+
twine check ${{ 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,8 @@ cython_debug/
159159
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162-
#.idea/
162+
.idea/
163+
164+
# Files generated by local pipeline
165+
flake8-report
166+
pytest_results.html

.local_build.bat

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@echo off
2+
setlocal
3+
4+
REM Define the files to be deleted
5+
set "FLAKE_FILE=flake8-report"
6+
set "PYTEST_FILE=pytest_results.html"
7+
set "BUILD=dist"
8+
set "DIST_PACKAGE=dist\*.tar.gz"
9+
10+
REM Check if an argument is provided
11+
if "%~1"=="" (
12+
echo Usage: %0 [True|False]
13+
exit /b 1
14+
)
15+
16+
REM Parse the optional argument
17+
set "OUTPUT=%~1"
18+
19+
REM Validate the argument
20+
if /I "%OUTPUT%" neq "True" if /I "%OUTPUT%" neq "False" (
21+
echo Invalid argument. Please specify True or False.
22+
exit /b 1
23+
)
24+
25+
REM Define the files and directories to be checked
26+
echo Verifying if all mandatory files exist...
27+
set "CHECK_FILES_DIRS=.github\workflows\pipeline.yml .github\workflows\release.yml tests .flake8 .gitignore CHANGELOG.md conftest.py LICENSE pytest.ini README.md requirements.txt setup.py"
28+
29+
REM Check for the existence of each required file or directory
30+
for %%f in (%CHECK_FILES_DIRS%) do (
31+
if not exist "%%f" (
32+
echo Error: Required file or directory %%f is missing.
33+
exit /b 1
34+
)
35+
)
36+
37+
REM Execute flake8 command based on the argument
38+
if /I "%OUTPUT%"=="True" (
39+
REM Delete the files if they exist
40+
if exist "%FLAKE_FILE%" (
41+
echo Deleting %FLAKE_FILE%...
42+
del "%FLAKE_FILE%"
43+
)
44+
45+
if exist "%PYTEST_FILE%" (
46+
echo Deleting %PYTEST_FILE%...
47+
del "%PYTEST_FILE%"
48+
)
49+
50+
REM Execute flake8 with output redirection to a file
51+
echo Running flake8 with output file...
52+
flake8 --verbose --color auto --count --statistics --format=default --output-file=flake8-report
53+
54+
REM Execute pytest with output redirection to a file
55+
echo Running pytest with output file...
56+
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes --html=pytest_results.html --self-contained-html
57+
) else (
58+
REM Execute flake8 without output redirection
59+
echo Running flake8 without output file...
60+
flake8 --verbose --color auto --count --statistics --format=default
61+
62+
REM Execute pytest without output redirection
63+
echo Running pytest without output file...
64+
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes
65+
)
66+
67+
REM Build package
68+
if exist %BUILD% (
69+
echo Deleting folder %BUILD% and its contents...
70+
rd /s /q "%BUILD%"
71+
)
72+
echo Building package...
73+
python setup.py sdist
74+
75+
REM Install the generated distribution
76+
echo Installing the package...
77+
for %%f in (%DIST_PACKAGE%) do (
78+
echo Installing %%f...
79+
python -m pip install "%%f"
80+
)
81+
82+
endlocal

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Version History
2+
3+
- 0.1.0: Initial Release (latest)

0 commit comments

Comments
 (0)