Skip to content

Commit

Permalink
[Issue #1541] Fail CI when there are outstanding linter changes (#1583)
Browse files Browse the repository at this point in the history
## Summary
Fixes #1541

### Time to review: __2 mins__

## Changes proposed

Splits `lint` into:

- format
- format-check
- lint

Their purposes are explained inline

## Context for reviewers

See #1541
  • Loading branch information
coilysiren authored Apr 1, 2024
1 parent bdf0855 commit 2251ce4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci-analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
56 changes: 39 additions & 17 deletions analytics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 #
Expand Down
13 changes: 0 additions & 13 deletions analytics/src/analytics/metrics/burnup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
# """
Expand All @@ -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],
# )
4 changes: 3 additions & 1 deletion analytics/src/analytics/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2251ce4

Please sign in to comment.