-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve detection of Time-Zone inconsistencies
We have a track record of Time-Zone inconsistencies in the events of the project website (e.g. #1616, #1805, #2288, #2418, #2422, #2431, #2449). In order to detect these inconsistencies earlier, make the `tz` mandatory and check that the Time-Zone offset match the Time-Zone name. These checks require a working bundle so run it on GitHub actions and keep the old pre-commit check to only check date formatting using basic UNIX tooling. Adjust the events templates to match what we expect. While here, also check that non-online events have the needed `location.city` and `location.country`. Signed-off-by: Romain Tartière <[email protected]>
- Loading branch information
Showing
7 changed files
with
81 additions
and
17 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
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
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
malformed_event_dates=$(grep -Er --files-without-match '^eventdate: [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [-+][0-9]{4}$' _events) | ||
if [ -n "${malformed_event_dates}" ]; then | ||
echo "Malformed event date in:" >&2 | ||
echo "${malformed_event_dates}" >&2 | ||
exit 1 | ||
echo "Malformed event date in:" >&2 | ||
echo "${malformed_event_dates}" >&2 | ||
exit 1 | ||
fi |
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,67 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'active_support' | ||
require 'active_support/time' | ||
|
||
require 'yaml' | ||
|
||
issues = 0 | ||
|
||
Dir['_events/*'].each do |filename| | ||
data = YAML.safe_load_file(filename, permitted_classes: [Time]) | ||
start_date = data['eventdate'] | ||
end_date = data['enddate'] | ||
tz = data['tz'] | ||
|
||
if tz.nil? | ||
message = "#{filename}: All events must have a 'tz' key" | ||
if start_date | ||
message += %{ (based on the time-zone offset of 'eventdate' (#{start_date}), it may be "#{ActiveSupport::TimeZone[start_date.utc_offset].tzinfo.identifier}")} | ||
end | ||
|
||
warn message | ||
issues += 1 | ||
end | ||
|
||
if data['online'] == false | ||
if data.dig('location', 'city').nil? | ||
warn "#{filename}: non-online events must have a 'location.city' key" | ||
issues += 1 | ||
end | ||
|
||
if data.dig('location', 'country').nil? | ||
warn "#{filename}: non-online events must have a 'location.country' key" | ||
issues += 1 | ||
end | ||
end | ||
|
||
if start_date.nil? | ||
warn "#{filename}: All events must have an 'eventdate' key" | ||
issues += 1 | ||
elsif start_date.is_a?(Time) | ||
x = start_date.in_time_zone(tz) | ||
if x.utc_offset != start_date.utc_offset | ||
warn %{#{filename}: event 'eventdate' (#{start_date}) in not in 'tz' (#{tz}) (did you mean "#{x}"?)} | ||
issues += 1 | ||
end | ||
else | ||
warn "#{filename}: event 'eventdate' (#{start_date}) is not a valid RFC822 date" | ||
issues += 1 | ||
end | ||
|
||
if end_date.is_a?(Time) | ||
x = end_date.in_time_zone(tz) | ||
if x.utc_offset != start_date.utc_offset | ||
warn %{#{filename}: event 'enddate' (#{end_date}) in not in 'tz' (#{tz}) (did you mean "#{x}"?)} | ||
issues += 1 | ||
end | ||
elsif end_date | ||
warn "#{filename}: event 'enddate' (#{end_date}) is not a valid RFC822 date" | ||
issues += 1 | ||
end | ||
end | ||
|
||
if issues > 0 | ||
warn "#{issues} problems found in events." | ||
exit 1 | ||
end |