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

Add black formatting in tox + rev ignore in git blame #244

Merged
merged 2 commits into from
Sep 21, 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
7 changes: 7 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Have a look at
# https://stackoverflow.com/questions/34957237/can-i-configure-git-blame-to-always-ignore-certain-commits-want-to-fix-git-blam/57129540#57129540
# https://akrabat.com/ignoring-revisions-with-git-blame/
# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view

# Run code through black for formatting
e3061441e1492f44386d10b1c6426162e6d0c81c
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,23 @@ python -m pip install pip-tools
```

more info available at: https://github.com/jazzband/pip-tools/


# Ignoring large reformattings with git blame

The commits listed in `.git-blame-ignore-revs` are automatically ignored in github blame view
(https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view).
This feature is meant to ignore commits that just introduced reformatting, and maintain the logical
contributions of each line.

You can make use of the `.git-blame-ignore-revs` file locally by passing it as an argument to the
blame command:
```
git blame --ignore-revs-file .git-blame-ignore-revs ...
```
or by adding it to your local git configurations:
```
git config --local blame.ignoreRevsFile .git-blame-ignore-revs
```
Note that this should be done for per-project, as some projects may lack the `.git-blame-ignore-revs`
file, and in this case `git blame` would return an error.
101 changes: 50 additions & 51 deletions conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,31 @@
# declared properly somewhere/somehow
confdir = os.path.abspath(os.path.dirname(__file__))
# use parent dir as dbdir else fallback to current dir
dbdir = os.path.abspath(os.path.join(confdir, '..')) if confdir.endswith('conf') \
else confdir
dbdir = os.path.abspath(os.path.join(confdir, "..")) if confdir.endswith("conf") else confdir


class BaseConfiguration(object):
# Make this random (used to generate session keys)
SECRET_KEY = '74d9e9f9cd40e66fc6c4c2e9987dce48df3ce98542529fd0'
SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(os.path.join(
dbdir, 'freshmaker.db'))
SECRET_KEY = "74d9e9f9cd40e66fc6c4c2e9987dce48df3ce98542529fd0"
SQLALCHEMY_DATABASE_URI = "sqlite:///{0}".format(os.path.join(dbdir, "freshmaker.db"))
SQLALCHEMY_TRACK_MODIFICATIONS = False

HOST = '0.0.0.0'
HOST = "0.0.0.0"
PORT = 5001

SERVER_NAME = 'localhost:5001'
SERVER_NAME = "localhost:5001"

DEBUG = False
# Global network-related values, in seconds
NET_TIMEOUT = 120
NET_RETRY_INTERVAL = 30

SYSTEM = 'koji'
SYSTEM = "koji"

# Available log levels are: debug, info, warn, error.
LOG_LEVEL = 'info'
LOG_LEVEL = "info"

MESSAGING_TOPIC_PREFIX = ['org.fedoraproject.prod']
MESSAGING_TOPIC_PREFIX = ["org.fedoraproject.prod"]

# Base URL of git repository with source artifacts.
GIT_BASE_URL = "git://pkgs.devel.redhat.com"
Expand All @@ -49,9 +47,9 @@ class BaseConfiguration(object):

# Read Koji configuration from profile instead of reading them from
# configuration file directly. For staging Koji, it is stg.
KOJI_PROFILE = 'koji'
KOJI_PROFILE = "koji"
KOJI_PROXYUSER = False
KOJI_BUILD_OWNER = 'freshmaker'
KOJI_BUILD_OWNER = "freshmaker"

# Settings for docker image rebuild handler
KOJI_CONTAINER_SCRATCH_BUILD = False
Expand Down Expand Up @@ -121,12 +119,12 @@ class BaseConfiguration(object):

# ODCS configs
# URL to ODCS to call APIs
ODCS_SERVER_URL = 'https://odcs.localhost/'
ODCS_SERVER_URL = "https://odcs.localhost/"
ODCS_VERIFY_SSL = True
# Valid authentication method would be kerberos or openidc
ODCS_AUTH_MECH = 'kerberos'
ODCS_AUTH_MECH = "kerberos"
# When use openidc authentcation, set the openidc token for accessing ODCS
ODCS_OPENIDC_TOKEN = ''
ODCS_OPENIDC_TOKEN = ""

# Kerberos authentication Settings used to authenticated freshmaker itself
# by other services
Expand All @@ -137,65 +135,66 @@ class BaseConfiguration(object):
# Principal used to acquire credential cache. When using a client keytab,
# this value must be present in that keytab file. Otherwise, principal must
# match the one in specified ccache file.
KRB_AUTH_PRINCIPAL = ''
KRB_AUTH_PRINCIPAL = ""
# Path to freshmaker's client keytab file.
KRB_AUTH_CLIENT_KEYTAB = ''
KRB_AUTH_CLIENT_KEYTAB = ""
# Path to credential cache file. This optional could be None when not using
# a client keytab to acquire credential.
KRB_AUTH_CCACHE_FILE = tempfile.mkstemp(
suffix=str(os.getpid()), prefix="freshmaker_cc_") # type: Union[Tuple[int, str], Optional[str]]
suffix=str(os.getpid()), prefix="freshmaker_cc_"
) # type: Union[Tuple[int, str], Optional[str]]

# Select which authentication backend to work with. There are 3 choices Tuple[int, str]
# noauth: no authentication is enabled. Useful for development particularly.
# kerberos: Kerberos authentication is enabled.
# openidc: OpenIDC authentication is enabled.
AUTH_BACKEND = ''
AUTH_BACKEND = ""

# Used for Kerberos authentication and to query user's groups.
# Format: ldap://hostname[:port]
# For example: ldap://ldap.example.com/
AUTH_LDAP_SERVER = ''
AUTH_LDAP_SERVER = ""

# The base to query for users in LDAP. For example, ou=users,dc=example,dc=com.
AUTH_LDAP_USER_BASE = ''
AUTH_LDAP_USER_BASE = ""

# OIDC provider
AUTH_OPENIDC_USERINFO_URI = 'https://id.fedoraproject.org/openidc/UserInfo'
AUTH_OPENIDC_USERINFO_URI = "https://id.fedoraproject.org/openidc/UserInfo"

# OIDC base namespace
OIDC_BASE_NAMESPACE = ''
OIDC_BASE_NAMESPACE = ""

# Scope requested from Fedora Infra for permission of submitting request to
# run a new compose.
# See also: https://fedoraproject.org/wiki/Infrastructure/Authentication
# Add additional required scope in following list
AUTH_OPENIDC_REQUIRED_SCOPES = [
'openid',
'https://id.fedoraproject.org/scope/groups',
"openid",
"https://id.fedoraproject.org/scope/groups",
]

# Select which messaging backend will be used, that could be fedmsg, amq,
# in_memory or rhmsg.
MESSAGING = 'fedmsg'
MESSAGING = "fedmsg"
MESSAGING_BACKENDS = {
'fedmsg': {
'SERVICE': 'freshmaker',
"fedmsg": {
"SERVICE": "freshmaker",
},
'rhmsg': {
"rhmsg": {
# Brokers to connect, e.g.
# ['amqps://host:5671', 'amqps://anotherhost:5671']
'BROKER_URLS': [],
"BROKER_URLS": [],
# Path to certificate file used to authenticate freshmaker
'CERT_FILE': '',
"CERT_FILE": "",
# Path to private key file used to authenticate freshmaker
'KEY_FILE': '',
"KEY_FILE": "",
# Path to trusted CA certificate bundle.
'CA_CERT': '',
'TOPIC_PREFIX': 'VirtualTopic.eng.freshmaker',
"CA_CERT": "",
"TOPIC_PREFIX": "VirtualTopic.eng.freshmaker",
},
"in_memory": {
"SERVICE": "freshmaker",
},
'in_memory': {
'SERVICE': 'freshmaker',
}
}

# repositories that should be searched for unpublished images, specifically because of EUS base images
Expand All @@ -204,9 +203,9 @@ class BaseConfiguration(object):

class DevConfiguration(BaseConfiguration):
DEBUG = True
LOG_LEVEL = 'debug'
LOG_LEVEL = "debug"

MESSAGING_TOPIC_PREFIX = ['org.fedoraproject.dev', 'org.fedoraproject.stg']
MESSAGING_TOPIC_PREFIX = ["org.fedoraproject.dev", "org.fedoraproject.stg"]

# Global network-related values, in seconds
NET_TIMEOUT = 5
Expand All @@ -220,42 +219,42 @@ class DevConfiguration(BaseConfiguration):
# credential. Instead, kinit in default ccache with personal principal
# often.
KRB_AUTH_USE_KEYTAB = False
KRB_AUTH_PRINCIPAL = '' # Should be in form name@REAL
KRB_AUTH_PRINCIPAL = "" # Should be in form name@REAL
# Use the default ccache
KRB_AUTH_CCACHE_FILE = None

AUTH_BACKEND = 'noauth'
AUTH_OPENIDC_USERINFO_URI = 'https://iddev.fedorainfracloud.org/openidc/UserInfo'
AUTH_BACKEND = "noauth"
AUTH_OPENIDC_USERINFO_URI = "https://iddev.fedorainfracloud.org/openidc/UserInfo"


class TestConfiguration(BaseConfiguration):
LOG_LEVEL = 'debug'
LOG_LEVEL = "debug"
DEBUG = True

FRESHMAKER_ROOT_URL = "https://localhost" # Root url of Freshmaker's endpoints

SQLALCHEMY_DATABASE_URI = 'sqlite://'
SQLALCHEMY_DATABASE_URI = "sqlite://"

MESSAGING = 'in_memory'
MESSAGING_SENDER = 'in_memory'
MESSAGING = "in_memory"
MESSAGING_SENDER = "in_memory"

# Global network-related values, in seconds
NET_TIMEOUT = 1
NET_RETRY_INTERVAL = 1

KOJI_CONTAINER_SCRATCH_BUILD = True

LIGHTBLUE_SERVER_URL = '' # replace with real dev server url
LIGHTBLUE_SERVER_URL = "" # replace with real dev server url
LIGHTBLUE_VERIFY_SSL = False

PYXIS_SERVER_URL = 'https://localhost/'
PYXIS_SERVER_URL = "https://localhost/"

# Disable caching for tests
DOGPILE_CACHE_BACKEND = "dogpile.cache.null"

AUTH_BACKEND = 'noauth'
AUTH_LDAP_SERVER = 'ldap://ldap.example.com'
AUTH_LDAP_USER_BASE = 'ou=users,dc=example,dc=com'
AUTH_BACKEND = "noauth"
AUTH_LDAP_SERVER = "ldap://ldap.example.com"
AUTH_LDAP_USER_BASE = "ou=users,dc=example,dc=com"
MAX_THREAD_WORKERS = 1

HANDLER_BUILD_ALLOWLIST = {}
Expand Down
13 changes: 8 additions & 5 deletions contrib/generate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"""


ERRATA_URL = 'https://errata.devel.redhat.com/api/v1/'
FRESHMAKER_URL = 'https://freshmaker.engineering.redhat.com/api/1/'
ERRATA_URL = "https://errata.devel.redhat.com/api/v1/"
FRESHMAKER_URL = "https://freshmaker.engineering.redhat.com/api/1/"


def get_advisory(errata_id):
krb_auth = HTTPKerberosAuth()
r = requests.get(ERRATA_URL + "erratum/%s" % str(errata_id), auth=krb_auth, timeout=conf.requests_timeout)
r = requests.get(
ERRATA_URL + "erratum/%s" % str(errata_id), auth=krb_auth, timeout=conf.requests_timeout
)
r.raise_for_status()
data = r.json()
return data["errata"].values()[0]
Expand All @@ -45,7 +47,7 @@ def get_freshmaker_build(search_key, original_nvr):
return None


if __name__ == '__main__':
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("SEARCH_KEY", help="Freshmaker's search_key")
parser.add_argument("ORIGINAL_NVR", help="Freshmaker's original_nvr")
Expand All @@ -61,7 +63,8 @@ def get_freshmaker_build(search_key, original_nvr):
template_data = {
"freshmaker_date": build["time_completed"].split("T")[0],
"original_nvr": build["original_nvr"],
"freshmaker_brew_build": "https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=%d" % build["build_id"],
"freshmaker_brew_build": "https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=%d"
% build["build_id"],
"rhsa_advisory": "https://errata.devel.redhat.com/advisory/%s" % event["search_key"],
"container_advisory": "https://errata.devel.redhat.com/advisory/%s" % container_advisory,
"container_advisory_date": errata["issue_date"].split("T")[0],
Expand Down
Loading