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
13 changes: 13 additions & 0 deletions .github/semantic_release/CHANGELOG.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# CHANGELOG

{% for version, release in ctx.history.released.items() %}
## {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})

{% for type_, commits in release["elements"] | dictsort if type_ != "unknown" %}
### {{ type_ | title }}

{% for commit in commits %}
* {{ commit.descriptions[0] }}
{% endfor %}
{% endfor %}
{% endfor %}
7 changes: 1 addition & 6 deletions .github/workflows/lint-and-type-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ name: Lint and Type Check
on:
push:
branches:
- v2-python-rewrite
- master
pull_request:
branches:
- v2-python-rewrite
- master
- '**'

jobs:
lint-and-type-check:
Expand Down
151 changes: 151 additions & 0 deletions .github/workflows/pyinstaller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: PyInstaller Builds

on:
push:
branches: [ '**' ]
workflow_dispatch:

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.13-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-3.13-
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install ruff black mypy types-requests pytest

- name: Run ruff (linting)
run: |
echo "Running ruff linter..."
ruff check check_netscaler/ tests/ --output-format=github
continue-on-error: false

- name: Run black (code formatting check)
run: |
echo "Checking code formatting with black..."
black --check --diff check_netscaler/ tests/
continue-on-error: false

- name: Run mypy (type checking)
run: |
echo "Running mypy type checker..."
mypy check_netscaler/ --ignore-missing-imports --no-strict-optional
continue-on-error: true

- name: Run tests
run: |
echo "Running pytest..."
pytest tests/ -v --tb=short
continue-on-error: false

build:
name: Build Binary (${{ matrix.os }})
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
artifact_name: check_netscaler-linux
asset_name: check_netscaler-linux
- os: windows-latest
artifact_name: check_netscaler.exe
asset_name: check_netscaler-windows.exe
- os: macos-latest
artifact_name: check_netscaler-macos
asset_name: check_netscaler-macos

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Cache pip packages
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/Library/Caches/pip
~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-pyinstaller-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-pyinstaller-
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pyinstaller

- name: Build with PyInstaller
run: |
pyinstaller check_netscaler.spec

- name: Smoke test (Linux/macOS)
if: runner.os != 'Windows'
run: |
chmod +x dist/check_netscaler
./dist/check_netscaler --version
./dist/check_netscaler --help

- name: Smoke test (Windows)
if: runner.os == 'Windows'
run: |
dist\check_netscaler.exe --version
dist\check_netscaler.exe --help

- name: Rename binary (Linux)
if: runner.os == 'Linux'
run: mv dist/check_netscaler dist/${{ matrix.artifact_name }}

- name: Rename binary (macOS)
if: runner.os == 'macOS'
run: mv dist/check_netscaler dist/${{ matrix.artifact_name }}

- name: Generate SHA256 checksum (Linux/macOS)
if: runner.os != 'Windows'
run: |
cd dist
sha256sum ${{ matrix.artifact_name }} > ${{ matrix.artifact_name }}.sha256sum

- name: Generate SHA256 checksum (Windows)
if: runner.os == 'Windows'
run: |
cd dist
certutil -hashfile ${{ matrix.artifact_name }} SHA256 > ${{ matrix.artifact_name }}.sha256sum

- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: |
dist/${{ matrix.artifact_name }}
dist/${{ matrix.artifact_name }}.sha256sum
if-no-files-found: error
retention-days: 30
105 changes: 104 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,90 @@ jobs:
name: dist
path: dist/

build-binaries:
name: Build Binaries (${{ matrix.os }})
needs: test
runs-on: ${{ matrix.os }}
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
artifact_name: check_netscaler-linux
asset_name: check_netscaler-linux
- os: windows-latest
artifact_name: check_netscaler.exe
asset_name: check_netscaler-windows.exe
- os: macos-latest
artifact_name: check_netscaler-macos
asset_name: check_netscaler-macos

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pyinstaller

- name: Build with PyInstaller
run: |
pyinstaller check_netscaler.spec

- name: Smoke test (Linux/macOS)
if: runner.os != 'Windows'
run: |
chmod +x dist/check_netscaler
./dist/check_netscaler --version
./dist/check_netscaler --help

- name: Smoke test (Windows)
if: runner.os == 'Windows'
run: |
dist\check_netscaler.exe --version
dist\check_netscaler.exe --help

- name: Rename binary (Linux)
if: runner.os == 'Linux'
run: mv dist/check_netscaler dist/${{ matrix.artifact_name }}

- name: Rename binary (macOS)
if: runner.os == 'macOS'
run: mv dist/check_netscaler dist/${{ matrix.artifact_name }}

- name: Generate SHA256 checksum (Linux/macOS)
if: runner.os != 'Windows'
run: |
cd dist
sha256sum ${{ matrix.artifact_name }} > ${{ matrix.artifact_name }}.sha256sum

- name: Generate SHA256 checksum (Windows)
if: runner.os == 'Windows'
run: |
cd dist
certutil -hashfile ${{ matrix.artifact_name }} SHA256 > ${{ matrix.artifact_name }}.sha256sum

- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: |
dist/${{ matrix.artifact_name }}
dist/${{ matrix.artifact_name }}.sha256sum
if-no-files-found: error

release:
name: Create Release
runs-on: ubuntu-latest
needs: [test, build]
needs: [test, build, build-binaries]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
outputs:
released: ${{ steps.semantic.outputs.released }}
Expand All @@ -132,13 +212,36 @@ jobs:
python -m pip install --upgrade pip
pip install build twine

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/

- name: Display artifact structure
run: ls -R artifacts/

- name: Python Semantic Release
id: semantic
uses: python-semantic-release/python-semantic-release@v9.8.8
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
root_options: "-vv"

- name: Upload binaries to release
if: steps.semantic.outputs.released == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ steps.semantic.outputs.version }}
gh release upload v${VERSION} \
artifacts/check_netscaler-linux/check_netscaler-linux \
artifacts/check_netscaler-linux/check_netscaler-linux.sha256sum \
artifacts/check_netscaler.exe/check_netscaler.exe \
artifacts/check_netscaler.exe/check_netscaler.exe.sha256sum \
artifacts/check_netscaler-macos/check_netscaler-macos \
artifacts/check_netscaler-macos/check_netscaler-macos.sha256sum \
--clobber

publish-testpypi:
name: Publish to TestPyPI
runs-on: ubuntu-latest
Expand Down
86 changes: 86 additions & 0 deletions check_netscaler.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# -*- mode: python ; coding: utf-8 -*-
"""
PyInstaller spec file for check_netscaler
Creates a single-file executable for cross-platform distribution
"""

block_cipher = None

a = Analysis(
['run_check_netscaler.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[
'requests',
'urllib3',
'certifi',
'charset_normalizer',
'idna',
'check_netscaler.client',
'check_netscaler.client.session',
'check_netscaler.client.nitro',
'check_netscaler.client.exceptions',
'check_netscaler.commands',
'check_netscaler.commands.base',
'check_netscaler.commands.state',
'check_netscaler.commands.threshold',
'check_netscaler.commands.sslcert',
'check_netscaler.commands.nsconfig',
'check_netscaler.commands.hwinfo',
'check_netscaler.commands.hastatus',
'check_netscaler.commands.license',
'check_netscaler.commands.interfaces',
'check_netscaler.commands.perfdata',
'check_netscaler.commands.servicegroup',
'check_netscaler.commands.matches',
'check_netscaler.commands.staserver',
'check_netscaler.commands.ntp',
'check_netscaler.commands.debug',
'check_netscaler.output',
'check_netscaler.output.nagios',
'check_netscaler.utils',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
'pytest',
'pytest-cov',
'pytest-mock',
'black',
'ruff',
'mypy',
'setuptools',
'_pytest',
'py',
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='check_netscaler',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
Loading
Loading