Skip to content

Instantly share code, notes, and snippets.

import hmac
import logging
from rest_framework.viewsets import ViewSet
from rest_framework.parsers import JSONParser
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK, HTTP_500_INTERNAL_SERVER_ERROR, HTTP_403_FORBIDDEN, HTTP_400_BAD_REQUEST
from ..RepositoryClient import RepositoryClient
from ..PerformanceGuardBot import PerformanceGuardBot
import logging
from abc import ABCMeta, abstractmethod, abstractproperty
# This is a string that is the name of the status context that is updated
# when the CI pipeline completes
from .constants import CI_STATUS_CONTEXT #'continuous-integration/jenkins/pr-merge'
logger = logging.getLogger()
# Github API keywords used to define the check's conclusion
import time
import requests
from github3 import GitHub
from jwt import JWT, jwk_from_pem
import logging
from .constants import REPO_OWNER, REPO_NAME, GITHUB_BASE_URL
logger = logging.getLogger()
@bialesdaniel
bialesdaniel / constants.py
Last active February 11, 2021 22:02
Constants file for a Django app that creates Github Checks for PRs
import os
# GitHub Integration
GITHUB_APP_ID = 12345 # This value can be found on your GitHub App overview page
# My secrets are environment variables
# The webhook secret you chose for the GitHub App
GITHUB_APP_WEBHOOK_SECRET = os.environ.get('GITHUB_APP_WEBHOOK_SECRET')
# The private key that was generated when you created the GitHub App
#########################################################################
# From oltpbench/reporting/parsers/summary_parser.py
from oltpbench.reporting.utils import get_value_by_pattern
from oltpbench.reporting.constants import LATENCY_ATTRIBUTE_MAPPING
# NOTE: What we wanted to do was to reuse this function to parse the latency data
# from the res file as well.
def parse_latency_data(latency_dict):
"""
@bialesdaniel
bialesdaniel / isCycle.js
Created October 10, 2018 18:50
Check if an array is a cycle where each value references how far away the next value is. A cycle must touch every value and end where it starts.
function isCycle(arr){
let i = 0
let itemsToTouch = arr.length
while(arr[i]!==0){
itemsToTouch--
const val = arr[i]
arr[i]=0
if(i +val >=arr.length){
i = (i + val) % arr.length
}else if(i+val <0){