From e1e40de1cbf8870743d04256e39caada3883c80b Mon Sep 17 00:00:00 2001 From: Jochem Smit Date: Mon, 7 Aug 2023 17:25:55 +0200 Subject: [PATCH] update testing and release workflows --- .github/workflows/pypi_main.yml | 11 ++--- .github/workflows/pypi_test.yml | 11 ++--- .github/workflows/pytest.yml | 76 +++++++-------------------------- 3 files changed, 23 insertions(+), 75 deletions(-) diff --git a/.github/workflows/pypi_main.yml b/.github/workflows/pypi_main.yml index 582d091b..8fe54fe4 100644 --- a/.github/workflows/pypi_main.yml +++ b/.github/workflows/pypi_main.yml @@ -15,14 +15,11 @@ jobs: uses: actions/setup-python@v4 with: python-version: 3.9 - - name: Install Poetry - run: pip install poetry - - name: Install dependencies - run: | - pip install poetry-dynamic-versioning + - name: Install Hatch + run: pip install hatch - name: Build - run: poetry build - - name: Publish distribution 📦 to Test PyPI + run: hatch build + - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pypi_test.yml b/.github/workflows/pypi_test.yml index 46948230..24ad77fc 100644 --- a/.github/workflows/pypi_test.yml +++ b/.github/workflows/pypi_test.yml @@ -15,15 +15,12 @@ jobs: uses: actions/setup-python@v4 with: python-version: 3.9 - - name: Install Poetry - run: pip install poetry - - name: Install dependencies - run: | - pip install poetry-dynamic-versioning + - name: Install Hatch + run: pip install hatch - name: Build - run: poetry build + run: hatch build - name: Publish distribution 📦 to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ \ No newline at end of file + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 0d35c5eb..9de631a9 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,35 +1,9 @@ -name: Testing and Linting +name: Testing on: [push] # adapted from: https://github.com/tiangolo/poetry-version-plugin jobs: - linting: - runs-on: ubuntu-latest - steps: - #---------------------------------------------- - # check-out repo and set-up python - #---------------------------------------------- - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.9 - #---------------------------------------------- - # load pip cache if cache exists - #---------------------------------------------- - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - restore-keys: ${{ runner.os }}-pip - #---------------------------------------------- - # install and run linters - #---------------------------------------------- - - run: python -m pip install black - - run: | - black . --check - test: - needs: linting strategy: fail-fast: true matrix: @@ -40,50 +14,30 @@ jobs: shell: bash runs-on: ${{ matrix.os }} steps: - #---------------------------------------------- - # check-out repo and set-up python - #---------------------------------------------- - name: Check out repository uses: actions/checkout@v3 + - name: Set up python ${{ matrix.python-version }} id: setup-python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - #---------------------------------------------- - # ----- install & configure poetry ----- - #---------------------------------------------- + cache: pip + cache-dependency-path: requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt + + - name: Install pinned requirements + run: | + python -m pip install --upgrade pip + pip install -r requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt --prefer-binary + + - name: Install test requirements + run: pip install .[test] - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - #---------------------------------------------- - # load cached venv if cache exists - #---------------------------------------------- - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v3 - with: - path: ~/.venv - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - #---------------------------------------------- - # install dependencies if cache does not exist - #---------------------------------------------- - name: Install dependencies if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: | poetry install --no-interaction --no-root --all-extras - #---------------------------------------------- - # install root project - #---------------------------------------------- - - name: Install library - run: poetry install --no-interaction --all-extras - #---------------------------------------------- - # run test suite - #---------------------------------------------- + - name: Run tests - run: | - source $VENV - pytest tests/ + run: | + pytest tests/