From 9f0f0b07b945d421543cab82a62598d0ef34f12f Mon Sep 17 00:00:00 2001 From: NHagar Date: Wed, 3 Apr 2024 19:07:15 -0500 Subject: [PATCH] workflow updates --- .github/workflows/pull_request.yml | 17 ++++++++++++ .github/workflows/pylint.yml | 23 ---------------- .github/workflows/python-publish.yml | 39 ---------------------------- .github/workflows/release.yml | 21 +++++++++++++++ tests/test_newsletter.py | 4 ++- 5 files changed, 41 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/pull_request.yml delete mode 100644 .github/workflows/pylint.yml delete mode 100644 .github/workflows/python-publish.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..bf50fcd --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,17 @@ +name: CI +on: pull_request + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install Poetry + run: curl -sSL https://install.python-poetry.org | python3 - + - name: Add Poetry to path + run: echo "${HOME}/.poetry/bin" >> $GITHUB_PATH + - name: Install venv + run: poetry install + - name: Test + run: poetry run pytest \ No newline at end of file diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index 383e65c..0000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Pylint - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index bdaab28..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,39 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Upload Python Package - -on: - release: - types: [published] - -permissions: - contents: read - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d798e7a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Publish to PyPI +on: + release: + types: [published] + +jobs: + pypi_release: + name: Builds Using Poetry and Publishes to PyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install Poetry + run: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python + - name: Add Poetry to path + run: echo "${HOME}/.poetry/bin" >> $GITHUB_PATH + - run: poetry install + - run: poetry run pytest + - run: poetry config pypi-token.pypi "${{ secrets.PYPI_API_KEY }}" + - name: Publish package + run: poetry publish --build \ No newline at end of file diff --git a/tests/test_newsletter.py b/tests/test_newsletter.py index 41b721c..591d6bd 100644 --- a/tests/test_newsletter.py +++ b/tests/test_newsletter.py @@ -104,7 +104,9 @@ def test_get_newsletter_recommendations( ) mock_get.assert_called_once_with( - "https://test_subdomain.substack.com/recommendations", headers=HEADERS + "https://test_subdomain.substack.com/recommendations", + headers=HEADERS, + timeout=30, ) mock_bs_init.assert_called_once_with("mocked_html", "html.parser") self.assertEqual(mock_find_all.call_count, 2)