Skip to content

Commit

Permalink
Merge V0.3.3 updates into v0.4.x (#86)
Browse files Browse the repository at this point in the history
* Bump actions/checkout from 3 to 4 (#81)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updates CI (#82)

* Fix termination signal (#84)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
djperrefort and dependabot[bot] authored Oct 5, 2023
1 parent c238c5f commit 2ec5d7a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 30 deletions.
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)

0 comments on commit 2ec5d7a

Please sign in to comment.