Checks Package¶
Authenticator¶
-
class
checks.Authenticator(pem, git_app_id)¶ Bases:
objectAuthenticator class: creates, stores and updates JWT and INSTALLATION tokens for use in the Github App API calls
- Parameters
pem – .pem certificate file name
git_app_id – Github App ID for API calls
-
INSTALL_EXP_THRESHOLD= 2¶
-
JWT_EXP_THRESHOLD= 2¶
-
_checkInstallToken()¶ Checks Install token for expiry date and creates new one if necessary
-
_checkJWT()¶ Checks if the passed JWT is still current and either returns the old one or creates and returns a new one
-
_newInstallToken()¶ Generates new Install Token valid for an hour to auth API requests
-
_newJWT()¶ Creates new JWT for authentication based on private key and GIT APP ID
-
getToken()¶ Check expiry date of existing install token and create new one if needed, returns valid token.
-
getTokenHeader()¶ Returns fully formed header with valid installation token
-
updateInstallID(id)¶ Update Installation ID of Github App to be used for auth (usually send with webhook)
CheckFlow¶
-
class
checks.CheckFlow(initRepo=True)¶ Bases:
object-
AUTOPAS= '../../AutoPas'¶
-
DB= 'database.config'¶
-
GIT_APP_ID= '-1'¶
-
PEM= 'private-key.pem'¶
-
PERF_THRESHOLD= 0.9¶
-
_checkCommits(url)¶ Gets list of pull request commits and runs checks :param url: url to receive commits from :return: if worker is needed
-
_compareConfigs(base: mongoDocuments.Config.Config, test: mongoDocuments.Config.Config)¶ Given two configs, find all overlapping results and compare them
- Parameters
base – PR Base SHA config
test – Commit in PR to compare to base
- Returns
-
static
_compareResults(base: mongoDocuments.Result.Result, test: mongoDocuments.Result.Result)¶ Compare invididual matching results
- Parameters
base –
test –
- Returns
Speedups
-
_createCheckRun(sha, name)¶
-
_getBranchHead(baseBranch: str) → str¶ Running git command in AutoPas Repo to find head of branch
- Parameters
baseBranch – name of base branch, e.g. master
- Returns
HEAD sha on baseBranch
- Return type
str
-
_getCommitSHAsFromURL(url)¶ Get the commit SHAs from a base url. This will get all commits from a PR using pagination.
-
_getForkPoint(baseBranch: str, branchRef: str) → str¶ Running git command in AutoPas Repo to find fork point of branch.
- Parameters
baseBranch – name of base branch, e.g. master
branchRef – SHA on feature branch or ref (e.g. origin/feature)
- Returns
fork point sha on baseBranch
- Return type
str
-
_getLastCommonRef(baseRef: str, branchRef: str) → str¶ Running git command in AutoPas Repo to find last common ref. This usually is the last time origin/master was merged into the feature branch.
- Parameters
baseRef – SHA on base branch or ref (e.g. origin/master)
branchRef – SHA on feature branch or ref
- Returns
last common ref
- Return type
str
-
comparePerformance(q: mongoDocuments.QueueObject.QueueObject)¶ Function to compare performance between different commits in the Repo.
Works on a checkrun already created via the GitHub checks api at compareUrl. Comparison options include:
1a) Merge Current Master Head into branch and compare performance between merged and un-merged master 1b) Merge failed -> Compare between non-merged feature branch and master 2) To Be Implemented (perf already available): Compare against the Fork Point 3) To Be Implemented (perf already available): Compare against the Last Common commit between master and feature branch
- Parameters
q – QueueObject containing all necessary information to run comparison
Returns:
-
receiveHook(request)¶ on receive of pull_request event
-
runCheck(q: mongoDocuments.QueueObject.QueueObject)¶
-
Commit¶
-
class
checks.Commit(repo: git.repo.base.Repo, sha: str, baseSHA: str = None)¶ Bases:
object-
baseDir= ''¶
-
build()¶
-
buildDir= 'perfBuild'¶
-
generatePlot()¶ Quick overview plot for commit :return:
-
mdFlexDir= ''¶
-
measure(setup: mongoDocuments.Setup.Setup)¶
-
measureCheckpoint(checkpoint: mongoDocuments.Checkpoint.Checkpoint, setup: mongoDocuments.Setup.Setup = None)¶
-
parse_and_upload()¶
-
save_failed_config(failure: str)¶ Saving failed configs to not re-run them again :param failure: Failure Mode :return:
-
updateStatus(code, header, message, image=None)¶
-
ImgurUploader¶
Repository¶
-
class
checks.Repository(gitPath, branch='origin/master')¶ Bases:
object-
_testCommit(c: checks.Commit.Commit, customJob: mongoDocuments.QueueObject.QueueObject = None, plotting: bool = True)¶ test the commit and return status and images :param c: Commit to test :param case: [‘Setup’, ‘Checkpoint’] switch to use clean setups or checkpoints with their attached setups :param plotting: bool if plotting to imgur is needed
Returns:
-
checkoutBranch(branch)¶
-
fetchAll()¶ Fetching for all remote branches
Returns:
-
testLast(last)¶
-
testMerge(baseSHA, branchSHA)¶ Trying a merge of base into branch
- Parameters
baseSHA – from e.g. origin/master
branchSHA – from e.g. origin/feature
Returns:
-
testNewest()¶
-
testSHA(sha)¶
-