Skip to content
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

Update astroid dependency #4111

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request: ~

env:
CACHE_VERSION: 0
CACHE_VERSION: 1
DEFAULT_PYTHON: 3.6
PRE_COMMIT_CACHE: ~/.cache/pre-commit

Expand All @@ -31,9 +31,12 @@ jobs:
- name: Fetch astroid commit hash
id: fetch-astroid-hash
run: >-
echo "::set-output name=hash::"$(
curl -s https://api.github.com/repos/PyCQA/astroid/branches/master |
grep -E '^ "sha": "(\S*)' | awk '{print substr($0, 13, 40)}')
echo "::set-output name=hash::"$(python script/fetch_astroid_hash.py)
- name: Check astroid commit hash
if: steps.fetch-astroid-hash.outputs.hash == ''
run: |
echo "Error with astroid hash generation, check logs!"
exit 1
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
Expand Down Expand Up @@ -205,9 +208,12 @@ jobs:
- name: Fetch astroid commit hash
id: fetch-astroid-hash
run: >-
echo "::set-output name=hash::"$(
curl -s https://api.github.com/repos/PyCQA/astroid/branches/master |
grep -E '^ "sha": "(\S*)' | awk '{print substr($0, 13, 40)}')
echo "::set-output name=hash::"$(python script/fetch_astroid_hash.py)
- name: Check astroid commit hash
if: steps.fetch-astroid-hash.outputs.hash == ''
run: |
echo "Error with astroid hash generation, check logs!"
exit 1
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
Expand Down Expand Up @@ -379,9 +385,12 @@ jobs:
- name: Fetch astroid commit hash
id: fetch-astroid-hash
run: >-
echo "::set-output name=hash::"$(
curl -s https://api.github.com/repos/PyCQA/astroid/branches/master |
grep -E '^ "sha": "(\S*)' | awk '{print substr($0, 13, 40)}')
echo "::set-output name=hash::"$(python script/fetch_astroid_hash.py)
- name: Check astroid commit hash
if: steps.fetch-astroid-hash.outputs.hash == ''
run: |
echo "Error with astroid hash generation, check logs!"
exit 1
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
Expand Down
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ What's New in Pylint 2.7.0?

* Add Github Actions to replace Travis and AppVeyor in the future

* Update Astroid version to `2.5`


What's New in Pylint 2.6.1?
===========================
Expand Down
2 changes: 1 addition & 1 deletion pylint/__pkginfo__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
version += "-dev" + str(dev_version)

install_requires = [
"astroid>=2.4.0,<=2.6",
"astroid==2.5",
"isort>=4.2.5,<6",
"mccabe>=0.6,<0.7",
"toml>=0.7.1",
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_pypy.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
astroid @ git+git://github.com/PyCQA/astroid.git@master
astroid @ git+git://github.com/PyCQA/astroid.git@2.5
coveralls
coverage<5.0
pytest
Expand Down
47 changes: 47 additions & 0 deletions script/fetch_astroid_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/python
"""Small script to fetch last commit hash for tracked astroid branch."""
import json
import subprocess
import sys
from typing import List

REQUIREMENTS_FILE = "requirements_test_pypy.txt"
GITHUB_API_URI = "https://api.github.com/repos/PyCQA/astroid/branches/"


class ScriptError(Exception):
pass


def read_branch_from_file(file: str) -> str:
with open(file) as fp:
data: List[str] = fp.read().split("\n")
astroid = [line.strip() for line in data if line.strip().startswith("astroid")]
if len(astroid) == 0:
raise ScriptError(f"No astroid dependency found in: {file}")
if len(astroid) > 1:
raise ScriptError(f"Multiple astroid dependencies found in: {file}")

return astroid[0].split("@")[2]


def fetch_hash(branch: str) -> str:
uri = f"{GITHUB_API_URI}{branch}"
p = subprocess.run(["curl", "-s", uri], stdout=subprocess.PIPE, check=True)
if p.stdout is False:
raise ScriptError(f"Could not fetch API result from: {uri}")
json_dict = json.loads(p.stdout.decode("utf-8"))
try:
return json_dict["commit"]["sha"]
except KeyError as ex:
raise ScriptError("Could not read hash") from ex


def main():
branch = read_branch_from_file(REQUIREMENTS_FILE)
commit_hash = fetch_hash(branch)
sys.stdout.write(commit_hash)


if __name__ == "__main__":
main()