-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from DSACMS/dev
Merge Dev Into Main
- Loading branch information
Showing
23 changed files
with
511 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tier1/{{cookiecutter.project_slug}}/repometrics/cookiecutter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"project_type" : ["Package", "Website", "Standards", "Libraries", "Data", "Apps", "Tools", "APIs"], | ||
"user_input": ["Yes", "No"], | ||
"project_fisma_level": ["Low", "Moderate", "High"], | ||
"group": "CMS/OA/DSAC", | ||
"subset_in_healthcare": "Policy, Operational", | ||
"user_type": "Providers, Patients, Government", | ||
"repository_host": ["Github.com", "GitHub ENT", "GitHub Cloud", "GitLab.com", "GitLab ENT", "GitLab ENT CCSQ"], | ||
"maturity_model_tier": ["1", "2", "3", "4"], | ||
"__prompts__": { | ||
"group": "Which group is the project part of?", | ||
"subset_in_healthcare": "Which subset of healthcare does the project belong to?", | ||
"user_type": "Who are the intended users?", | ||
"user_input": "Does the project accept user input? (e.g. allows user to query a database, allows login by users, etc.)", | ||
"repository_host": "Where is the repository hosted?", | ||
"maturity_model_tier": "What maturity model tier is your project classified as?" | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tier1/{{cookiecutter.project_slug}}/repometrics/hooks/post_gen_project.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# Change to the parent directory | ||
cd .. | ||
|
||
# Define the repometrics directory to remove | ||
dir_name="repometrics" | ||
|
||
# Check if repometrics directory exists and remove it | ||
if [ -d "$dir_name" ]; then | ||
rm -rf "$dir_name" | ||
fi | ||
|
||
project_type="{{cookiecutter.project_type}}" | ||
sub_project_dir="${project_type}" | ||
repometrics_file="code.json" | ||
parent_dir="./" | ||
|
||
if [ -f "${sub_project_dir}/${repometrics_file}" ]; then | ||
# Move code.json file to parent directory | ||
mv "${sub_project_dir}/${repometrics_file}" "${parent_dir}" | ||
|
||
# Check if the move was successful | ||
if [ $? -eq 0 ]; then | ||
# Remove the source directory | ||
rm -rf "${sub_project_dir}" | ||
|
||
# Check if the deletion was successful | ||
if [ $? -eq 0 ]; then | ||
echo "Successfully generated code.json file." | ||
fi | ||
fi | ||
fi |
10 changes: 10 additions & 0 deletions
10
tier1/{{cookiecutter.project_slug}}/repometrics/{{cookiecutter.project_type}}/code.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"project_type": "{{ cookiecutter.project_type }}", | ||
"user_input": "{{ cookiecutter.user_input }}", | ||
"project_fisma_level": "{{ cookiecutter.project_fisma_level }}", | ||
"group": "{{ cookiecutter.group }}", | ||
"subset_in_healthcare": "{{ cookiecutter.subset_in_healthcare }}", | ||
"user_type": "{{ cookiecutter.user_type }}", | ||
"repository_host": "{{ cookiecutter.repository_host }}", | ||
"maturity_model_tier": "{{ cookiecutter.maturity_model_tier }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
{ | ||
"project_name": "My Project", | ||
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}", | ||
"project_org": "DSACMS", | ||
"project_repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", | ||
"project_description": "This is the project description, could match github.com repo description.", | ||
"code_owners": "Git usernames of code owners; separated by commas.", | ||
"project_visibility": ["public", "internal", "private"], | ||
"create_repo": [true, false], | ||
"receive_updates": [true, false], | ||
"__prompts__": { | ||
"create_repo": "Would you like to create a repo on github.com?", | ||
"receive_updates": "Would you like to receive updates from the DSACMS team via pull requests?" | ||
} | ||
"project_name": "My Project", | ||
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}", | ||
"project_org": "DSACMS", | ||
"project_repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", | ||
"project_description": "This is the project description, could match github.com repo description.", | ||
"code_owners": "Git usernames of code owners; separated by commas.", | ||
"project_visibility": ["public", "internal", "private"], | ||
"create_repo": [true, false], | ||
"receive_updates": [true, false], | ||
"add_maintainer": [true, false], | ||
"__prompts__": { | ||
"create_repo": "Would you like to create a repo on github.com?", | ||
"receive_updates": "Would you like to receive updates from the DSACMS team via pull requests?", | ||
"add_maintainer": "Would you like to add a maintainer?" | ||
}, | ||
"_copy_without_render": ["repometrics"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,9 @@ jobs: | |
- name: Contribute List | ||
uses: akhilmhdh/[email protected] | ||
env: | ||
{% raw %} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
{% endraw %} | ||
with: | ||
# https://github.com/marketplace/actions/contribute-list#optional-parameters | ||
readme_path: MAINTAINERS.md | ||
|
@@ -38,18 +40,22 @@ jobs: | |
# https://docs.github.com/en/graphql/guides/forming-calls-with-graphql#communicating-with-graphql | ||
# CANNOT have newlines! | ||
run: | | ||
{% raw %} | ||
OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) | ||
REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) | ||
QUERY='query { repository(owner: \"'"$OWNER"'\", name: \"'"$REPO"'\") { collaborators { totalCount } } }' | ||
CONTRIBUTORS=$(curl -s -X POST -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" -d "{\"query\": \"$QUERY\"}" https://api.github.com/graphql | jq -r '.data.repository.collaborators.totalCount') | ||
echo "Total contributors: $CONTRIBUTORS" | ||
echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT | ||
{% endraw %} | ||
- name: Replace slug in MAINTAINERS.md with number of contributors | ||
# https://stackoverflow.com/questions/10613643/replace-a-unknown-string-between-two-known-strings-with-sed | ||
run: | | ||
{% raw %} | ||
CONTRIBUTORS=${{ steps.get_contributors.outputs.contributors }} | ||
sed -i 's/<!--CONTRIBUTOR COUNT START-->.*<!--CONTRIBUTOR COUNT END-->/<!--CONTRIBUTOR COUNT START--> '"$CONTRIBUTORS"' <!--CONTRIBUTOR COUNT END-->/g' MAINTAINERS.md | ||
{% endraw %} | ||
- name: Commit and push changes | ||
# https://github.com/orgs/community/discussions/26560#discussioncomment-3531273 | ||
|
18 changes: 18 additions & 0 deletions
18
tier2/{{cookiecutter.project_slug}}/repometrics/cookiecutter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"project_type" : ["Package", "Website", "Standards", "Libraries", "Data", "Apps", "Tools", "APIs"], | ||
"user_input": ["Yes", "No"], | ||
"project_fisma_level": ["Low", "Moderate", "High"], | ||
"group": "CMS/OA/DSAC", | ||
"subset_in_healthcare": "Policy, Operational", | ||
"user_type": "Providers, Patients, Government", | ||
"repository_host": ["Github.com", "GitHub ENT", "GitHub Cloud", "GitLab.com", "GitLab ENT", "GitLab ENT CCSQ"], | ||
"maturity_model_tier": ["1", "2", "3", "4"], | ||
"__prompts__": { | ||
"group": "Which group is the project part of?", | ||
"subset_in_healthcare": "Which subset of healthcare does the project belong to?", | ||
"user_type": "Who are the intended users?", | ||
"user_input": "Does the project accept user input? (e.g. allows user to query a database, allows login by users, etc.)", | ||
"repository_host": "Where is the repository hosted?", | ||
"maturity_model_tier": "What maturity model tier is your project classified as?" | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tier2/{{cookiecutter.project_slug}}/repometrics/hooks/post_gen_project.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# Change to the parent directory | ||
cd .. | ||
|
||
# Define the repometrics directory to remove | ||
dir_name="repometrics" | ||
|
||
# Check if repometrics directory exists and remove it | ||
if [ -d "$dir_name" ]; then | ||
rm -rf "$dir_name" | ||
fi | ||
|
||
project_type="{{cookiecutter.project_type}}" | ||
sub_project_dir="${project_type}" | ||
repometrics_file="code.json" | ||
parent_dir="./" | ||
|
||
if [ -f "${sub_project_dir}/${repometrics_file}" ]; then | ||
# Move code.json file to parent directory | ||
mv "${sub_project_dir}/${repometrics_file}" "${parent_dir}" | ||
|
||
# Check if the move was successful | ||
if [ $? -eq 0 ]; then | ||
# Remove the source directory | ||
rm -rf "${sub_project_dir}" | ||
|
||
# Check if the deletion was successful | ||
if [ $? -eq 0 ]; then | ||
echo "Successfully generated code.json file." | ||
fi | ||
fi | ||
fi |
10 changes: 10 additions & 0 deletions
10
tier2/{{cookiecutter.project_slug}}/repometrics/{{cookiecutter.project_type}}/code.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"project_type": "{{ cookiecutter.project_type }}", | ||
"user_input": "{{ cookiecutter.user_input }}", | ||
"project_fisma_level": "{{ cookiecutter.project_fisma_level }}", | ||
"group": "{{ cookiecutter.group }}", | ||
"subset_in_healthcare": "{{ cookiecutter.subset_in_healthcare }}", | ||
"user_type": "{{ cookiecutter.user_type }}", | ||
"repository_host": "{{ cookiecutter.repository_host }}", | ||
"maturity_model_tier": "{{ cookiecutter.maturity_model_tier }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
{ | ||
"project_name": "My Project", | ||
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}", | ||
"project_org": "DSACMS", | ||
"project_repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", | ||
"project_description": "This is the project description, could match github.com repo description.", | ||
"code_owners": "Git usernames of code owners; separated by commas.", | ||
"project_visibility": ["public", "internal", "private"], | ||
"create_repo": [true, false], | ||
"receive_updates": [true, false], | ||
"__prompts__": { | ||
"create_repo": "Would you like to create a repo on github.com?", | ||
"receive_updates": "Would you like to receive updates from the DSACMS team via pull requests?" | ||
} | ||
"project_name": "My Project", | ||
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}", | ||
"project_org": "DSACMS", | ||
"project_repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", | ||
"project_description": "This is the project description, could match github.com repo description.", | ||
"code_owners": "Git usernames of code owners; separated by commas.", | ||
"project_visibility": ["public", "internal", "private"], | ||
"create_repo": [true, false], | ||
"receive_updates": [true, false], | ||
"add_maintainer": [true, false], | ||
"__prompts__": { | ||
"create_repo": "Would you like to create a repo on github.com?", | ||
"receive_updates": "Would you like to receive updates from the DSACMS team via pull requests?", | ||
"add_maintainer": "Would you like to add maintainers, approvers, and/or reviewers?" | ||
}, | ||
"_copy_without_render": ["repometrics"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import subprocess | ||
|
||
REPO_NAME = '{{ cookiecutter.project_repo_name }}' | ||
ORG_NAME = '{{ cookiecutter.project_org }}' | ||
VISIBILITY = '{{cookiecutter.project_visibility}}' | ||
DESCRIPTION = '{{cookiecutter.project_description}}' | ||
CREATE_REPO = '{{cookiecutter.create_repo}}' | ||
RECEIVE_UPDATES = '{{cookiecutter.receive_updates}}' | ||
ADD_MAINTAINER = '{{cookiecutter.add_maintainer}}' | ||
|
||
def createGithubRepo(): | ||
subprocess.call(["git", "init", "-b", "main"]) | ||
subprocess.call(["git", "add", "."]) | ||
subprocess.call(["git", "commit", "-m", "first commit"]) | ||
gh_cli_command = [ | ||
"gh", "repo", "create", | ||
f"{ORG_NAME}/{REPO_NAME}", | ||
"--source=.", | ||
f"--{VISIBILITY}", | ||
"--push", | ||
f"--description={DESCRIPTION}", | ||
] | ||
subprocess.call(gh_cli_command) | ||
subprocess.call(["git", "push", "--set-upstream", "origin", "main"]) | ||
|
||
def addTopic(): | ||
gh_cli_command = [ | ||
"gh", "repo", "edit", | ||
f"{ORG_NAME}/{REPO_NAME}", | ||
"--add-topic=dsacms-tier3", | ||
] | ||
subprocess.call(gh_cli_command) | ||
|
||
# Helper function for addMaintainer() to get user input of usernames for Maintainer, Approver, and Reviewer | ||
def getUsernames(role): | ||
while True: | ||
usernames = input(f"Enter the GitHub usernames of {role} (comma-separated): ").strip() | ||
if usernames: | ||
return [username.strip() for username in usernames.split(',')] | ||
print("Please enter at least one username.") | ||
|
||
# Helper function for addMaintainer() to format list of usernames | ||
def formatUsernames(usernames): | ||
return "".join(f"- @{username.lstrip('@')}\n" for username in usernames) | ||
|
||
def addMaintainer(): | ||
maintainers = getUsernames("MAINTAINERS") | ||
approvers = getUsernames("APPROVERS") | ||
reviewers = getUsernames("REVIEWERS") | ||
|
||
maintainers_file_path = "MAINTAINERS.md" | ||
|
||
with open(maintainers_file_path, "r") as f: | ||
lines = f.readlines() | ||
|
||
for i, line in enumerate(lines): | ||
if line.strip() == "## Maintainers:" and i + 2 < len(lines) and lines[i + 2].strip() == "-": | ||
lines[i + 2] = formatUsernames(maintainers) | ||
elif line.strip() == "## Approvers:" and i + 1 < len(lines) and lines[i + 1].strip() == "-": | ||
lines[i + 1] = formatUsernames(approvers) | ||
elif line.strip() == "## Reviewers:" and i + 1 < len(lines) and lines[i + 1].strip() == "-": | ||
lines[i + 1] = formatUsernames(reviewers) | ||
|
||
with open(maintainers_file_path, "w") as f: | ||
f.writelines(lines) | ||
|
||
if CREATE_REPO == "True": | ||
createGithubRepo() | ||
|
||
if RECEIVE_UPDATES == "True": | ||
addTopic() | ||
|
||
if ADD_MAINTAINER == "True": | ||
addMaintainer() |
Oops, something went wrong.