diff --git a/.github/workflows/update_cocomo_stats.yml b/.github/workflows/update_cocomo_stats.yml index fa7db373e6..7e7701a5a1 100644 --- a/.github/workflows/update_cocomo_stats.yml +++ b/.github/workflows/update_cocomo_stats.yml @@ -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 diff --git a/.github/workflows/update_data.yml b/.github/workflows/update_data.yml index c6c99f57fa..f20bfbc521 100644 --- a/.github/workflows/update_data.yml +++ b/.github/workflows/update_data.yml @@ -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 diff --git a/scripts/scc_cocomo.sh b/scripts/scc_cocomo.sh index 795578f471..61625c0aea 100755 --- a/scripts/scc_cocomo.sh +++ b/scripts/scc_cocomo.sh @@ -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 @@ -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"