Skip to content

Commit

Permalink
docs: correct auto update of main readme updated_at and revert on doc…
Browse files Browse the repository at this point in the history
…s falsy updates
  • Loading branch information
the-forest-tree authored and the-forest-tree committed Mar 14, 2024
1 parent c4a842f commit 16f03f1
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ We invite developers to join us in our mission to bring AI and data integration
| **Comeet** | ATS | 🎯 | | | | | | |
| **Cornerstone OnDemand** | ATS | 🎯 | | | | | | |
| **Crosstalent** | ATS | :hourglass: | *19/01/2022* | | | | | |
| [**DigitalRecruiters**](./src/hrflow_connectors/connectors/digitalrecruiters/README.md) | ATS | :white_check_mark: | *17/08/2023* | *13/03/2024* | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| [**DigitalRecruiters**](./src/hrflow_connectors/connectors/digitalrecruiters/README.md) | ATS | :white_check_mark: | *17/08/2023* | *23/11/2023* | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
|**EngageATS** | ATS | 🎯 | | | | | | |
| **EOLIA Software** | ATS | 🎯 | | | | | | |
| **Eploy** | ATS | 🎯 | | | | | | |
Expand All @@ -85,7 +85,7 @@ We invite developers to join us in our mission to bring AI and data integration
| **Jobvite** | ATS | 🎯 | | |
| **Kronos (UKG)** | HCM | 🎯 | | |
| **Lano** | ATS | 🎯 | | | | | | |
| [**Lever**](./src/hrflow_connectors/connectors/lever/README.md) | ATS | :white_check_mark: | *18/08/2023* | *13/03/2024* | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| [**Lever**](./src/hrflow_connectors/connectors/lever/README.md) | ATS | :white_check_mark: | *18/08/2023* | *23/11/2023* | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| **Mailchimp** | Marketing Tools | 🎯 | | |
| **Microsoft Dynamics** | HCM | 🎯 | | |
| **Oracle** | HCM | 🎯 | | |
Expand All @@ -96,7 +96,7 @@ We invite developers to join us in our mission to bring AI and data integration
| **RecruiterFlow** | ATS | 🎯 | | | | | | |
| **Recruitive** | ATS | 🎯 | | | | | | |
| [**SAPSuccessfactors**](./src/hrflow_connectors/connectors/sapsuccessfactors/README.md) | ATS | :white_check_mark: | *19/01/2022* | *30/10/2023* | :x: | :white_check_mark: | :white_check_mark: | :x: |
| [**Salesforce**](./src/hrflow_connectors/connectors/salesforce/README.md) | CRM | :white_check_mark: | *03/08/2023* | *13/03/2024* | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| [**Salesforce**](./src/hrflow_connectors/connectors/salesforce/README.md) | CRM | :white_check_mark: | *03/08/2023* | *04/12/2023* | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| [**Smartrecruiters**](./src/hrflow_connectors/connectors/smartrecruiters/README.md) | ATS | :white_check_mark: | *21/03/2022* | *30/10/2023* | :x: | :white_check_mark: | :white_check_mark: | :x: |
| [**Taleez**](./src/hrflow_connectors/connectors/taleez/README.md) | ATS | :white_check_mark: | *19/01/2022* | *04/09/2023* | :x: | :white_check_mark: | :white_check_mark: | :x: |
| **Talentlyft** | ATS | 🎯 | | | | | | |
Expand Down Expand Up @@ -135,7 +135,7 @@ We invite developers to join us in our mission to bring AI and data integration
| **Indeed** | Job Board | 🎯 | | |
| **Inzojob** | Job Board | 🎯 | | |
| **Jobijoba** | Job Board | 🎯 | | |
| [**Jobology**](./src/hrflow_connectors/connectors/jobology/README.md) | Job Board | :white_check_mark: | *21/12/2022* | *13/03/2024* | :x: | :x: | :x: | :x: |
| [**Jobology**](./src/hrflow_connectors/connectors/jobology/README.md) | Job Board | :white_check_mark: | *21/12/2022* | *19/02/2024* | :x: | :x: | :x: | :x: |
| **Jobrapido** | Job Board | 🎯 | | |
| **JobTeaser** | Job Board | 🎯 | | |
| **Jobtransport** | Job Board | 🎯 | | |
Expand Down
15 changes: 12 additions & 3 deletions src/hrflow_connectors/core/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
import typing as t
from contextvars import ContextVar
from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path

from pydantic import BaseModel
Expand Down Expand Up @@ -34,7 +34,7 @@ def CONNECTOR_LISTING_REGEXP_F(name: str) -> str:
return (
r"\|\s*\[?\*{0,2}(?i:(?P<name>"
+ r" ?".join([c for c in name if c.strip()])
+ r"))\*{0,2}(\]\([^)]+\))?\s*\|[^|]+\|[^|]+\|\s*(\*|_)(?P<release_date>[\d\/]+)(\*|_)\s*\|.+"
+ r"))\*{0,2}(\]\([^)]+\))?\s*\|[^|]+\|[^|]+\|\s*(\*|_)(?P<release_date>[\d\/]+)(\*|_)\s*\|\s*(\*|_)(?P<update_date>[\d\/]+)(\*|_)\s*\|.+"
)


Expand All @@ -43,7 +43,9 @@ def CONNECTOR_LISTING_REGEXP_F(name: str) -> str:
)


GIT_UPDATE_EXCLUDE_PATTERN = r"notebooks/.gitkeep"
GIT_UPDATE_EXCLUDE_PATTERN = (
r"(notebooks/\.gitkeep|README\.md|test\-config\.yaml|logo\.png|docs/)"
)
GIT_UPDATE_TIMEOUT = 5
GIT_UPDATE_DATE = """
git ls-tree -r --name-only HEAD {base_connector_path}/{connector} | while read filename; do
Expand Down Expand Up @@ -217,6 +219,13 @@ def update_root_readme(connectors: t.List[Connector], root: Path) -> t.Dict:
model.name, pattern
)
)
current_updated_at = datetime.strptime(
match.group("update_date"), "%d/%m/%Y"
).replace(tzinfo=timezone.utc)
updated_at = (
current_updated_at if current_updated_at >= updated_at else updated_at
)

updated_listing = (
"| [**{name}**]({readme_link}) | {type} | :white_check_mark: |"
" *{release_date}* | *{updated_at}* | {pull_profile_list_status} |"
Expand Down
89 changes: 77 additions & 12 deletions tests/core/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import random
import re
from contextlib import contextmanager
from datetime import date, datetime, time
from datetime import date, datetime, time, timezone
from os.path import relpath
from pathlib import Path
from unittest import mock
Expand Down Expand Up @@ -37,7 +37,7 @@
# 🤝 List of Connectors (ATS/CRM/HCM)
| Name | Type | Available | Release date | Last update | Pull profile list action | Pull job list action | Push profile action | Push job action |
|----------------|--------------|----------|----------|----------|------------|--------|-----------|--------------|
| [**Smart Leads**](./src/hrflow_connectors/connectors/smartleads/README.md) | HCM | :white_check_mark: | *27/09/2022* | *04/09/2023* | :x: | :white_check_mark: | :white_check_mark: | :x: |
| [**Smart Leads**](./src/hrflow_connectors/connectors/smartleads/README.md) | HCM | :white_check_mark: | *27/09/2021* | *04/09/2022* | :x: | :white_check_mark: | :white_check_mark: | :x: |
| [**No Connector Dir**](./src/hrflow_connectors/connectors/noconnectordir/README.md) | HCM | :white_check_mark: | *20/01/2019* | *14/03/2022* | :x: | :white_check_mark: | :white_check_mark: | :x: |
Expand Down Expand Up @@ -319,6 +319,7 @@ def test_main_readme_update_at_expected_value(root_readme, connectors_directory)
time(
random.randint(0, 23), random.randint(0, 59), random.randint(0, 59)
),
tzinfo=timezone.utc,
).isoformat()
+ " some/file."
+ "".join(random.choices("abcdefghk", k=3))
Expand All @@ -331,7 +332,16 @@ def test_main_readme_update_at_expected_value(root_readme, connectors_directory)
assert expected.strftime("%d/%m/%Y") in root_readme.read_text()


def test_main_keep_empty_notebooks_not_taken_into_account_for_main_readme_updated_at(
IGNORED_PATHS = [
"notebooks/{}".format(KEEP_EMPTY_NOTEBOOKS),
"README.md",
"test-config.yaml",
"logo.png",
"docs/pull_action.md",
]


def test_ignored_path_are_not_taken_into_account_for_main_readme_updated_at(
root_readme, connectors_directory
):
connectors = [SmartLeads]
Expand All @@ -358,29 +368,32 @@ def test_main_keep_empty_notebooks_not_taken_into_account_for_main_readme_update
time(
random.randint(0, 23), random.randint(0, 59), random.randint(0, 59)
),
tzinfo=timezone.utc,
).isoformat()
+ " some/file."
+ "".join(random.choices("abcdefghk", k=3))
for date in dates
]
)
keep_empty_notebooks_stdout_line = "\n{} {}".format(
datetime.combine(
greater_than_max_of_dates,
time.min,
).isoformat(),
"notebooks/{}".format(KEEP_EMPTY_NOTEBOOKS),
should_be_ignored = "\n".join(
[
datetime.combine(
greater_than_max_of_dates, time.min, tzinfo=timezone.utc
).isoformat()
+ " "
+ ignored
for ignored in IGNORED_PATHS
]
)
with patched_subprocess(stdout=base_stdout + keep_empty_notebooks_stdout_line):
with patched_subprocess(stdout=base_stdout + should_be_ignored):
generate_docs(connectors=connectors, connectors_directory=connectors_directory)

assert greater_than_max_of_dates.strftime("%d/%m/%Y") not in root_readme.read_text()
assert max_of_dates.strftime("%d/%m/%Y") in root_readme.read_text()

greater_than_max_of_dates_with_regular_file = "\n{} {}".format(
datetime.combine(
greater_than_max_of_dates,
time.min,
greater_than_max_of_dates, time.min, tzinfo=timezone.utc
).isoformat(),
"regular/file.txt",
)
Expand All @@ -393,6 +406,58 @@ def test_main_keep_empty_notebooks_not_taken_into_account_for_main_readme_update
assert max_of_dates.strftime("%d/%m/%Y") not in root_readme.read_text()


def test_main_readme_update_at_helper_doesnt_override_handwritten_updated_at(
root_readme, connectors_directory
):
connectors = [SmartLeads]

set_at = date(year=2026, month=1, day=1)
assert set_at.strftime("%d/%m/%Y") not in root_readme.read_text()

stdout = "\n {} {}".format(
datetime.combine(
set_at,
time.min,
tzinfo=timezone.utc,
).isoformat(),
"regular_file.txt",
)
with patched_subprocess(stdout=stdout):
generate_docs(connectors=connectors, connectors_directory=connectors_directory)

assert set_at.strftime("%d/%m/%Y") in root_readme.read_text()

dates_before_set_at = [
date(year=2023, month=random.randint(1, 12), day=random.randint(1, 28))
for _ in range(5)
]
for date_before in dates_before_set_at:
assert date_before < set_at

expected = max(dates_before_set_at)
assert expected.strftime("%d/%m/%Y") not in root_readme.read_text()

stdout = "\n".join(
[
datetime.combine(
date,
time(
random.randint(0, 23), random.randint(0, 59), random.randint(0, 59)
),
tzinfo=timezone.utc,
).isoformat()
+ " some/file."
+ "".join(random.choices("abcdefghk", k=3))
for date in dates_before_set_at
]
)
with patched_subprocess(stdout=stdout):
generate_docs(connectors=connectors, connectors_directory=connectors_directory)

assert expected.strftime("%d/%m/%Y") not in root_readme.read_text()
assert set_at.strftime("%d/%m/%Y") in root_readme.read_text()


def test_documentation_with_remote_code_links(connectors_directory):
readme = connectors_directory / SmartLeads.model.name.lower() / "README.md"
action_documentation = (
Expand Down

0 comments on commit 16f03f1

Please sign in to comment.