Skip to content

Commit 4859b1a

Browse files
authored
Merge branch 'main' into ducky-bober-emoji
2 parents ead6712 + d85f627 commit 4859b1a

File tree

14 files changed

+62
-52
lines changed

14 files changed

+62
-52
lines changed

.github/workflows/event-validation.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818

1919
- name: Set up Python
20-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v5
2121
with:
22-
python-version: 3.8
22+
python-version: 3.12
2323

2424
- name: Install dependencies
2525
run: python -m pip install -r events/requirements.txt
@@ -46,7 +46,7 @@ jobs:
4646
- name: Upload a Build Artifact
4747
if: always() && steps.prepare-artifact.outcome == 'success'
4848
continue-on-error: true
49-
uses: actions/upload-artifact@v2
49+
uses: actions/upload-artifact@v4
5050
with:
5151
name: pull-request-payload
5252
path: pull_request_payload.json

.github/workflows/status-embed.yml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,12 @@ on:
77
types:
88
- completed
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
status_embed:
12-
# We need to send a status embed whenever the workflow
13-
# sequence we're running terminates. There are a number
14-
# of situations in which that happens:
15-
#
16-
# 1. We reach the end of the Event Validation workflow, without
17-
# it being skipped.
18-
#
19-
# 2. A `pull_request` triggered a Lint & Test workflow,
20-
# as the sequence always terminates with one run.
21-
#
22-
# 3. If any workflow ends in failure or was cancelled.
23-
if: >-
24-
(github.event.workflow_run.name == 'Event Validation' && github.event.workflow_run.conclusion != 'skipped') ||
25-
github.event.workflow_run.event == 'pull_request' ||
26-
github.event.workflow_run.conclusion == 'failure' ||
27-
github.event.workflow_run.conclusion == 'cancelled'
2816
name: Send Status Embed to Discord
2917
runs-on: ubuntu-latest
3018

@@ -39,13 +27,13 @@ jobs:
3927
curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json
4028
DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url')
4129
[ -z "$DOWNLOAD_URL" ] && exit 1
42-
wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2
30+
curl -sSL -H "Authorization: token $GITHUB_TOKEN" -o pull_request_payload.zip $DOWNLOAD_URL || exit 2
4331
unzip -p pull_request_payload.zip > pull_request_payload.json
4432
[ -s pull_request_payload.json ] || exit 3
45-
echo "::set-output name=pr_author_login::$(jq -r '.user.login // empty' pull_request_payload.json)"
46-
echo "::set-output name=pr_number::$(jq -r '.number // empty' pull_request_payload.json)"
47-
echo "::set-output name=pr_title::$(jq -r '.title // empty' pull_request_payload.json)"
48-
echo "::set-output name=pr_source::$(jq -r '.head.label // empty' pull_request_payload.json)"
33+
echo "pr_author_login=$(jq -r '.user.login // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
34+
echo "pr_number=$(jq -r '.number // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
35+
echo "pr_title=$(jq -r '.title // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
36+
echo "pr_source=$(jq -r '.head.label // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
4937
env:
5038
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5139

@@ -54,20 +42,18 @@ jobs:
5442
# more information and we can fine tune when we actually want
5543
# to send an embed.
5644
- name: GitHub Actions Status Embed for Discord
57-
uses: SebastiaanZ/github-status-embed-for-discord@v0.2.1
45+
uses: SebastiaanZ/github-status-embed-for-discord@v0.3.0
5846
with:
5947
# Our GitHub Actions webhook
6048
webhook_id: '784184528997842985'
6149
webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }}
6250

63-
# Workflow information
51+
# We need to provide the information of the workflow that
52+
# triggered this workflow instead of this workflow.
6453
workflow_name: ${{ github.event.workflow_run.name }}
6554
run_id: ${{ github.event.workflow_run.id }}
6655
run_number: ${{ github.event.workflow_run.run_number }}
6756
status: ${{ github.event.workflow_run.conclusion }}
68-
actor: ${{ github.actor }}
69-
repository: ${{ github.repository }}
70-
ref: ${{ github.ref }}
7157
sha: ${{ github.event.workflow_run.head_sha }}
7258

7359
pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}
21.1 KB
Loading

emotes/lemoji/src/lemoji_pleading.svg

Lines changed: 26 additions & 0 deletions
Loading

events/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ start_date: July 10
2323
end_date: July 20
2424
```
2525
26-
There must be exactly 1 fallback event, and 0 or more non-fallback events. Events cannot collide in time, and the end date must either be equal to the start date (1 day event) or chronologically subsequent. Both bounds are inclusive, and the format shown in the example above must be followed.
26+
There must be exactly 1 fallback event, and 0 or more non-fallback events. For single-day events, `end_date` must be equal to `start_date`. If `start_date` is a later day in the year than `end_date`, the event is interpreted as starting in one year and ending in the next. Both bounds are inclusive, and the format shown in the example above must be followed.
2727

2828
The markdown section of the meta file then contains the event's description. Descriptions are made available directly in the Discord guild as embeds sent by the Python bot. For formatting, use Discord's watered down Markdown ~ keep in mind that e.g. the `#` symbol does not create a heading.
2929

events/diwali/meta.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
start_date: November 8
3-
end_date: November 14
2+
start_date: November 1
3+
end_date: November 4
44
---
55
**Diwali**
66

events/easter/meta.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
start_date: April 3
3-
end_date: April 10
2+
start_date: March 30
3+
end_date: April 1
44
---
55
**Easter**
66

events/eid_al_fitr/meta.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
start_date: April 20
3-
end_date: April 21
2+
start_date: April 9
3+
end_date: April 13
44
---
55

66
**Eid al-Fitr**

events/halloween/meta.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
start_date: October 26
3-
end_date: November 1
2+
start_date: October 30
3+
end_date: October 31
44
---
55
**Halloween**
66

events/holi/meta.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
start_date: March 7
3-
end_date: March 13
2+
start_date: March 23
3+
end_date: March 26
44
---
55
**Holi**
66

events/new_year/meta.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
start_date: December 26
3-
end_date: December 31
2+
start_date: December 29
3+
end_date: January 3
44
---
55
**New Year**
66

events/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Python: 3.8
2-
python-frontmatter==1.0.0
3-
pyyaml==5.4.1
1+
# Python: 3.12
2+
python-frontmatter==1.1.0
3+
pyyaml==6.0.1

events/validation.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
We check that each event directory satisfies the following:
1010
* Contains 'meta.md', `banners/` and 'server_icons/' with at least 1 file inside each
1111
* The 'meta.md' file either registers the event as fallback, or specifies the start and end dates
12-
* The end date must either be the same as the start date, or chronologically subsequent
1312
* The 'meta.md' file contains an event description between 1 and 2048 characters in length
1413
1514
If all events are set up correctly, we also validate that:
@@ -123,8 +122,6 @@ def make_event(name: str, from_dir: Path) -> Event:
123122
except Exception as exc:
124123
raise Misconfiguration(f"Attribute 'end_date' with value '{end_date}' failed to parse: {exc}")
125124

126-
if not start_date <= end_date:
127-
raise Misconfiguration("End date must be equal or subsequent to start date")
128125

129126
return Event(name=name, fallback=False, start_date=start_date, end_date=end_date, description=description)
130127

@@ -133,20 +130,21 @@ def active_days(event: Event) -> t.Iterator[date]:
133130
"""
134131
Generate all days in which `event` is active.
135132
133+
All dates returned will be in the same year.
134+
136135
This can only be called for non-fallback events. The fallback event does not have start and end dates.
137136
"""
138137
if None in (event.start_date, event.end_date):
139138
raise RuntimeError("Cannot generate days: event does not have start and date!")
140139

141-
if not event.start_date <= event.end_date:
142-
raise RuntimeError("Cannot generate days: start date does not precede end date!")
143-
144140
state = event.start_date
145141
while True:
146142
yield state
147143
if state == event.end_date:
148144
break
149145
state += timedelta(days=1)
146+
# Wrap around to the same year, so comparisons only compare day and month.
147+
state = state.replace(year=ARBITRARY_YEAR)
150148

151149

152150
def find_collisions(events: t.List[Event]) -> t.Dict[date, t.List[Event]]:
28.7 KB
Loading

0 commit comments

Comments
 (0)