Skip to content

Commit

Permalink
Update github actions for PRs opened against main (github#29)
Browse files Browse the repository at this point in the history
* update pr action and requirements.txt

* fix flake8 findings

* remove dev container configurations
  • Loading branch information
Jamie Sadler authored Jan 5, 2022
1 parent 4af3b20 commit 8cedb7b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 33 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/black-formatter.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: python
on:
pull_request:
branches:
- main

env:
PYTHON_VERSION: "3.10.0"

jobs:
python:
runs-on: ubuntu-20.04
name: python
steps:
- uses: actions/checkout@v2

- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: install dependencies
run: pip install -r requirements.txt

- name: run black formatter
run: black --check .

- name: run flake8 linter
# Ignore linting errors that the black formatter is opiniated about
run: flake8 --ignore E501,W503 .

- name: run bandit security scan
run: bandit -r .
1 change: 0 additions & 1 deletion jiralib.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ def parse_state(self, raw_state):
return raw_state != self.endstate

def transition(self, transition):
old_issue_status = str(self.rawissue.fields.status.name)

if (
self.get_state()
Expand Down
7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
bandit~=1.7.0
black~=21.0b
flake8~=4.0.0
flask~=2.0.0
requests~=2.26.0
jira~=3.0.0
logging-formatter-anticrlf==1.2
logging-formatter-anticrlf==1.2
requests~=2.26.0
9 changes: 0 additions & 9 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from flask import Flask, request, jsonify
from flask.logging import default_handler
import json
import hashlib
import hmac
import logging
from datetime import datetime
import jiralib
import threading
Expand All @@ -29,11 +27,6 @@ def run_server(
app.run(port=port)


# logging.getLogger('jiralib').addHandler(default_handler)
# logging.getLogger('ghlib').addHandler(default_handler)
# logging.basicConfig(level=logging.INFO)


def auth_is_valid(signature, request_body):
if app.debug:
return True
Expand Down Expand Up @@ -142,8 +135,6 @@ def github_webhook():
alert = json_dict.get("alert")
alert_url = alert.get("html_url")
alert_num = alert.get("number")
rule_id = alert.get("rule").get("id")
rule_desc = alert.get("rule").get("description")

# TODO: We might want to do the following asynchronously, as it could
# take time to do a full sync on a repo with many alerts / issues
Expand Down
5 changes: 2 additions & 3 deletions sync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import jiralib
import ghlib
import logging
import itertools

Expand Down Expand Up @@ -114,13 +113,13 @@ def sync_repo(self, repo_id, states=None):
# gather issues
for i in self.jira.fetch_issues(repo.get_key()):
_, _, _, alert_key, _ = i.get_alert_info()
if not alert_key in pairs:
if alert_key not in pairs:
pairs[alert_key] = (None, [])
pairs[alert_key][1].append(i)

# remove unused states
for k in list(states.keys()):
if not k in pairs:
if k not in pairs:
del states[k]

# perform sync
Expand Down
2 changes: 1 addition & 1 deletion util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def state_from_json(s):
j = json.loads(s)
if not "version" in j:
if "version" not in j:
return {}
return j["states"]

Expand Down

0 comments on commit 8cedb7b

Please sign in to comment.