{"action":"created","comment":{"url":"https://api.github.com/repos/knative/test-infra/pulls/comments/240403159","pull_request_review_id":183424950,"id":240403159,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDQwMzE1OQ==","diff_hunk":"@@ -437,3 +428,59 @@ function lint_markdown() {\n   # https://github.com/markdownlint/markdownlint\n   run_lint_tool mdl \"linting markdown files\" \"-r ~MD013\" $@\n }\n+\n+# Call a function and verify its return value and output.\n+# Parameters: $1 - expected return code.\n+#             $2 - expected output (\"\" if no output is expected)\n+#             $3 ..$n - function to call and its parameters.\n+function test_function() {\n+  local expected_retcode=$1\n+  local expected_string=$2\n+  local output=\"$(mktemp)\"\n+  local output_code=\"$(mktemp)\"\n+  shift 2\n+  echo -n \"$(trap '{ echo $? > ${output_code}; }' EXIT ; \"$@\")\" &> ${output}\n+  local retcode=$(cat ${output_code})\n+  if [[ ${retcode} -ne ${expected_retcode} ]]; then\n+    cat ${output}\n+    echo \"Return code ${retcode} doesn't match expected return code ${expected_retcode}\"\n+    return 1\n+  fi\n+  if [[ -n \"${expected_string}\" ]]; then\n+    local found=1\n+    grep \"${expected_string}\" ${output} > /dev/null || found=0\n+    if (( ! found )); then\n+      cat ${output}\n+      echo \"String '${expected_string}' not found\"\n+      return 1\n+    fi\n+  else\n+    if [[ -s ${output} ]]; then\n+      ls ${output}\n+      cat ${output}\n+      echo \"Unexpected output\"\n+      return 1\n+    fi\n+  fi\n+  echo \"'$@' returns code ${expected_retcode} and displays '${expected_string}'\"\n+}\n+\n+# Mock gcloud function for testing purpose\n+function mock_gcloud_function() {\n+  set -e\n+  function gcloud() {\n+    echo \"\"\n+  }\n+  \"$@\" 2>&1\n+}\n+\n+function check_is_int() {\n+  [[ -n $1 && $1 =~ ^[0-9]+$ ]] && return 0\n+  return 1\n+}\n+\n+# Safety checks, make sure not release/nightly gcr\n+function check_is_protected_gcr() {","path":"scripts/library.sh","position":89,"original_position":89,"commit_id":"1f7fe05f213eafe2c18108bdc8f4c289edc8635b","original_commit_id":"1f7fe05f213eafe2c18108bdc8f4c289edc8635b","user":{"login":"adrcunha","id":35786489,"node_id":"MDQ6VXNlcjM1Nzg2NDg5","avatar_url":"https://avatars3.githubusercontent.com/u/35786489?v=4","gravatar_id":"","url":"https://api.github.com/users/adrcunha","html_url":"https://github.com/adrcunha","followers_url":"https://api.github.com/users/adrcunha/followers","following_url":"https://api.github.com/users/adrcunha/following{/other_user}","gists_url":"https://api.github.com/users/adrcunha/gists{/gist_id}","starred_url":"https://api.github.com/users/adrcunha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrcunha/subscriptions","organizations_url":"https://api.github.com/users/adrcunha/orgs","repos_url":"https://api.github.com/users/adrcunha/repos","events_url":"https://api.github.com/users/adrcunha/events{/privacy}","received_events_url":"https://api.github.com/users/adrcunha/received_events","type":"User","site_admin":false},"body":"Rename to `is_protected_gcr`, it will make it more readable in conditionals.","created_at":"2018-12-10T22:18:47Z","updated_at":"2018-12-10T22:20:57Z","html_url":"https://github.com/knative/test-infra/pull/305#discussion_r240403159","pull_request_url":"https://api.github.com/repos/knative/test-infra/pulls/305","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/knative/test-infra/pulls/comments/240403159"},"html":{"href":"https://github.com/knative/test-infra/pull/305#discussion_r240403159"},"pull_request":{"href":"https://api.github.com/repos/knative/test-infra/pulls/305"}}},"pull_request":{"url":"https://api.github.com/repos/knative/test-infra/pulls/305","id":237420572,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3NDIwNTcy","html_url":"https://github.com/knative/test-infra/pull/305","diff_url":"https://github.com/knative/test-infra/pull/305.diff","patch_url":"https://github.com/knative/test-infra/pull/305.patch","issue_url":"https://api.github.com/repos/knative/test-infra/issues/305","number":305,"state":"open","locked":false,"title":"Periodical Prow job deleting old images","user":{"login":"chaodaiG","id":45011425,"node_id":"MDQ6VXNlcjQ1MDExNDI1","avatar_url":"https://avatars0.githubusercontent.com/u/45011425?v=4","gravatar_id":"","url":"https://api.github.com/users/chaodaiG","html_url":"https://github.com/chaodaiG","followers_url":"https://api.github.com/users/chaodaiG/followers","following_url":"https://api.github.com/users/chaodaiG/following{/other_user}","gists_url":"https://api.github.com/users/chaodaiG/gists{/gist_id}","starred_url":"https://api.github.com/users/chaodaiG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaodaiG/subscriptions","organizations_url":"https://api.github.com/users/chaodaiG/orgs","repos_url":"https://api.github.com/users/chaodaiG/repos","events_url":"https://api.github.com/users/chaodaiG/events{/privacy}","received_events_url":"https://api.github.com/users/chaodaiG/received_events","type":"User","site_admin":false},"body":"Instead of deleting the images in GCR after the test finishes, have a job to perform it from time to time (and only old images).\r\n\r\n- Add `cleanup.sh` script under `tools`\r\n- Add unit testing under `test/unit`\r\n- Add Prow job calling this cleanup script periodically\r\n- Remove `delete_gcr_images` function from common `library.sh`\r\n- Refactor some common functions to library\r\n\r\nAfter this PR, scripts/functions for images deletions will only live under `knative/test-infra` repo, and no jobs other than `cleanup-old-images` job should delete any images.\r\n\r\nFixes https://github.com/knative/test-infra/issues/276\r\n","created_at":"2018-12-10T18:25:22Z","updated_at":"2018-12-10T22:20:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea53edb89b7bced71e3dd33822e8eb8626957240","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jessiezcc","id":37942702,"node_id":"MDQ6VXNlcjM3OTQyNzAy","avatar_url":"https://avatars2.githubusercontent.com/u/37942702?v=4","gravatar_id":"","url":"https://api.github.com/users/jessiezcc","html_url":"https://github.com/jessiezcc","followers_url":"https://api.github.com/users/jessiezcc/followers","following_url":"https://api.github.com/users/jessiezcc/following{/other_user}","gists_url":"https://api.github.com/users/jessiezcc/gists{/gist_id}","starred_url":"https://api.github.com/users/jessiezcc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessiezcc/subscriptions","organizations_url":"https://api.github.com/users/jessiezcc/orgs","repos_url":"https://api.github.com/users/jessiezcc/repos","events_url":"https://api.github.com/users/jessiezcc/events{/privacy}","received_events_url":"https://api.github.com/users/jessiezcc/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":993222917,"node_id":"MDU6TGFiZWw5OTMyMjI5MTc=","url":"https://api.github.com/repos/knative/test-infra/labels/size/L","name":"size/L","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/knative/test-infra/pulls/305/commits","review_comments_url":"https://api.github.com/repos/knative/test-infra/pulls/305/comments","review_comment_url":"https://api.github.com/repos/knative/test-infra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/knative/test-infra/issues/305/comments","statuses_url":"https://api.github.com/repos/knative/test-infra/statuses/1f7fe05f213eafe2c18108bdc8f4c289edc8635b","head":{"label":"chaodaiG:chaodai_delete_old_image_by_project","ref":"chaodai_delete_old_image_by_project","sha":"1f7fe05f213eafe2c18108bdc8f4c289edc8635b","user":{"login":"chaodaiG","id":45011425,"node_id":"MDQ6VXNlcjQ1MDExNDI1","avatar_url":"https://avatars0.githubusercontent.com/u/45011425?v=4","gravatar_id":"","url":"https://api.github.com/users/chaodaiG","html_url":"https://github.com/chaodaiG","followers_url":"https://api.github.com/users/chaodaiG/followers","following_url":"https://api.github.com/users/chaodaiG/following{/other_user}","gists_url":"https://api.github.com/users/chaodaiG/gists{/gist_id}","starred_url":"https://api.github.com/users/chaodaiG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaodaiG/subscriptions","organizations_url":"https://api.github.com/users/chaodaiG/orgs","repos_url":"https://api.github.com/users/chaodaiG/repos","events_url":"https://api.github.com/users/chaodaiG/events{/privacy}","received_events_url":"https://api.github.com/users/chaodaiG/received_events","type":"User","site_admin":false},"repo":{"id":159388501,"node_id":"MDEwOlJlcG9zaXRvcnkxNTkzODg1MDE=","name":"test-infra","full_name":"chaodaiG/test-infra","private":false,"owner":{"login":"chaodaiG","id":45011425,"node_id":"MDQ6VXNlcjQ1MDExNDI1","avatar_url":"https://avatars0.githubusercontent.com/u/45011425?v=4","gravatar_id":"","url":"https://api.github.com/users/chaodaiG","html_url":"https://github.com/chaodaiG","followers_url":"https://api.github.com/users/chaodaiG/followers","following_url":"https://api.github.com/users/chaodaiG/following{/other_user}","gists_url":"https://api.github.com/users/chaodaiG/gists{/gist_id}","starred_url":"https://api.github.com/users/chaodaiG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaodaiG/subscriptions","organizations_url":"https://api.github.com/users/chaodaiG/orgs","repos_url":"https://api.github.com/users/chaodaiG/repos","events_url":"https://api.github.com/users/chaodaiG/events{/privacy}","received_events_url":"https://api.github.com/users/chaodaiG/received_events","type":"User","site_admin":false},"html_url":"https://github.com/chaodaiG/test-infra","description":"Test infrastructure for the Knative project.","fork":true,"url":"https://api.github.com/repos/chaodaiG/test-infra","forks_url":"https://api.github.com/repos/chaodaiG/test-infra/forks","keys_url":"https://api.github.com/repos/chaodaiG/test-infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chaodaiG/test-infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chaodaiG/test-infra/teams","hooks_url":"https://api.github.com/repos/chaodaiG/test-infra/hooks","issue_events_url":"https://api.github.com/repos/chaodaiG/test-infra/issues/events{/number}","events_url":"https://api.github.com/repos/chaodaiG/test-infra/events","assignees_url":"https://api.github.com/repos/chaodaiG/test-infra/assignees{/user}","branches_url":"https://api.github.com/repos/chaodaiG/test-infra/branches{/branch}","tags_url":"https://api.github.com/repos/chaodaiG/test-infra/tags","blobs_url":"https://api.github.com/repos/chaodaiG/test-infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chaodaiG/test-infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chaodaiG/test-infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/chaodaiG/test-infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chaodaiG/test-infra/statuses/{sha}","languages_url":"https://api.github.com/repos/chaodaiG/test-infra/languages","stargazers_url":"https://api.github.com/repos/chaodaiG/test-infra/stargazers","contributors_url":"https://api.github.com/repos/chaodaiG/test-infra/contributors","subscribers_url":"https://api.github.com/repos/chaodaiG/test-infra/subscribers","subscription_url":"https://api.github.com/repos/chaodaiG/test-infra/subscription","commits_url":"https://api.github.com/repos/chaodaiG/test-infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/chaodaiG/test-infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/chaodaiG/test-infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/chaodaiG/test-infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/chaodaiG/test-infra/contents/{+path}","compare_url":"https://api.github.com/repos/chaodaiG/test-infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chaodaiG/test-infra/merges","archive_url":"https://api.github.com/repos/chaodaiG/test-infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chaodaiG/test-infra/downloads","issues_url":"https://api.github.com/repos/chaodaiG/test-infra/issues{/number}","pulls_url":"https://api.github.com/repos/chaodaiG/test-infra/pulls{/number}","milestones_url":"https://api.github.com/repos/chaodaiG/test-infra/milestones{/number}","notifications_url":"https://api.github.com/repos/chaodaiG/test-infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chaodaiG/test-infra/labels{/name}","releases_url":"https://api.github.com/repos/chaodaiG/test-infra/releases{/id}","deployments_url":"https://api.github.com/repos/chaodaiG/test-infra/deployments","created_at":"2018-11-27T19:31:52Z","updated_at":"2018-11-27T19:31:54Z","pushed_at":"2018-12-10T22:20:57Z","git_url":"git://github.com/chaodaiG/test-infra.git","ssh_url":"git@github.com:chaodaiG/test-infra.git","clone_url":"https://github.com/chaodaiG/test-infra.git","svn_url":"https://github.com/chaodaiG/test-infra","homepage":null,"size":9703,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"knative:master","ref":"master","sha":"95a6bc7f94a9a0a1ecfc3906a657edeaaf063eff","user":{"login":"knative","id":35583233,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NTgzMjMz","avatar_url":"https://avatars2.githubusercontent.com/u/35583233?v=4","gravatar_id":"","url":"https://api.github.com/users/knative","html_url":"https://github.com/knative","followers_url":"https://api.github.com/users/knative/followers","following_url":"https://api.github.com/users/knative/following{/other_user}","gists_url":"https://api.github.com/users/knative/gists{/gist_id}","starred_url":"https://api.github.com/users/knative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knative/subscriptions","organizations_url":"https://api.github.com/users/knative/orgs","repos_url":"https://api.github.com/users/knative/repos","events_url":"https://api.github.com/users/knative/events{/privacy}","received_events_url":"https://api.github.com/users/knative/received_events","type":"Organization","site_admin":false},"repo":{"id":136082371,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYwODIzNzE=","name":"test-infra","full_name":"knative/test-infra","private":false,"owner":{"login":"knative","id":35583233,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NTgzMjMz","avatar_url":"https://avatars2.githubusercontent.com/u/35583233?v=4","gravatar_id":"","url":"https://api.github.com/users/knative","html_url":"https://github.com/knative","followers_url":"https://api.github.com/users/knative/followers","following_url":"https://api.github.com/users/knative/following{/other_user}","gists_url":"https://api.github.com/users/knative/gists{/gist_id}","starred_url":"https://api.github.com/users/knative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knative/subscriptions","organizations_url":"https://api.github.com/users/knative/orgs","repos_url":"https://api.github.com/users/knative/repos","events_url":"https://api.github.com/users/knative/events{/privacy}","received_events_url":"https://api.github.com/users/knative/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/knative/test-infra","description":"Test infrastructure for the Knative project.","fork":false,"url":"https://api.github.com/repos/knative/test-infra","forks_url":"https://api.github.com/repos/knative/test-infra/forks","keys_url":"https://api.github.com/repos/knative/test-infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/knative/test-infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/knative/test-infra/teams","hooks_url":"https://api.github.com/repos/knative/test-infra/hooks","issue_events_url":"https://api.github.com/repos/knative/test-infra/issues/events{/number}","events_url":"https://api.github.com/repos/knative/test-infra/events","assignees_url":"https://api.github.com/repos/knative/test-infra/assignees{/user}","branches_url":"https://api.github.com/repos/knative/test-infra/branches{/branch}","tags_url":"https://api.github.com/repos/knative/test-infra/tags","blobs_url":"https://api.github.com/repos/knative/test-infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/knative/test-infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/knative/test-infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/knative/test-infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/knative/test-infra/statuses/{sha}","languages_url":"https://api.github.com/repos/knative/test-infra/languages","stargazers_url":"https://api.github.com/repos/knative/test-infra/stargazers","contributors_url":"https://api.github.com/repos/knative/test-infra/contributors","subscribers_url":"https://api.github.com/repos/knative/test-infra/subscribers","subscription_url":"https://api.github.com/repos/knative/test-infra/subscription","commits_url":"https://api.github.com/repos/knative/test-infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/knative/test-infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/knative/test-infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/knative/test-infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/knative/test-infra/contents/{+path}","compare_url":"https://api.github.com/repos/knative/test-infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/knative/test-infra/merges","archive_url":"https://api.github.com/repos/knative/test-infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/knative/test-infra/downloads","issues_url":"https://api.github.com/repos/knative/test-infra/issues{/number}","pulls_url":"https://api.github.com/repos/knative/test-infra/pulls{/number}","milestones_url":"https://api.github.com/repos/knative/test-infra/milestones{/number}","notifications_url":"https://api.github.com/repos/knative/test-infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/knative/test-infra/labels{/name}","releases_url":"https://api.github.com/repos/knative/test-infra/releases{/id}","deployments_url":"https://api.github.com/repos/knative/test-infra/deployments","created_at":"2018-06-04T21:01:06Z","updated_at":"2018-12-10T21:43:19Z","pushed_at":"2018-12-10T21:43:17Z","git_url":"git://github.com/knative/test-infra.git","ssh_url":"git@github.com:knative/test-infra.git","clone_url":"https://github.com/knative/test-infra.git","svn_url":"https://github.com/knative/test-infra","homepage":null,"size":9795,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":null,"archived":false,"open_issues_count":39,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":26,"open_issues":39,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/knative/test-infra/pulls/305"},"html":{"href":"https://github.com/knative/test-infra/pull/305"},"issue":{"href":"https://api.github.com/repos/knative/test-infra/issues/305"},"comments":{"href":"https://api.github.com/repos/knative/test-infra/issues/305/comments"},"review_comments":{"href":"https://api.github.com/repos/knative/test-infra/pulls/305/comments"},"review_comment":{"href":"https://api.github.com/repos/knative/test-infra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/knative/test-infra/pulls/305/commits"},"statuses":{"href":"https://api.github.com/repos/knative/test-infra/statuses/1f7fe05f213eafe2c18108bdc8f4c289edc8635b"}},"author_association":"NONE"}}
{"actor":{"display_login":"adrcunha"}}