test-future #142
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: test-future | |
# This workflow detects breakage against upcoming releases of dependencies | |
# even in the absence of activity in Darker's own repository. | |
on: # yamllint disable-line rule:truthy | |
schedule: | |
- cron: "05 20 * * 6" | |
jobs: | |
test-future: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'master' | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
# strict dependency resolution added in pip 20.3 | |
# CVE-2021-3572 fixed in pip 21.1 | |
python -m pip install --upgrade 'pip>=21.1' | |
pip install \ | |
--constraint=constraints-future.txt \ | |
--upgrade \ | |
--upgrade-strategy=eager \ | |
-e '.[test]' | |
- name: Test with pytest | |
run: | | |
pytest | |
- name: Note a possible Black incompatibility and required actions | |
if: failure() | |
shell: python | |
run: | | |
import json | |
import os | |
import urllib.request | |
from distutils.version import LooseVersion | |
from importlib.metadata import version | |
from textwrap import dedent | |
for linenum, line in enumerate(open("setup.cfg"), 1): | |
constraint = line.strip() | |
if constraint.startswith("black>="): | |
column = line.index("black>=") + 1 | |
end_column = len(line) | |
break | |
else: | |
raise RuntimeError("black>= line not found in setup.cfg") | |
response = urllib.request.urlopen( | |
'https://pypi.org/pypi/black/json' | |
).read().decode() | |
latest_version = max( | |
LooseVersion(s) | |
for s in json.loads(response)['releases'].keys() | |
) | |
print( | |
dedent( | |
f""" | |
### :x: Future Black incompatibility? :x: | |
You could add a maximum version constraint for Black on | |
`setup.cfg` line {linenum}, e.g. | |
`{constraint},<={latest_version}` | |
See [#382](/akaihola/darker/issues/382) | |
for more information | |
""" | |
), | |
file=open(os.getenv("GITHUB_STEP_SUMMARY"), "a"), | |
) | |
print( | |
"::notice " | |
"file=setup.cfg," | |
f"line={linenum}," | |
f"col={column}," | |
f"endColumn={end_column}," | |
"title=Future Black incompatibility?::" | |
"You could add a maximum version constraint for Black here, " | |
f"e.g. {constraint},<={latest_version}" | |
) |