diff --git a/analytics/Makefile b/analytics/Makefile index bc3a3e42a..df1ce54d2 100644 --- a/analytics/Makefile +++ b/analytics/Makefile @@ -7,6 +7,7 @@ REPO ?= simpler-grants-gov SPRINT_PROJECT ?= 13 SPRINT_FILE ?= data/sprint-data.json ISSUE_FILE ?= data/issue-data.json +OUTPUT_DIR ?= data SPRINT ?= @current UNIT ?= points ACTION ?= show-results @@ -159,6 +160,7 @@ sprint-burndown: $(POETRY) analytics calculate sprint_burndown \ --sprint-file $(SPRINT_FILE) \ --issue-file $(ISSUE_FILE) \ + --output-dir $(OUTPUT_DIR) \ --sprint "$(SPRINT)" \ --unit $(UNIT) \ --$(ACTION) @@ -169,6 +171,7 @@ percent-complete: $(POETRY) analytics calculate deliverable_percent_complete \ --sprint-file $(SPRINT_FILE) \ --issue-file $(ISSUE_FILE) \ + --output-dir $(OUTPUT_DIR) \ --unit $(UNIT) \ --$(ACTION) diff --git a/analytics/src/analytics/cli.py b/analytics/src/analytics/cli.py index 9c814105b..a62bef53b 100644 --- a/analytics/src/analytics/cli.py +++ b/analytics/src/analytics/cli.py @@ -1,5 +1,6 @@ # pylint: disable=C0415 """Expose a series of CLI entrypoints for the analytics package.""" +from pathlib import Path from typing import Annotated, Optional import typer @@ -19,6 +20,7 @@ ISSUE_FILE_ARG = typer.Option(help="Path to file with exported issue data") ROADMAP_FILE_ARG = typer.Option(help="Path to file with exported roadmap data") OUTPUT_FILE_ARG = typer.Option(help="Path to file where exported data will be saved") +OUTPUT_DIR_ARG = typer.Option(help="Path to directory where output files will be saved") OWNER_ARG = typer.Option(help="GitHub handle of the repo or project owner") REPO_ARG = typer.Option(help="Name of the GitHub repo") PROJECT_ARG = typer.Option(help="Number of the GitHub project") @@ -75,6 +77,7 @@ def calculate_sprint_burndown( *, # makes the following args keyword only show_results: Annotated[bool, SHOW_RESULTS_ARG] = False, post_results: Annotated[bool, POST_RESULTS_ARG] = False, + output_dir: Annotated[str, OUTPUT_DIR_ARG] = "data", ) -> None: """Calculate the burndown for a particular sprint.""" # load the input data @@ -88,6 +91,7 @@ def calculate_sprint_burndown( metric=burndown, show_results=show_results, post_results=post_results, + output_dir=output_dir, ) @@ -100,6 +104,7 @@ def calculate_sprint_burnup( *, # makes the following args keyword only show_results: Annotated[bool, SHOW_RESULTS_ARG] = False, post_results: Annotated[bool, POST_RESULTS_ARG] = False, + output_dir: Annotated[str, OUTPUT_DIR_ARG] = "data", ) -> None: """Calculate the burnup of a particular sprint.""" # load the input data @@ -113,6 +118,7 @@ def calculate_sprint_burnup( metric=burnup, show_results=show_results, post_results=post_results, + output_dir=output_dir, ) @@ -126,6 +132,7 @@ def calculate_deliverable_percent_complete( *, # makes the following args keyword only show_results: Annotated[bool, SHOW_RESULTS_ARG] = False, post_results: Annotated[bool, POST_RESULTS_ARG] = False, + output_dir: Annotated[str, OUTPUT_DIR_ARG] = "data", roadmap_file: Annotated[Optional[str], ROADMAP_FILE_ARG] = None, # noqa: UP007 include_status: Annotated[Optional[list[str]], STATUS_ARG] = None, # noqa: UP007 ) -> None: @@ -153,6 +160,7 @@ def calculate_deliverable_percent_complete( metric=metric, show_results=show_results, post_results=post_results, + output_dir=output_dir, ) @@ -161,6 +169,7 @@ def show_and_or_post_results( *, # makes the following args keyword only show_results: bool, post_results: bool, + output_dir: str, ) -> None: """Optionally show the results of a metric and/or post them to slack.""" # defer load of settings until this command is called @@ -177,4 +186,5 @@ def show_and_or_post_results( metric.post_results_to_slack( slackbot=slackbot, channel_id=settings.reporting_channel_id, + output_dir=Path(output_dir), ) diff --git a/infra/analytics/database/prod.s3.tfbackend b/infra/analytics/database/prod.s3.tfbackend new file mode 100644 index 000000000..625af07d1 --- /dev/null +++ b/infra/analytics/database/prod.s3.tfbackend @@ -0,0 +1,4 @@ +bucket = "simpler-grants-gov-315341936575-us-east-1-tf" +key = "infra/analytics/database/prod.tfstate" +dynamodb_table = "simpler-grants-gov-315341936575-us-east-1-tf-state-locks" +region = "us-east-1" diff --git a/infra/analytics/database/staging.s3.tfbackend b/infra/analytics/database/staging.s3.tfbackend new file mode 100644 index 000000000..38401c300 --- /dev/null +++ b/infra/analytics/database/staging.s3.tfbackend @@ -0,0 +1,4 @@ +bucket = "simpler-grants-gov-315341936575-us-east-1-tf" +key = "infra/analytics/database/staging.tfstate" +dynamodb_table = "simpler-grants-gov-315341936575-us-east-1-tf-state-locks" +region = "us-east-1" diff --git a/infra/analytics/service/prod.s3.tfbackend b/infra/analytics/service/prod.s3.tfbackend new file mode 100644 index 000000000..863714392 --- /dev/null +++ b/infra/analytics/service/prod.s3.tfbackend @@ -0,0 +1,4 @@ +bucket = "simpler-grants-gov-315341936575-us-east-1-tf" +key = "infra/analytics/service/prod.tfstate" +dynamodb_table = "simpler-grants-gov-315341936575-us-east-1-tf-state-locks" +region = "us-east-1" diff --git a/infra/analytics/service/sfn_sprint_reports.tf b/infra/analytics/service/sfn_sprint_reports.tf index b5dc811f7..75ab44f61 100644 --- a/infra/analytics/service/sfn_sprint_reports.tf +++ b/infra/analytics/service/sfn_sprint_reports.tf @@ -48,6 +48,10 @@ resource "aws_sfn_state_machine" "sprint_reports" { { "Name" : "ISSUE_FILE", "Value" : "/tmp/issue-data.json", + }, + { + "Name" : "OUTPUT_DIR", + "Value" : "/tmp/", } ] "Command" : [ diff --git a/infra/analytics/service/staging.s3.tfbackend b/infra/analytics/service/staging.s3.tfbackend new file mode 100644 index 000000000..91e1a2f9c --- /dev/null +++ b/infra/analytics/service/staging.s3.tfbackend @@ -0,0 +1,4 @@ +bucket = "simpler-grants-gov-315341936575-us-east-1-tf" +key = "infra/analytics/service/staging.tfstate" +dynamodb_table = "simpler-grants-gov-315341936575-us-east-1-tf-state-locks" +region = "us-east-1"