Skip to content

Commit

Permalink
adapt CI actions
Browse files Browse the repository at this point in the history
- increase range of python and Flask versions tested

- test correct install via pip
  • Loading branch information
ValentinFrancois authored and jwg4 committed May 21, 2023
1 parent 59c54fd commit d594157
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 25 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/minimal-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,40 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-18.04]
python-version: ['3.8', '3.9', '3.10']
flask-version: [latest]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: pip install poetry
- name: Force the chosen flask version
run: poetry add flask==${{ matrix.flask-version }}
run: pip3 install poetry

- name: Force Python version (linux/macOS)
if: matrix.os != 'windows-latest'
# sed command for macOS: https://stackoverflow.com/a/44864004
run: sed -i.bak 's/python = "^3.6"/python = "~${{ matrix.python-version }}"/' pyproject.toml

- name: Force Python version (windows)
if: matrix.os == 'windows-latest'
run: (Get-Content pyproject.toml).replace('python = "^3.6"', 'python = "~${{ matrix.python-version }}"') | Set-Content pyproject.toml

- name: Force Flask version
run: poetry add Flask==${{ matrix.flask-version }}

- name: Install requirements
run: poetry install

- name: List installed package versions for manual inspection
run: poetry --version && poetry show

- name: Test package
run: poetry run test

- name: Test package
run: poetry run doctest
11 changes: 9 additions & 2 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,29 @@ jobs:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'nodeploy')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Install poetry
run: pip install poetry

- name: Install requirements
run: poetry install

- name: Build package
run: poetry build

- name: Test package
run: poetry run pytest

- name: Check if already uploaded
id: check_pypi
run: poetry run check_pypi_prerelease
continue-on-error: true

- name: publish to pypi
run: poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
if: steps.check_pypi.outcome == 'success'
13 changes: 10 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy release version to pypi
on:
push:
branches:
branches:
- main

jobs:
Expand All @@ -11,19 +11,26 @@ jobs:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'nodeploy')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Install poetry
run: pip install poetry

- name: Install requirements
run: poetry install

- name: Build package
run: poetry build

- name: Test package
run: poetry run pytest

- name: Check if already uploaded
run: poetry run check_pypi

- name: publish to pypi
run: poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
174 changes: 161 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,174 @@ on:
- pull_request

jobs:

testing:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-18.04, macos-latest, windows-latest]
flask-version: ["1.0", 1.1, "2.0", latest]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.x']
flask-version: ['1.0', '1.1', '2.0', '2.1', 'latest']
os: [ubuntu-20.04, macos-latest, windows-latest]
exclude:
# starting from Flask 2.1.0, python 3.6 is no longer supported:
- flask-version: '2.1'
python-version: '3.6'

- flask-version: 'latest'
python-version: '3.6'

# old versions of Flask no longer working with python >= 3.10:
- flask-version: '1.0'
python-version: '3.10'

- flask-version: '1.0'
python-version: '3.x'

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: pip install poetry
- name: Force the chosen flask version
run: poetry add flask==${{ matrix.flask-version }}
- name: Install requirements
run: poetry install

- name: Install dev dependencies (python 3.6)
if: matrix.python-version == '3.6'
run: |
pip3 install poetry
poetry export --dev --without-hashes --format requirements.txt --output requirements-dev.txt
pip3 install -r requirements-dev.txt
- name: Install Flask ${{ matrix.flask-version }}
if: matrix.flask-version != 'latest'
run: pip3 install Flask==${{ matrix.flask-version }}

- name: Install latest Flask
if: matrix.flask-version == 'latest'
run: pip3 install Flask

- name: Install dev dependencies (python >= 3.7)
if: matrix.python-version != '3.6'
run: |
pip3 install poetry
poetry export --only dev --format requirements.txt --output requirements-dev.txt
pip3 install -r requirements-dev.txt
- name: Overwrite Flask dependencies for legacy install
if: matrix.flask-version < '2.0' && matrix.flask-version != 'latest'
run: |
pip3 install "Jinja2<3.0"
pip3 install "MarkupSafe<=2.0.1"
pip3 install "itsdangerous<=2.0.1"
- name: Overwrite Flask dependencies for legacy install (2)
if: matrix.flask-version < '2.1' && matrix.flask-version != 'latest'
run: pip3 install "werkzeug<=2.0.3"

- name: List installed package versions for manual inspection
run: python3 --version && pip3 list

- name: Run unit tests
run: poetry run test
run: python3 -c "from run_tests import test; test()"

- name: Run doctests
run: poetry run doctest
run: python3 -c "from run_tests import run_doctest; run_doctest()"

check_pip_install:
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.x']
flask-version: ['1.0', '1.1', '2.0', '2.1', 'latest']
os: [ubuntu-20.04, macos-latest, windows-latest]
exclude:
# starting from Flask 2.1.0, python 3.6 is no longer supported:
- flask-version: '2.1'
python-version: '3.6'

- flask-version: 'latest'
python-version: '3.6'

# old versions of Flask no longer working with python >= 3.10:
- flask-version: '1.0'
python-version: '3.10'

- flask-version: '1.0'
python-version: '3.x'

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dev dependencies (python 3.6)
# actually installs all dependencies (no --only flag in this version)
# so we run this without installing the target Flask version
if: matrix.python-version == '3.6'
run: |
pip3 install poetry
poetry export --dev --without-hashes --format requirements.txt --output requirements-dev.txt
pip3 install -r requirements-dev.txt
- name: Install Flask ${{ matrix.flask-version }}
if: matrix.flask-version != 'latest'
run: pip3 install Flask==${{ matrix.flask-version }}

- name: Install latest Flask
if: matrix.flask-version == 'latest'
run: pip3 install Flask

- name: Install current flask-selfdoc from GitHub (linux/macOS)
if: matrix.os != 'windows-latest'
run: |
git_url="${{ github.event.pull_request.head.repo.git_url }}@${{ github.event.pull_request.head.ref }}"
git_url="git+https${git_url:3}"
pip3 install ${git_url}
- name: Install current flask-selfdoc from GitHub (windows)
if: matrix.os == 'windows-latest'
run: |
$git_url = "${{ github.event.pull_request.head.repo.git_url }}@${{ github.event.pull_request.head.ref }}"
$git_url = $git_url.subString(3)
$git_url = "git+https$git_url"
pip3 install $git_url
- name: Install dev dependencies (python >= 3.7)
if: matrix.python-version != '3.6'
run: |
pip3 install poetry
poetry export --only dev --format requirements.txt --output requirements-dev.txt
pip3 install -r requirements-dev.txt
- name: Overwrite Flask dependencies for legacy install
if: matrix.flask-version < '2.0' && matrix.flask-version != 'latest'
run: |
pip3 install "Jinja2<3.0"
pip3 install "MarkupSafe<=2.0.1"
pip3 install "itsdangerous<=2.0.1"
- name: Overwrite Flask dependencies for legacy install (2)
if: matrix.flask-version < '2.1' && matrix.flask-version != 'latest'
run: pip3 install "werkzeug<=2.0.3"

- name: List installed package versions for manual inspection
run: python3 --version && pip3 list

- name: Check that Flask version did not change
# not implemented for windows yet
if: matrix.flask-version != 'latest' && matrix.os != 'windows-latest'
run: |
flask_version=$(pip3 show Flask | grep Version:)
echo "found Flask ${flask_version}"
if [[ $(pip3 show Flask | grep Version) == *"Version: ${{ matrix.flask-version }}"* ]]
then
echo "No reinstall of Flask was done 👍"
else
exit 1
fi
- name: Try importing flask_selfdoc
run: python3 -c "import flask_selfdoc"

0 comments on commit d594157

Please sign in to comment.