Skip to content

Commit 72ca93e

Browse files
authored
Merge branch 'main' into copilot/fix-3bf3311a-03bb-4bd6-8f32-de5183b1ebf1
2 parents 7c88ca1 + 3c0f265 commit 72ca93e

File tree

55 files changed

+1540
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1540
-93
lines changed

.github/workflows/releast-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
python3 configure.py --hostname api.github.com \
2121
--enterprise-name gm3dmo-enterprise-cloud-testing \
2222
--org forest-town \
23-
--repo-name pwr-release1 \
23+
--repo pwr-release1 \
2424
--default-repo-visibility public \
2525
--token ${{ secrets.FORESTPAT }} \
26-
--webhook-url ${{ vars.WEBHOOK }} \
26+
--repo-webhook-url ${{ vars.WEBHOOK }} \
2727
--app-configure yes \
2828
--app-id 1 \
2929
--app-installation-id 1 \

.github/workflows/the-power.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ jobs:
2323
with:
2424
python-version: 3.9
2525

26-
- name: run configure script
26+
- name: run the power configure.py script
2727
run: |
2828
python3 configure.py --hostname api.github.com \
2929
--enterprise-name enterprise-example \
30+
--token ghp_mrsMigginsPIEShopmAWV6tyRZxwbwk0JAI94 \
3031
--org org-example \
3132
--repo testrepo \
32-
--token ghp_mrsMigginsRfGYNzymAWV6tyRZxwbwk0JAI94 \
33-
--webhook-url https://example.com/webhook \
33+
--repo-webhook-url https://example.com/webhook \
3434
--app-configure yes \
3535
--app-id 1 \
3636
--app-installation-id 1 \

add-assignees-to-an-issue.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
. ./.gh-api-examples.conf
2+
3+
# https://docs.github.com/en/enterprise-cloud@latest/rest/issues/assignees?apiVersion=2022-11-28#add-assignees-to-an-issue
4+
# POST /repos/{owner}/{repo}/issues/{issue_number}/assignees
5+
6+
7+
# If the script is passed an argument $1 use that as the name
8+
if [ -z "$1" ]
9+
then
10+
user_to_assign=$pr_approver_name
11+
else
12+
user_to_assign=$1
13+
fi
14+
15+
16+
issue_number=${default_issue_id}
17+
18+
json_file=tmp/add-assignees-to-an-issue.json
19+
20+
jq -n \
21+
--arg user_to_assign "${user_to_assign}" \
22+
'{
23+
assignees: $user_to_assign,
24+
}' > ${json_file}
25+
26+
27+
28+
curl ${curl_custom_flags} \
29+
-H "X-GitHub-Api-Version: ${github_api_version}" \
30+
-H "Accept: application/vnd.github.v3+json" \
31+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
32+
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/issues/${issue_number}/assignees" --data @${json_file}
33+

build-testcase

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ printf "${normal}"
2727
printf "${highlight} - Creating docs/README.md: ${normal}"
2828
./create-commit-readme.sh | jq -r ".content.html_url"
2929

30-
printf "${highlight} - Creating simple workflow file: ${normal}"
31-
./create-commit-workflow-simple.sh | jq -r ".content.html_url"
30+
printf "${highlight} - Creating workflow file: ${normal}"
31+
./create-commit-workflow-pwr.sh | jq -r ".content.html_url"
3232

3333
printf "${highlight} - Creating CODEOWNERS: ${normal}"
3434
./create-commit-codeowners.sh| jq -r ".content.html_url"

build-testcase-shai-hulud

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
normal=$(tput sgr0)
2+
highlight=$(tput setaf 2)
3+
4+
printf "$highlight"
5+
6+
cat << EOF
7+
8+
________ ____
9+
/_ __/ /_ ___ / __ \____ _ _____ _____
10+
/ / / __ \/ _ \ / /_/ / __ \ | /| / / _ \/ ___/
11+
/ / / / / / __/ / ____/ /_/ / |/ |/ / __/ /
12+
/_/ /_/ /_/\___/ /_/ \____/|__/|__/\___/_/
13+
14+
EOF
15+
16+
printf "${normal}"
17+
18+
printf "${highlight} - Creating repo: ${normal}"
19+
./create-repo-testrepo.sh | jq -r '.name'
20+
21+
printf "${highlight} - Adding team to repo (team_slug must be set in your .gh-api-examples.conf file)${normal}\n"
22+
./add-team-to-repo.sh
23+
24+
printf "${highlight} - Creating webhook: ${normal}"
25+
./create-webhook.sh | jq -r '.id'
26+
27+
printf "${highlight} - Creating docs/README.md: ${normal}"
28+
./create-commit-readme.sh | jq -r ".content.html_url"
29+
30+
printf "${highlight} - Creating simple workflow file: ${normal}"
31+
./create-commit-workflow-simple.sh | jq -r ".content.html_url"
32+
33+
printf "${highlight} - Creating CODEOWNERS: ${normal}"
34+
./create-commit-codeowners.sh| jq -r ".content.html_url"
35+
36+
printf "${highlight} - Creating shai-hulud vulnerable package.json: ${normal}"
37+
./create-commit-security-shai-hulud-package-json.sh | jq -r ".content.html_url"
38+
sleep 2
39+
40+
printf "${highlight} - Creating new branch: ${normal}"
41+
./create-branch-newbranch.sh | jq -r '.url'
42+
43+
printf "${highlight} - Creating a commit on the new branch: ${normal}"
44+
./create-commit-on-new-branch.sh | jq -r ".content.html_url"
45+
46+
printf "${highlight} - Creating an update commit to docs/README.md: ${normal}"
47+
./create-commit-update-readme.sh | jq -r ".content.html_url"
48+
49+
printf "${highlight} - Creating an issue: ${normal}"
50+
./create-repo-issue.sh | jq -r '.html_url'
51+
52+
printf "${highlight} - Creating a pull request: ${normal}"
53+
./create-pull-request.sh | jq -r '.html_url'
54+
55+
printf "${highlight} - Setting branch protection rules on default branch: ${normal}"
56+
./set-branch-protection.sh | jq -r '.url'
57+
58+
printf "${highlight} - Creating a release: ${normal}"
59+
./create-release.sh | jq -r '.html_url'
60+
61+
printf "${highlight} - Adding a .gitattributes file to new branch: ${normal}"
62+
./create-commit-gitattributes.sh | jq -r ".content.html_url"
63+
echo
64+
65+
66+
# If you have the appropriate token set in `pr_approver_token`
67+
# then you can provide an approving review:
68+
# ./create-approving-review-for-a-pull-request.sh

build-testcase-with-commit-status

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ printf "${normal}"
2828
./add-team-to-repo.sh
2929
printf "${highlight} - Creating docs/README: ${normal}"
3030
./create-commit-readme.sh | jq -r ".content.html_url"
31+
32+
printf "${highlight} - Creating workflow file: ${normal}"
33+
./create-commit-workflow-pwr.sh | jq -r ".content.html_url"
34+
3135
printf "${highlight} - Creating CODEOWNERS: ${normal}"
3236
./create-commit-codeowners.sh| jq -r ".content.html_url"
3337
sleep 2
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Create a repository and setup a simple workflow
2+
# Prior to running this, make any needed modifications to test-data/workflow-simple.yml_
3+
# that are needed for the testcase.
4+
# The "as delivered" version of workflow-simple.yml_ will trigger the workflow
5+
# with dispatch event
6+
#
7+
8+
normal=$(tput sgr0)
9+
highlight=$(tput setaf 2)
10+
yellow=$(tput setaf 3)
11+
12+
printf "$highlight"
13+
14+
cat << EOF
15+
16+
________ ____
17+
/_ __/ /_ ___ / __ \____ _ _____ _____
18+
/ / / __ \/ _ \ / /_/ / __ \ | /| / / _ \/ ___/
19+
/ / / / / / __/ / ____/ /_/ / |/ |/ / __/ /
20+
/_/ /_/ /_/\___/ /_/ \____/|__/|__/\___/_/
21+
22+
==================================================
23+
$0
24+
==================================================
25+
26+
EOF
27+
28+
printf "${normal}"
29+
30+
printf "${highlight} - Creating repo: ${normal}"
31+
./create-repo.sh | jq -r '.name'
32+
33+
printf "${highlight} - Creating webhook: ${normal}"
34+
./create-webhook.sh | jq -r '.id'
35+
36+
printf "${highlight} - Creating docs/README.md: ${normal}"
37+
./create-commit-readme.sh | jq -r ".content.html_url"
38+
39+
printf "${highlight} - Creating new_branch: ${normal}"
40+
./create-branch-newbranch.sh | jq -r '.url'
41+
42+
# order is important here the workflow file must be created
43+
printf "${highlight} - Committing workflow file: ${normal}"
44+
./create-commit-workflow-merge-queue-demo.sh | jq -r '.content.path'
45+
46+
printf "${highlight} - Creating repository branch ruleset: ${normal}"
47+
./create-a-repository-ruleset-branch-pattern-merge-queue.sh | jq -r '.name'
48+
49+
50+
printf "${highlight} - Creating a commit on the new branch: ${normal}"
51+
./create-commit-on-new-branch.sh | jq -r ".content.html_url"
52+
53+
printf "${highlight} - Creating an update commit to docs/README.md: ${normal}"
54+
./create-commit-update-readme.sh | jq -r ".content.html_url"
55+
56+
printf "${highlight} - Creating an issue: ${normal}"
57+
./create-repo-issue.sh | jq -r '.html_url'
58+
59+
printf "${highlight} - Creating a pull request: ${normal}"
60+
./create-pull-request.sh | jq -r '.html_url'
61+

configure.py

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ def main(args):
8383
ssl_verify=true
8484
8585
86+
### GitHub Enterprise Teams
87+
enterprise_team_name="enterprise-team1"
88+
8689
### GitHub API Version
8790
# https://docs.github.com/en/rest/overview/api-versions
8891
github_api_version=${github_api_version}
@@ -91,6 +94,7 @@ def main(args):
9194
# https://docs.github.com/en/organizations
9295
org="${org}"
9396
owner="${org}"
97+
org_webhook_url=${org_webhook_url}
9498
org_secret_name="PWR_ORG_SECRET_001"
9599
org_owner="${org_owner}"
96100
org_members="${org_members}"
@@ -107,7 +111,7 @@ def main(args):
107111
repo_secret_name="REPOSITORY_SECRET_001"
108112
repo_secret_value="repository_secret_string"
109113
# webhook url is also used by the organization
110-
webhook_url=${webhook_url}
114+
repo_webhook_url=${repo_webhook_url}
111115
repo_webhook_secret="pwr-repo-webhook-secret"
112116
has_issues=true
113117
has_wiki=true
@@ -238,6 +242,7 @@ def main(args):
238242
ent_app_client_secret=${ent_app_client_secret}
239243
ent_app_private_pem=${ent_app_private_pem}
240244
ent_app_installation_id=${ent_app_installation_id}
245+
ent_app_org_installation_id=${ent_app_org_installation_id}
241246
242247
243248
### [GitHub Apps](https://docs.github.com/en/rest/apps)
@@ -254,6 +259,7 @@ def main(args):
254259
# private_pem_file=/opt/the-power/testapp.YYYY-MM-DD.private-key.pem
255260
# #=> The absolute path of the pem file is /opt/the-power/Downloads/testapp.YYYY-MM-DD.private-key.pem
256261
#
262+
app_configure=${app_configure}
257263
app_private_pem=${app_private_pem}
258264
# When working with the power in a codespace you may need a path like:
259265
#private_pem_file=../../workspaces/the-power/ft-testapp.2022-03-23.private-key.pem
@@ -426,7 +432,7 @@ def main(args):
426432
args.org = input(f"Enter Org name: ")
427433

428434
# If configuring a GitHub App:
429-
if args.configure_github_app != "no":
435+
if args.app_configure != "no":
430436
if args.app_id != "":
431437
logger.info(f"default_app_id = {args.app_id}")
432438
else:
@@ -453,22 +459,22 @@ def main(args):
453459
f"Enter path relative from home to app private key: "
454460
)
455461

456-
if args.webhook_url == "smee":
457-
webhook_url = thepower.get_webhook_url()
458-
if webhook_url is None:
459-
webhook_url = input(f"Enter webhook URL: ")
462+
if args.repo_webhook_url == "smee":
463+
repo_webhook_url = thepower.get_webhook_url()
464+
if repo_webhook_url is None:
465+
repo_webhook_url = input(f"Enter webhook URL: ")
460466

461-
args.webhook_url = webhook_url
462-
if re.match(r"^https?://", args.webhook_url):
463-
thepower.open_webhook_url_in_browser(args.webhook_url)
467+
args.repo_webhook_url = repo_webhook_url
468+
if re.match(r"^https?://", args.repo_webhook_url):
469+
thepower.open_webhook_url_in_browser(args.repo_webhook_url, anon=True)
464470
else:
465471
logger.info(
466472
"No webhook URL supplied. You can still set a webhook URL in .gh-api-examples.conf file."
467473
)
468-
elif args.webhook_url:
469-
logger.info(f"Webhook URL = {args.webhook_url}")
474+
elif args.repo_webhook_url:
475+
logger.info(f"Webhook URL = {args.repo_webhook_url}")
470476
else:
471-
args.webhook_url = input(f"Enter webhook url: ")
477+
args.repo_webhook_url = input(f"Enter webhook url: ")
472478

473479
out_filename = ".gh-api-examples.conf"
474480

@@ -503,7 +509,7 @@ def main(args):
503509
parser.add_argument(
504510
"--app-configure",
505511
action="store",
506-
dest="configure_github_app",
512+
dest="app_configure",
507513
default="no",
508514
)
509515
parser.add_argument(
@@ -517,7 +523,7 @@ def main(args):
517523
action="store",
518524
dest="app_id",
519525
default="1",
520-
help="an app id (integer)",
526+
help="an app id" ,
521527
)
522528
parser.add_argument(
523529
"--app-installation-id",
@@ -562,12 +568,18 @@ def main(args):
562568
"--mgmt-port", action="store", dest="mgmt_port", default=8443
563569
)
564570
parser.add_argument(
565-
"-w",
566-
"--webhook-url",
571+
"--repo-webhook-url",
567572
action="store",
568-
dest="webhook_url",
573+
dest="repo_webhook_url",
569574
default="smee",
570-
help="Set this if you want to provide your own webhook url.",
575+
help="Set this if you want to provide your own webhook url for a repository.",
576+
)
577+
parser.add_argument(
578+
"--org_webhook-url",
579+
action="store",
580+
dest="org_webhook_url",
581+
default="https://example.com/webhook",
582+
help="Set this if you want to provide your own webhook url for a repository.",
571583
)
572584
parser.add_argument(
573585
"--x-client-id",
@@ -620,8 +632,7 @@ def main(args):
620632
help="Set this for github.com config",
621633
)
622634
parser.add_argument(
623-
"-r",
624-
"--repo-name",
635+
"--repo",
625636
action="store",
626637
dest="repo_name",
627638
default="testrepo",
@@ -678,6 +689,13 @@ def main(args):
678689
default="0",
679690
help="",
680691
)
692+
parser.add_argument(
693+
"--enterprise-app-org-installation-id",
694+
action="store",
695+
dest="ent_app_org_installation_id",
696+
default="0",
697+
help="enterprise app org installation id",
698+
)
681699
parser.add_argument(
682700
"--enterprise-app-id",
683701
action="store",
@@ -706,7 +724,6 @@ def main(args):
706724
default="ent_app_client_secret",
707725
help="An enterprise app client secret.",
708726
)
709-
710727
parser.add_argument(
711728
"--number-of-orgs",
712729
action="store",

0 commit comments

Comments
 (0)