diff --git a/.github/workflows/ci-analytics.yml b/.github/workflows/ci-analytics.yml index 6bc146d18..29a9f7471 100644 --- a/.github/workflows/ci-analytics.yml +++ b/.github/workflows/ci-analytics.yml @@ -33,6 +33,9 @@ jobs: - name: Install analytics package using poetry run: make install + - name: Check formatters + run: make format-check + - name: Run linting run: make lint diff --git a/analytics/Makefile b/analytics/Makefile index 7b8e40431..bc3a3e42a 100644 --- a/analytics/Makefile +++ b/analytics/Makefile @@ -75,15 +75,18 @@ login: build: docker-compose build -lint: - @echo "=> Running code quality checks" - @echo "=============================" - $(POETRY) black src tests - $(POETRY) ruff src tests --fix - $(POETRY) pylint src tests - $(POETRY) mypy src - @echo "=============================" - @echo "=> All checks succeeded" +release-build: + docker buildx build \ + --target release \ + --platform=linux/amd64 \ + --build-arg RUN_USER=$(RUN_USER) \ + --build-arg RUN_UID=$(RUN_UID) \ + $(OPTS) \ + . + +######### +# Tests # +######### unit-test: @echo "=> Running unit tests" @@ -100,14 +103,33 @@ test-audit: unit-test e2e-test @echo "=============================" $(POETRY) coverage report --show-missing --fail-under=$(MIN_TEST_COVERAGE) -release-build: - docker buildx build \ - --target release \ - --platform=linux/amd64 \ - --build-arg RUN_USER=$(RUN_USER) \ - --build-arg RUN_UID=$(RUN_UID) \ - $(OPTS) \ - . +########################## +# Formatting and Linting # +########################## + +format: ## runs code formatting + @echo "=> Running code formatting" + @echo "=============================" + $(POETRY) black src tests + $(POETRY) ruff --fix src tests + @echo "=============================" + @echo "=> Code formatting complete" + +format-check: ## runs code formatting checks + @echo "=> Running code formatting checks" + @echo "=============================" + $(POETRY) black --check src tests + $(POETRY) ruff --fix --exit-non-zero-on-fix src tests + @echo "=============================" + @echo "=> All checks succeeded" + +lint: ## runs code quality checks + @echo "=> Running code quality checks" + @echo "=============================" + $(POETRY) pylint src tests + $(POETRY) mypy src + @echo "=============================" + @echo "=> All checks succeeded" ################# # Data Commands # diff --git a/analytics/src/analytics/metrics/burnup.py b/analytics/src/analytics/metrics/burnup.py index f46ec6ad2..a9fd90fdd 100644 --- a/analytics/src/analytics/metrics/burnup.py +++ b/analytics/src/analytics/metrics/burnup.py @@ -184,15 +184,9 @@ def _isolate_data_for_this_sprint(self) -> pd.DataFrame: # """ # # create local copies of the key column names - # agg_col = self.opened_col if status == "opened" else self.closed_col - # unit_col = self.unit.value - # key_cols = [agg_col, unit_col] # # create a dummy column to sum per row if the unit is tasks # if self.unit == Unit.issues: - # df[unit_col] = 1 # # isolate the key columns, group by open or closed date, then sum the units - # df_agg = df[key_cols].groupby(agg_col, as_index=False).agg({unit_col: "sum"}) - # return df_agg.rename(columns={agg_col: self.date_col, unit_col: status}) # def _get_tix_date_range(self, df: pd.DataFrame) -> pd.DataFrame: # """ @@ -210,12 +204,5 @@ def _isolate_data_for_this_sprint(self) -> pd.DataFrame: # """ # # get earliest date an issue was opened and latest date one was closed - # sprint_end = self.dataset.sprint_end(self.sprint) - # opened_min = df[self.opened_col].min() - # closed_max = df[self.closed_col].max() - # closed_max = sprint_end if closed_max is nan else max(sprint_end, closed_max) # # creates a dataframe with one row for each day between min and max date # return pd.DataFrame( - # pd.date_range(opened_min, closed_max), - # columns=[self.date_col], - # ) diff --git a/analytics/src/analytics/metrics/utils.py b/analytics/src/analytics/metrics/utils.py index 091762de0..f9af3b128 100644 --- a/analytics/src/analytics/metrics/utils.py +++ b/analytics/src/analytics/metrics/utils.py @@ -10,7 +10,9 @@ def get_daily_tix_counts_by_status( - df: pd.DataFrame, status: Literal["opened", "closed"], unit: Unit, + df: pd.DataFrame, + status: Literal["opened", "closed"], + unit: Unit, ) -> pd.DataFrame: """ Count the number of issues or points opened or closed by date.