-
Notifications
You must be signed in to change notification settings - Fork 4
Add Flask 2.x compatibility + fix line number detection under python <= 3.8 and python 3.11 #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c56ad25
688d3a0
baa41e9
e381d32
d7f1317
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find a better way than sed-replacing the python version in |
||
|
|
||
| - 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to control what packages we exactly installed in the end |
||
|
|
||
| - name: Test package | ||
| run: poetry run test | ||
|
|
||
| - name: Test package | ||
| run: poetry run doctest | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a typo? you are checking flask-version twice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Sorry, just seeing this now) I wasn't sure how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some packages that are now too recent when installed via the Flask 1.X dependencies |
||
| 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: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put this in a different workflow file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a different test strategy:
|
||
| 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' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps we should just allow all runs with python 3.6 to fail (or skip them), since it's EOL? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess now that python 3.6 is EOL we can indeed simplify the logic and stop testing on it |
||
| 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} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is currently failing |
||
|
|
||
| - 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. control what package versions we exactly installed |
||
|
|
||
| - name: Check that Flask version did not change | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. control that |
||
| # 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" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arguably we could run some tests or an example after importing this way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remember correctly the issue I fixed happened only at import time, but yes running an example is a good idea. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub was encouraging us to update to the most recent action versions, seems harmless