-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use gitlab-supplied format instead of ISO 8601 * change gitlab timestamp format to be consistent with webhook response in tests
- Loading branch information
Showing
3 changed files
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ | |
"build_status": "success", | ||
"build_name": "[email protected] /jcchwaj %[email protected] arch=linux-ubuntu20.04-x86_64_v3 E4S", | ||
"build_id": 9892514, # not used in testing unless it already exists in the db | ||
"build_started_at": "2024-01-24T17:24:06.000Z", | ||
"build_finished_at": "2024-01-24T17:47:00.000Z", | ||
"build_started_at": "2024-01-24 17:24:06 UTC", | ||
"build_finished_at": "2024-01-24 17:47:00 UTC", | ||
"ref": "pr42264_bugfix/mathomp4/hdf5-appleclang15", | ||
"runner": {"description": "aws"}, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import datetime | ||
|
||
|
||
def webhook_timestamp(dt: str) -> float: | ||
"""Converts a gitlab webhook datetime to a unix timestamp.""" | ||
# gitlab sends dates in 2021-02-23 02:41:37 UTC format | ||
# documentation says they use iso 8601, but they don't consistently apply it | ||
# https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#job-events | ||
GITLAB_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S %Z" | ||
# strptime doesn't tag with timezone by default | ||
return ( | ||
datetime.datetime.strptime(dt, GITLAB_DATETIME_FORMAT) | ||
.replace(tzinfo=datetime.timezone.utc) | ||
.timestamp() | ||
) |