Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge V0.3.3 updates into v0.4.x #86

Merged
merged 4 commits into from
Oct 5, 2023
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
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ updates:
schedule:
interval: "monthly"
open-pull-requests-limit: 100
groups:
python-dependencies:
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 100
groups:
actions-dependencies:
patterns:
- "*"
28 changes: 13 additions & 15 deletions .github/workflows/CodeQL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [ main ]
schedule:
- cron: 0 0 1 * *
- cron: 0 7 1 * *

jobs:
analyze:
Expand All @@ -23,20 +23,18 @@ jobs:
language: [ python ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: /language:${{matrix.language}}

- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: /language:${{matrix.language}}

# Use this job for branch protection rules
report-codeql-status:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/PackagePublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
environment: publish-pypi

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

- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -41,23 +44,20 @@ jobs:
with:
virtualenvs-create: false

- name: Checkout source
uses: actions/checkout@v4

# Get the new package version from the release tag
# Release tags are expected to start with "refs/tags/v", so the first 11 characters are stripped
# Git release tags are expected to start with "refs/tags/v"
- name: Set package version
run: |
release_tag=${{github.ref}}
poetry version "${release_tag:11}"
poetry version "${release_tag#refs/tags/v}"

- name: Build package
run: poetry build -v

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
print-hash: true
repository-url: ${{ matrix.host }}
user: ${{ secrets.REPO_USER }}
password: ${{ secrets.REPO_PASSWORD }}
12 changes: 7 additions & 5 deletions .github/workflows/PackageTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
workflow_dispatch:
workflow_call:
push:
schedule:
- cron: 0 7 1,15 * *

jobs:
run-tests:
Expand All @@ -23,17 +25,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: |
pip install poetry
poetry env use python${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false

- name: Install dependencies
run: poetry install --with tests

- name: Run tests with coverage
run: |
poetry run coverage run -m unittest discover tests
poetry run coverage run -m unittest discover
poetry run coverage report --omit="tests/*"
poetry run coverage xml --omit="tests/*" -o coverage.xml

Expand Down
10 changes: 6 additions & 4 deletions shinigami/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import asyncssh
import pandas as pd

INIT_PROCESS_ID = 1


def id_in_whitelist(id_value: int, whitelist: Collection[Union[int, Tuple[int, int]]]) -> bool:
"""Return whether an ID is in a list of ID values
Expand Down Expand Up @@ -81,7 +83,7 @@ async def terminate_errant_processes(
process_df = pd.read_fwf(StringIO(ps_return.stdout), widths=[11, 11, 11, 11, 500])

# Identify orphaned processes and filter them by the UID whitelist
orphaned = process_df[process_df.PPID == 1]
orphaned = process_df[process_df.PPID == INIT_PROCESS_ID]
terminate = orphaned[orphaned['UID'].apply(id_in_whitelist, whitelist=uid_whitelist)]

for _, row in terminate.iterrows():
Expand All @@ -91,6 +93,6 @@ async def terminate_errant_processes(
logging.info(f'[{node}] no processes found')

elif not debug:
proc_id_str = ','.join(terminate.PGID.astype(str))
logging.info(f'[{node}] Sending termination signal for process groups {proc_id_str}')
await conn.run(f"pkill --signal -9 --pgroup {proc_id_str}", check=True)
proc_id_str = ','.join(terminate.PGID.unique().astype(str))
logging.info(f"[{node}] Sending termination signal for process groups {proc_id_str}")
await conn.run(f"pkill --signal 9 --pgroup {proc_id_str}", check=True)