-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a02da57
commit a9ec685
Showing
16 changed files
with
1,160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
exclude = .git,__pycache__,venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
name: Lint, Test & Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
python-version: [ '3.10' ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Run Lint | ||
run: | | ||
flake8 --verbose --color auto --count --statistics --format=default --output-file=flake8-report | ||
- name: Upload Report | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: lint-report-${{ matrix.python-version }}-${{ matrix.os }} | ||
path: flake8-report | ||
|
||
test: | ||
name: Test | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest, macos-latest ] | ||
python-version: [ '3.10', '3.11', '3.12' ] | ||
runs-on: ${{ matrix.os }} | ||
needs: lint | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest | ||
pip install pytest-html | ||
pip install -r requirements.txt | ||
- name: Run Tests | ||
run: | | ||
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes --html=pytest_results.html --self-contained-html | ||
- name: Upload Report | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-${{ matrix.os }}-${{ matrix.python-version }} | ||
path: pytest_results.html | ||
|
||
build: | ||
name: Build | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest, macos-latest ] | ||
python-version: [ '3.10' ] | ||
runs-on: ${{ matrix.os }} | ||
needs: test | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel | ||
- name: Build Package | ||
run: | | ||
python setup.py sdist | ||
- name: Get Package Name (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
$path_separator = "\\" | ||
$latestFile = Get-ChildItem -Path "dist\\" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 | ||
Write-Host "Latest file: $latestFile" | ||
Write-Output "PACKAGE_NAME=dist$path_separator$($latestFile.Name)" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
- name: Get Package Name (Ubuntu and macOS) | ||
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' | ||
run: | | ||
path_separator="/" | ||
latestFile=$(ls -t dist/ | head -n 1) | ||
echo "Latest file: $latestFile" | ||
echo "PACKAGE_NAME=dist$path_separator$latestFile" >> $GITHUB_ENV | ||
- name: Install Package | ||
run: | | ||
pip install ${{ env.PACKAGE_NAME }} | ||
release_check: | ||
name: Release Check | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
python-version: [ '3.10' ] | ||
runs-on: ${{ matrix.os }} | ||
needs: build | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build Package | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
- name: Get Package Name (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
$path_separator = "\\" | ||
$latestFile = Get-ChildItem -Path "dist\\" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 | ||
Write-Host "Latest file: $latestFile" | ||
Write-Output "PACKAGE_NAME=dist$path_separator$($latestFile.Name)" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
- name: Get Package Name (Ubuntu and macOS) | ||
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' | ||
run: | | ||
path_separator="/" | ||
latestFile=$(ls -t dist/ | head -n 1) | ||
echo "Latest file: $latestFile" | ||
echo "PACKAGE_NAME=dist$path_separator$latestFile" >> $GITHUB_ENV | ||
- name: Release Check | ||
run: | | ||
twine check ${{ env.PACKAGE_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
publish: | ||
name: Release | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
python-version: [ '3.10' ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build Package | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
- name: Get Package Name (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
$path_separator = "\\" | ||
$latestFile = Get-ChildItem -Path "dist\\" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 | ||
Write-Host "Latest file: $latestFile" | ||
Write-Output "PACKAGE_NAME=dist$path_separator$($latestFile.Name)" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
- name: Get Package Name (Ubuntu and macOS) | ||
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' | ||
run: | | ||
path_separator="/" | ||
latestFile=$(ls -t dist/ | head -n 1) | ||
echo "Latest file: $latestFile" | ||
echo "PACKAGE_NAME=dist$path_separator$latestFile" >> $GITHUB_ENV | ||
- name: Upload to PyPI | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: | | ||
twine upload --repository pypi ${{ env.PACKAGE_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@echo off | ||
setlocal | ||
|
||
REM Define the files to be deleted | ||
set "FLAKE_FILE=flake8-report" | ||
set "PYTEST_FILE=pytest_results.html" | ||
set "BUILD=dist" | ||
set "DIST_PACKAGE=dist\*.tar.gz" | ||
|
||
REM Check if an argument is provided | ||
if "%~1"=="" ( | ||
echo Usage: %0 [True|False] | ||
exit /b 1 | ||
) | ||
|
||
REM Parse the optional argument | ||
set "OUTPUT=%~1" | ||
|
||
REM Validate the argument | ||
if /I "%OUTPUT%" neq "True" if /I "%OUTPUT%" neq "False" ( | ||
echo Invalid argument. Please specify True or False. | ||
exit /b 1 | ||
) | ||
|
||
REM Define the files and directories to be checked | ||
echo Verifying if all mandatory files exist... | ||
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" | ||
|
||
REM Check for the existence of each required file or directory | ||
for %%f in (%CHECK_FILES_DIRS%) do ( | ||
if not exist "%%f" ( | ||
echo Error: Required file or directory %%f is missing. | ||
exit /b 1 | ||
) | ||
) | ||
|
||
REM Execute flake8 command based on the argument | ||
if /I "%OUTPUT%"=="True" ( | ||
REM Delete the files if they exist | ||
if exist "%FLAKE_FILE%" ( | ||
echo Deleting %FLAKE_FILE%... | ||
del "%FLAKE_FILE%" | ||
) | ||
|
||
if exist "%PYTEST_FILE%" ( | ||
echo Deleting %PYTEST_FILE%... | ||
del "%PYTEST_FILE%" | ||
) | ||
|
||
REM Execute flake8 with output redirection to a file | ||
echo Running flake8 with output file... | ||
flake8 --verbose --color auto --count --statistics --format=default --output-file=flake8-report | ||
|
||
REM Execute pytest with output redirection to a file | ||
echo Running pytest with output file... | ||
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes --html=pytest_results.html --self-contained-html | ||
) else ( | ||
REM Execute flake8 without output redirection | ||
echo Running flake8 without output file... | ||
flake8 --verbose --color auto --count --statistics --format=default | ||
|
||
REM Execute pytest without output redirection | ||
echo Running pytest without output file... | ||
pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes | ||
) | ||
|
||
REM Build package | ||
if exist %BUILD% ( | ||
echo Deleting folder %BUILD% and its contents... | ||
rd /s /q "%BUILD%" | ||
) | ||
echo Building package... | ||
python setup.py sdist | ||
|
||
REM Install the generated distribution | ||
echo Installing the package... | ||
for %%f in (%DIST_PACKAGE%) do ( | ||
echo Installing %%f... | ||
python -m pip install "%%f" | ||
) | ||
|
||
endlocal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Version History | ||
|
||
- 0.1.0: Initial Release (latest) |
Oops, something went wrong.