Skip to content

Commit 644bf5e

Browse files
authored
Merge branch 'main' into feat/output-filename-env-18
2 parents b226a02 + e2771ed commit 644bf5e

10 files changed

Lines changed: 115 additions & 12 deletions

File tree

.github/linters/.markdown-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
###############
2121
# line length
2222
MD013: false
23-
# singe h1
23+
# single h1
2424
MD025: false
2525
# duplicate headers
2626
MD024: false

.github/workflows/copilot-setup-steps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626
# If you do not check out your code, Copilot will do this for you.
2727
steps:
2828
- name: Checkout code
29-
uses: actions/checkout@v6.0.2
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3030
with:
3131
persist-credentials: false
3232

3333
- name: Set up Python
34-
uses: actions/setup-python@v6.2.0
34+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3535
with:
3636
python-version: 3.12
3737

.github/workflows/docker-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
build:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v6.0.2
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1818
with:
1919
persist-credentials: false
2020
- name: Build the Docker image

.github/workflows/python-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
matrix:
2121
python-version: [3.11, 3.12]
2222
steps:
23-
- uses: actions/checkout@v6.0.2
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2424
with:
2525
persist-credentials: false
2626
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v6.2.0
27+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
- name: Install dependencies

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
steps:
2727
- name: "Checkout code"
28-
uses: actions/checkout@v6.0.2
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929
with:
3030
persist-credentials: false
3131

@@ -36,7 +36,7 @@ jobs:
3636
results_format: sarif
3737
publish_results: true
3838
- name: "Upload artifact"
39-
uses: actions/upload-artifact@v6.0.0
39+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
4040
with:
4141
name: SARIF file
4242
path: results.sarif

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
stale:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/stale@v10.1.1
14+
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
1515
with:
1616
stale-issue-message: "This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 14 days."
1717
close-issue-message: "This issue was closed because it has been stalled for 35 days with no activity."

.github/workflows/super-linter.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
statuses: write
1919
steps:
2020
- name: Checkout Code
21-
uses: actions/checkout@v6.0.2
21+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2222
with:
2323
fetch-depth: 0
2424
persist-credentials: false
@@ -27,7 +27,7 @@ jobs:
2727
python -m pip install --upgrade pip
2828
pip install -r requirements.txt -r requirements-test.txt
2929
- name: Lint Code Base
30-
uses: super-linter/super-linter@502f4fe48a81a392756e173e39a861f8c8efe056
30+
uses: super-linter/super-linter@61abc07d755095a68f4987d1c2c3d1d64408f1f9 # v8.5.0
3131
env:
3232
DEFAULT_BRANCH: main
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

contributor_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def merge_contributors(contributors: list) -> list:
104104
merged_contributors: List[ContributorStats] = []
105105
for contributor_list in contributors:
106106
for contributor in contributor_list:
107-
# if the contributor is already in the merged list, merge their relavent attributes
107+
# if the contributor is already in the merged list, merge their relevant attributes
108108
if contributor.username in [c.username for c in merged_contributors]:
109109
for merged_contributor in merged_contributors:
110110
if merged_contributor.username == contributor.username:

env.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ def validate_date_format(env_var_name: str) -> str:
7070
return date_to_validate
7171

7272

73+
def validate_date_range(start_date: str, end_date: str) -> None:
74+
"""Validate that start_date is before end_date.
75+
76+
Does nothing if either date is not set.
77+
78+
Args:
79+
start_date: The start date string in YYYY-MM-DD format.
80+
end_date: The end date string in YYYY-MM-DD format.
81+
82+
Raises:
83+
ValueError: If end_date is before or equal to start_date.
84+
"""
85+
if not start_date or not end_date:
86+
return
87+
88+
pattern = "%Y-%m-%d"
89+
try:
90+
start = datetime.datetime.strptime(start_date, pattern).date()
91+
end = datetime.datetime.strptime(end_date, pattern).date()
92+
except ValueError as exc:
93+
raise ValueError(
94+
"start_date and end_date must be in the format YYYY-MM-DD"
95+
) from exc
96+
97+
if end <= start:
98+
raise ValueError(
99+
f"END_DATE ('{end_date}') must be after START_DATE ('{start_date}')"
100+
)
101+
102+
73103
def get_env_vars(
74104
test: bool = False,
75105
) -> tuple[
@@ -144,6 +174,7 @@ def get_env_vars(
144174

145175
start_date = validate_date_format("START_DATE")
146176
end_date = validate_date_format("END_DATE")
177+
validate_date_range(start_date, end_date)
147178

148179
sponsor_info = get_bool_env_var("SPONSOR_INFO", False)
149180
link_to_profile = get_bool_env_var("LINK_TO_PROFILE", False)

test_env.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,78 @@ def test_get_env_vars_auth_with_github_app_installation_missing_inputs(self):
265265
"GH_APP_ID set and GH_APP_INSTALLATION_ID or GH_APP_PRIVATE_KEY variable not set",
266266
)
267267

268+
@patch.dict(
269+
os.environ,
270+
{
271+
"ORGANIZATION": "org",
272+
"REPOSITORY": "repo",
273+
"GH_TOKEN": "token",
274+
"START_DATE": "2025-01-01",
275+
"END_DATE": "2024-01-01",
276+
},
277+
clear=True,
278+
)
279+
def test_get_env_vars_end_date_before_start_date(self):
280+
"""Test that an error is raised when END_DATE is before START_DATE"""
281+
with self.assertRaises(ValueError) as cm:
282+
env.get_env_vars()
283+
the_exception = cm.exception
284+
self.assertEqual(
285+
str(the_exception),
286+
"END_DATE ('2024-01-01') must be after START_DATE ('2025-01-01')",
287+
)
288+
289+
@patch.dict(
290+
os.environ,
291+
{
292+
"ORGANIZATION": "org",
293+
"REPOSITORY": "repo",
294+
"GH_TOKEN": "token",
295+
"START_DATE": "2024-01-01",
296+
"END_DATE": "2024-01-01",
297+
},
298+
clear=True,
299+
)
300+
def test_get_env_vars_equal_start_and_end_date(self):
301+
"""Test that an error is raised when START_DATE equals END_DATE"""
302+
with self.assertRaises(ValueError) as cm:
303+
env.get_env_vars()
304+
the_exception = cm.exception
305+
self.assertEqual(
306+
str(the_exception),
307+
"END_DATE ('2024-01-01') must be after START_DATE ('2024-01-01')",
308+
)
309+
310+
@patch.dict(
311+
os.environ,
312+
{
313+
"ORGANIZATION": "org",
314+
"REPOSITORY": "repo",
315+
"GH_TOKEN": "token",
316+
"START_DATE": "2024-01-01",
317+
"END_DATE": "2025-01-01",
318+
},
319+
clear=True,
320+
)
321+
def test_get_env_vars_valid_date_range(self):
322+
"""Test that valid date range (START_DATE before END_DATE) is accepted"""
323+
(
324+
_organization,
325+
_repository_list,
326+
_gh_app_id,
327+
_gh_app_installation_id,
328+
_gh_app_private_key,
329+
_gh_app_enterprise_only,
330+
_token,
331+
_ghe,
332+
start_date,
333+
end_date,
334+
_sponsor_info,
335+
_link_to_profile,
336+
) = env.get_env_vars()
337+
self.assertEqual(start_date, "2024-01-01")
338+
self.assertEqual(end_date, "2025-01-01")
339+
268340

269341
if __name__ == "__main__":
270342
unittest.main()

0 commit comments

Comments
 (0)