From bd38c3019412afdb53ee394e2dd8ccc9294b83a3 Mon Sep 17 00:00:00 2001 From: fabianegli Date: Tue, 26 Nov 2024 09:12:11 +0100 Subject: [PATCH 1/3] specify file encodings in tests --- code/tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/tests.py b/code/tests.py index ffa7574..16e4fe3 100644 --- a/code/tests.py +++ b/code/tests.py @@ -10,12 +10,12 @@ def test_robots_txt_creation(): - robots_json = json.loads(Path("test_files/robots.json").read_text()) + robots_json = json.loads(Path("test_files/robots.json").read_text(encoding="utf-8")) robots_txt = json_to_txt(robots_json) - assert Path("test_files/robots.txt").read_text() == robots_txt + assert Path("test_files/robots.txt").read_text(encoding="utf-8") == robots_txt def test_table_of_bot_metrices_md(): - robots_json = json.loads(Path("test_files/robots.json").read_text()) + robots_json = json.loads(Path("test_files/robots.json").read_text(encoding="utf-8")) robots_table = json_to_table(robots_json) - assert Path("test_files/table-of-bot-metrics.md").read_text() == robots_table + assert Path("test_files/table-of-bot-metrics.md").read_text(encoding="utf-8") == robots_table From b64284d6846da62e1ad78146c4fcb6e7ff0eb80c Mon Sep 17 00:00:00 2001 From: fabianegli Date: Tue, 26 Nov 2024 09:41:46 +0100 Subject: [PATCH 2/3] restore correct attribution logic to before PR #55 --- .github/workflows/ai_robots_update.yml | 16 ++++------- .github/workflows/main.yml | 38 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/ai_robots_update.yml b/.github/workflows/ai_robots_update.yml index b346e10..654b0b5 100644 --- a/.github/workflows/ai_robots_update.yml +++ b/.github/workflows/ai_robots_update.yml @@ -1,8 +1,5 @@ name: Updates for AI robots files on: - push: - branches: - - "main" schedule: - cron: "0 0 * * *" @@ -24,11 +21,10 @@ jobs: git --no-pager diff git add -A git diff --quiet && git diff --staged --quiet || (git commit -m "Update from Dark Visitors" && git push) - - echo "Updating robots.txt and table-of-bot-metrics.md if necessary ..." - python code/dark_visitors.py --convert - echo "... done." - git --no-pager diff - git add -A - git diff --quiet && git diff --staged --quiet || (git commit -m "Updated from new robots.json" && git push) shell: bash + call-main: + needs: dark-visitors + uses: ./.github/workflows/main.yml + secrets: inherit + with: + message: "Update from Dark Visitors" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..a4c47d6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,38 @@ +on: + workflow_call: + inputs: + message: + type: string + required: true + description: The message to commit + push: + paths: + - 'robots.json' + branches: + - "main" + +jobs: + ai-robots-txt: + runs-on: ubuntu-latest + name: ai-robots-txt + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - run: | + git config --global user.name "ai.robots.txt" + git config --global user.email "ai.robots.txt@users.noreply.github.com" + git log -1 + git status + echo "Updating robots.txt and table-of-bot-metrics.md if necessary ..." + python code/dark_visitors.py --convert + echo "... done." + git --no-pager diff + git add -A + if [ -n "${{ inputs.message }}" ]; then + git commit -m "${{ inputs.message }}" + else + git commit -m "${{ github.event.head_commit.message }}" + fi + git push + shell: bash From eb8e1a49b5fd36b57490b37831d26013223b4eb9 Mon Sep 17 00:00:00 2001 From: fabianegli Date: Fri, 29 Nov 2024 09:02:47 +0100 Subject: [PATCH 3/3] Revert "specify file encodings in tests" This reverts commit bd38c3019412afdb53ee394e2dd8ccc9294b83a3. --- code/tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/tests.py b/code/tests.py index 16e4fe3..ffa7574 100644 --- a/code/tests.py +++ b/code/tests.py @@ -10,12 +10,12 @@ def test_robots_txt_creation(): - robots_json = json.loads(Path("test_files/robots.json").read_text(encoding="utf-8")) + robots_json = json.loads(Path("test_files/robots.json").read_text()) robots_txt = json_to_txt(robots_json) - assert Path("test_files/robots.txt").read_text(encoding="utf-8") == robots_txt + assert Path("test_files/robots.txt").read_text() == robots_txt def test_table_of_bot_metrices_md(): - robots_json = json.loads(Path("test_files/robots.json").read_text(encoding="utf-8")) + robots_json = json.loads(Path("test_files/robots.json").read_text()) robots_table = json_to_table(robots_json) - assert Path("test_files/table-of-bot-metrics.md").read_text(encoding="utf-8") == robots_table + assert Path("test_files/table-of-bot-metrics.md").read_text() == robots_table