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
48 changes: 48 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches:
- '**'
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v7.0.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

- name: Install dependencies (setup-python provides pip in $PATH)
run: |
python --version
python -m pip install --upgrade pip
python -m pip install ".[dev]"
python -m pip install -r requirements.txt

- name: Run tests
run: |
pytest tests/test_package.py

- name: Build package
run: |
python -m build

- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
with:
name: python-build-${{ matrix.python-version }}
path: dist/
retention-days: 7
if-no-files-found: ignore
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,29 @@ This file requires just one line containing PASSWORD=yourpassword.
ssh-keygen is used for generation. This executable is available on all my Linux and Windows environments. For deployment, paramiko is used.

# Testing
Tests are implemented in tests/test-ssh-keys.py
There is a test for each KEY_TYPE generation and KEY_TYPE deployment between from one to another container.

Before running the tests you have to build the docker images. Best approach is to run
```
./docker-operations.py --build test_image
```
This creates a docker image locally from scratch.

This script has also some requirements on the environment. You probably want to create a virtual environment and install requirements.txt first.
Tests are implemented in tests/ directory.

If you want to test ssh-keys.py script manually, you can run
```
./docker-operations.py --run test_image #starts only one container
./docker-operations.py --run ssh-network #starts 2 interconnected containers with docker compose
To install development dependencies (`pytest`, `python-dotenv` etc.):
```bash
pip install -e ".[dev]"
```

This will start a container with the script inside, so you can play around without affecting your client PC.

To run tests:
```bash
pytest
```
./docker-operations.py --stop test_image

Or with coverage reporting:
```bash
pytest --cov=scripts --cov-report=term-missing
```
stops and removes all containers, defined from the provided Dockerfile.

Since the purpose of the scripts is to modify client/server PCs, the images and containers are only used for testing.
To build the package:
```bash
pip install build
python -m build
```


# Improvements / Nice to have
Expand Down
104 changes: 0 additions & 104 deletions docker-operations.py

This file was deleted.

35 changes: 29 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
[build-system]
requires = ["setuptools >= 80.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "setup_scripts"
version = "0.1.0"
description = "several python packages for automation"
requires-python = ">=3.10"
dependencies = [
"paramiko >= 3.4.0",
]

[build-system]
requires = [
"setuptools>=60"
[project.scripts]
ssh-keys = "scripts.ssh_keys:main"

[project.optional-dependencies]
dev = [
"pytest >= 8.0.0",
"pytest-cov >= 4.0.0",
"pytest-mock >= 3.12.0",
"python-dotenv >= 1.0.0",
"build"
]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ['repo_helpers']
[tool.setuptools.packages.find]
include = ["scripts*"]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v"





65 changes: 0 additions & 65 deletions repo-ops.py

This file was deleted.

3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# requirements for global installation
paramiko>=3.4.0
build
Loading
Loading