Skip to content

Commit

Permalink
Merge pull request #196 from DSACMS/update-scc-cocomo-script
Browse files Browse the repository at this point in the history
Update SCC COCOMO script
  • Loading branch information
IsaacMilarky authored Jul 30, 2024
2 parents 4f5bfee + 6095a41 commit effeccf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/update_cocomo_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ jobs:
strategy:
matrix:
orgs: ["DSACMS", "Enterprise-CMCS", "CMS-Enterprise", "CMSgov"]
max-parallel: 1
permissions: write-all
name: update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: Install scc
run: sudo snap install scc
run: go install github.com/boyter/scc/v3@latest
- name: Run COCOMO script
run: ./scripts/scc_cocomo.sh ${{ matrix.orgs }}
- name: Commit changes
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
strategy:
matrix:
orgs: ["DSACMS","Enterprise-CMCS","CMS-Enterprise","CMSgov"]
max-parallel: 1
permissions: write-all
name: update
runs-on: ubuntu-latest
Expand Down
42 changes: 34 additions & 8 deletions scripts/scc_cocomo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ organization="$1"
VERBOSE="${VERBOSE:-0}"

if [ -z "$organization" ]; then
echo "Error: Organization name is required."
echo "Usage: ./script.sh ORGANIZATION_NAME"
exit 1
echo "Error: Organization name is required."
echo "Usage: ./script.sh ORGANIZATION_NAME"
exit 1
fi

# set up working directory
Expand All @@ -26,18 +26,44 @@ for repo_path in $repo_paths; do

[ "$VERBOSE" -eq 1 ] && echo "Cloning repository $repo_name from: $clone_url"

git clone $clone_url > /dev/null 2>&1 || ([ "$VERBOSE" -eq 1 ] && echo "Repo $repo_name already exists")
git clone $clone_url >/dev/null 2>&1 || ([ "$VERBOSE" -eq 1 ] && echo "Repo $repo_name already exists")

if [ -d $repo_name ]; then
cd $repo_name

# run scc
scc --format json > ../../scc_reports/cmsgov_${repo_name}.json # JSON
# scc > ../../scc_reports/cmsgov_${repo_name}.log # human-readable
# The average wage flag uses the GS scale as referenced below. A low end and high end range is used to estimate the cost of the project.
# The dryness score (and ULOC table) is also calculated and saved in a separate text file, which is then saved in the JSON as a string.
# https://www.opm.gov/policy-data-oversight/pay-leave/salaries-wages/salary-tables/pdf/2024/GS.pdf
scc --avg-wage 51332 --format json2 >../../scc_reports/cmsgov_${repo_name}_low.json # JSON w/ low end range GS9 step 1 (2024)
scc --avg-wage 159950 --format json2 >../../scc_reports/cmsgov_${repo_name}_high.json # JSON w/ high end range GS15 step 10 (2024)
scc --dryness >../../scc_reports/cmsgov_${repo_name}.log # human-readable w/ dryness

# combine the two JSON files into one with low and high wage range
jq -s '
{
languageSummary: .[0].languageSummary,
estimatedCost_low: .[0].estimatedCost,
estimatedScheduleMonths_low: .[0].estimatedScheduleMonths,
estimatedPeople_low: .[0].estimatedPeople,
estimatedCost_high: .[1].estimatedCost,
estimatedScheduleMonths_high: .[1].estimatedScheduleMonths,
estimatedPeople_high: .[1].estimatedPeople
}
' ../../scc_reports/cmsgov_${repo_name}_low.json ../../scc_reports/cmsgov_${repo_name}_high.json >../../scc_reports/cmsgov_${repo_name}_combined.json

# read the contents of log.log into a variable
dryness_content=$(<../../scc_reports/cmsgov_${repo_name}.log)

# escape the contents of log.log to make it JSON-safe
dryness_content=$(jq -Rsa . <<<"$dryness_content")

# combine the contents into combined_repo.json
jq --argjson dryness_table "$dryness_content" '. + {dryness_table: $dryness_table}' ../../scc_reports/cmsgov_${repo_name}_combined.json >../../scc_reports/cmsgov_${repo_name}_full.json

# combine scc results with repo metadata
jq -s '.[0] + {cocomo: .[1]}' "../../../app/site/_data/$organization/$repo_name/${repo_name}_data.json" "../../scc_reports/cmsgov_${repo_name}.json" > "../../../app/site/_data/$organization/$repo_name/${repo_name}_scc.json"
mv "../../../app/site/_data/$organization/$repo_name/${repo_name}_scc.json" "../../../app/site/_data/$organization/$repo_name/${repo_name}_data.json"
jq -s '.[0] + {cocomo: .[1]}' "../../../app/site/_data/$organization/$repo_name/${repo_name}_data.json" "../../scc_reports/cmsgov_${repo_name}_full.json" >"../../../app/site/_data/$organization/$repo_name/${repo_name}_scc.json"
mv "../../../app/site/_data/$organization/$repo_name/${repo_name}_scc.json" "../../../app/site/_data/$organization/$repo_name/${repo_name}_data.json"
cd ..
else
echo "Error! Something went wrong while cloning repo $repo_name"
Expand Down

0 comments on commit effeccf

Please sign in to comment.