From f57618186df00a32260ecf4fbce9d984968d4953 Mon Sep 17 00:00:00 2001 From: Caleb Aguirre-Leon Date: Sat, 24 May 2025 15:44:56 +0100 Subject: [PATCH 01/11] Implementing Golden File into Codebase The test_validate_url() method within the file_test.py file relies on an accerate HTML file comparison for the test to pass. By implementing this workflow it will ensure that this test case won't block people from implement new features. --- .github/dependabot.yml | 38 ++++--- .github/golden-file-updater.yml | 48 +++++++++ .github/workflows/document-formater.yml | 9 +- file.py | 130 ++---------------------- tests/file_test.py | 11 -- tests/no_content_template.golden | 118 +++++++++++++++++++++ tests/testing | 0 7 files changed, 194 insertions(+), 160 deletions(-) create mode 100644 .github/golden-file-updater.yml create mode 100644 tests/no_content_template.golden delete mode 100644 tests/testing diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 12a513b..f6e6762 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,25 +2,23 @@ # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - version: 2 updates: -- package-ecosystem: pip - directory: "/" - schedule: - interval: daily - time: "13:00" - groups: - python-packages: - patterns: - - "*" - -- package-ecosystem: "gomod" - directory: "/" - schedule: - interval: daily - time: "13:00" - groups: - go-packages: - patterns: - - "*" + - package-ecosystem: pip + directory: "/" + schedule: + interval: daily + time: "13:00" + groups: + python-packages: + patterns: + - "*" + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: daily + time: "13:00" + groups: + go-packages: + patterns: + - "*" diff --git a/.github/golden-file-updater.yml b/.github/golden-file-updater.yml new file mode 100644 index 0000000..2d47904 --- /dev/null +++ b/.github/golden-file-updater.yml @@ -0,0 +1,48 @@ +on: + push: + branches: [main] + paths-ignore: + - 'tests/*.golden' + +jobs: + run-test: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./tests + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Run test_validate_url + id: test + run: | + pytest file_test.py::test_validate_url + continue-on-error: true + + update-golden-files: + needs: run-test + if: needs.run-test.result == 'failure' + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./tests + steps: + - name: Check out repository with full history + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get Golden File Content + id: get_content + run: | + response=$(curl -s https://bsky.app/profile/witheringtales.bsky.social/post/3legkyuzjs22) + echo "response=$response" >> $GITHUB_OUTPUT + - name: Update Golden Files + run: | + echo "${{ steps.get_content.outputs.response }}" > no_content_template.golden + - name: Commit changes + run: | + git config user.name c985-star + git config user.email c4746376@gmail.com + git add *.golden + git commit -am "Golden Files Updated" || echo "No changes to commit" + git push diff --git a/.github/workflows/document-formater.yml b/.github/workflows/document-formater.yml index bec4a2e..1fab787 100644 --- a/.github/workflows/document-formater.yml +++ b/.github/workflows/document-formater.yml @@ -1,10 +1,9 @@ name: Document Formatter on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] - + branches: [main] jobs: yaml-format: runs-on: ubuntu-latest @@ -21,5 +20,5 @@ jobs: git add . git commit -m 'Formatted YAML files' - name: Check for changes - run: | - git diff --exit-code \ No newline at end of file + run: |- + git diff --exit-code diff --git a/file.py b/file.py index d4a5972..4f64eec 100644 --- a/file.py +++ b/file.py @@ -31,133 +31,15 @@ def validate_url(url: str) -> bool: bool: True if URL is valid, False otherwise. """ - no_content_template = """ - - - - - - - - Bluesky - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
-
- -