Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #1541] Fail CI when there are outstanding linter changes #1583

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:

# """
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruff made these changes. This is a good reminder not to leave large code blocks commented out like this, its "unsafe"

# # 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(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

black made these changes

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
Loading