Skip to content

Commit

Permalink
Fix for #3927. (#5100)
Browse files Browse the repository at this point in the history
  • Loading branch information
fniessink authored Dec 23, 2022
1 parent 0b5940b commit 9858260
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import asyncio
import itertools
from abc import ABC
from datetime import datetime, date, timedelta
from datetime import datetime, date, timedelta, timezone
from typing import cast, Sequence
from urllib.parse import quote

import aiohttp
from dateutil.parser import parse

from base_collectors import SourceCollector, TimePassedCollector
from collector_utilities.functions import days_ago, match_string_or_regular_expression
from collector_utilities.functions import days_ago
from collector_utilities.type import Response, URL, Value
from model import SourceMeasurement, SourceResponses

Expand Down Expand Up @@ -98,12 +98,12 @@ async def _parse_source_response_date_time(self, response: Response) -> datetime
"""Override to get the date and time of the pipeline."""
pipelines = await response.json()
datetimes = [self._datetime(pipeline) for pipeline in pipelines if self._include_pipeline(pipeline)]
return max(datetimes, default=datetime.min)
return max(datetimes, default=datetime.min.replace(tzinfo=timezone.utc))

def _include_pipeline(self, pipeline) -> bool:
"""Should this pipeline be considered?"""
return (
not match_string_or_regular_expression(pipeline["ref"], self._parameter("refs_to_ignore"))
pipeline["ref"] == self._parameter("branch")
and pipeline["status"] in self._parameter("pipeline_statuses_to_include")
and pipeline["source"] in self._parameter("pipeline_triggers_to_include")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def test_source_up_to_dateness_pipeline(self):
pipeline_json = [
dict(
updated_at="2020-11-24T10:00:00Z",
ref="ref",
ref="branch",
status="success",
source="push",
web_url="https://gitlab/project/-/pipelines/1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
name="Branches and tags to ignore (regular expressions, branch names or tag names)",
short_name="branches and tags to ignore",
help_url=GITLAB_BRANCH_HELP_URL,
metrics=["failed_jobs", "job_runs_within_time_period", "source_up_to_dateness", "unused_jobs"],
metrics=["failed_jobs", "job_runs_within_time_period", "unused_jobs"],
),
inactive_days=Days(
name="Number of days since last commit after which to consider branches inactive",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

<!-- The line "## <square-bracket>Unreleased</square-bracket>" is replaced by the release/release.py script with the new release version and release date. -->

## v4.7.0-rc.5 - 2022-12-23
## [Unreleased]

### Deployment notes

Expand Down
1 change: 0 additions & 1 deletion tests/feature_tests/steps/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
def get_server_info(context):
"""Get the server info."""
context.server_info = context.get("server")
print(context.server_info)


@then("the server information is returned")
Expand Down

0 comments on commit 9858260

Please sign in to comment.