mirror of
https://github.com/github/codeql-action
synced 2026-12-04 13:59:31 +08:00
Add workflow for testing python setup
This commit is contained in:
1 parent
18312707fe
commit
67ddca1d9c
33 files changed
+495
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
EXPECTED_VERSION=$1
|
||||
|
||||
FOUND_VERSION="$LGTM_PYTHON_SETUP_VERSION"
|
||||
FOUND_PYTHONPATH="$LGTM_INDEX_IMPORT_PATH"
|
||||
|
||||
echo "FOUND_VERSION=${FOUND_VERSION} FOUND_PYTHONPATH=${FOUND_PYTHONPATH} "
|
||||
|
||||
if [[ $FOUND_VERSION != $EXPECTED_VERSION ]]; then
|
||||
echo "Script told us to use Python ${FOUND_VERSION}, but expected ${EXPECTED_VERSION}"
|
||||
exit 1
|
||||
else
|
||||
echo "Script told us to use Python ${FOUND_VERSION}, which was expected"
|
||||
fi
|
||||
|
||||
PYTHON_EXE="python${EXPECTED_VERSION}"
|
||||
|
||||
INSTALLED_REQUESTS_VERSION=$(PYTHONPATH="${FOUND_PYTHONPATH}" "${PYTHON_EXE}" -c 'import requests; print(requests.__version__)')
|
||||
|
||||
EXPECTED_REQUESTS="1.2.3"
|
||||
|
||||
if [[ "$INSTALLED_REQUESTS_VERSION" != "$EXPECTED_REQUESTS" ]]; then
|
||||
echo "Using ${FOUND_PYTHONPATH} as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, but expected $EXPECTED_REQUESTS"
|
||||
exit 1
|
||||
else
|
||||
echo "Using ${FOUND_PYTHONPATH} as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, which was expected"
|
||||
fi
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
from typing import Tuple
|
||||
|
||||
def get_details(path_to_python_exe: str) -> Tuple[str, str]:
|
||||
import_path = subprocess.check_output(
|
||||
[
|
||||
path_to_python_exe,
|
||||
"-c",
|
||||
"import os; import pip; print(os.path.dirname(os.path.dirname(pip.__file__)))",
|
||||
],
|
||||
stdin=subprocess.DEVNULL,
|
||||
)
|
||||
version = subprocess.check_output(
|
||||
[path_to_python_exe, "-c", "import sys; print(sys.version_info[0])"],
|
||||
stdin=subprocess.DEVNULL,
|
||||
)
|
||||
|
||||
return version.decode("utf-8").strip(), import_path.decode("utf-8").strip()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
version, import_path = get_details(sys.argv[1])
|
||||
|
||||
print("Setting LGTM_PYTHON_SETUP_VERSION={}".format(version))
|
||||
print("::set-env name=LGTM_PYTHON_SETUP_VERSION::{}".format(version))
|
||||
|
||||
print("Setting LGTM_INDEX_IMPORT_PATH={}".format(import_path))
|
||||
print("::set-env name=LGTM_INDEX_IMPORT_PATH::{}".format(import_path))
|
||||
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
requests = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "2296b1fab66570fa3660c5e6a4e923332dcd7785814624c584be6623bc62c0e7"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.8"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.2.3"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
requests = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.100"
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "2296b1fab66570fa3660c5e6a4e923332dcd7785814624c584be6623bc62c0e7"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.8"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.2.3"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
requests = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "2.7"
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "fba50410545d38a2f88b8d6964eb292055389e363b5c75a56b01ec80e7de14c1"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "2.7"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.2.3"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
requests = "*"
|
||||
|
||||
[requires]
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "2296b1fab66570fa3660c5e6a4e923332dcd7785814624c584be6623bc62c0e7"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.8"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.2.3"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python HTTP for Humans."
|
||||
name = "requests"
|
||||
optional = false
|
||||
python-versions = "^3.8"
|
||||
version = "1.2.3"
|
||||
|
||||
[metadata]
|
||||
content-hash = "b1abdce30bbdad3ac786dafe6840129df522cae3c5988f9ba8061320e3c1a34e"
|
||||
python-versions = "^3.8"
|
||||
|
||||
[metadata.files]
|
||||
requests = [
|
||||
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[tool.poetry]
|
||||
name = "autoinstall-test"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
requests = "*"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
||||
@@ -0,0 +1,16 @@
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python HTTP for Humans."
|
||||
name = "requests"
|
||||
optional = false
|
||||
python-versions = "^3.100"
|
||||
version = "1.2.3"
|
||||
|
||||
[metadata]
|
||||
content-hash = "b1abdce30bbdad3ac786dafe6840129df522cae3c5988f9ba8061320e3c1a34e"
|
||||
python-versions = "^3.100"
|
||||
|
||||
[metadata.files]
|
||||
requests = [
|
||||
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[tool.poetry]
|
||||
name = "autoinstall-test"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.100"
|
||||
requests = "*"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python HTTP for Humans."
|
||||
name = "requests"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "1.2.3"
|
||||
|
||||
[metadata]
|
||||
content-hash = "b8c27a00aece20cb2ff6b3dcd394b1b5ef5e4acc3d7a059cfeb9f9cc11c9eff4"
|
||||
python-versions = "^2.7"
|
||||
|
||||
[metadata.files]
|
||||
requests = [
|
||||
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[tool.poetry]
|
||||
name = "autoinstall-test"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^2.7"
|
||||
requests = "*"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python HTTP for Humans."
|
||||
name = "requests"
|
||||
optional = false
|
||||
python-versions = "^3.5"
|
||||
version = "1.2.3"
|
||||
|
||||
[metadata]
|
||||
content-hash = "b1abdce30bbdad3ac786dafe6840129df522cae3c5988f9ba8061320e3c1a34e"
|
||||
python-versions = "^3.5"
|
||||
|
||||
[metadata.files]
|
||||
requests = [
|
||||
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[tool.poetry]
|
||||
name = "autoinstall-test"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.5"
|
||||
requests = "*"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
||||
@@ -0,0 +1,2 @@
|
||||
# non-existing package
|
||||
ajsdiofjasodinfkajsndfoiuqwhefoanisdfojnasdofas
|
||||
@@ -0,0 +1,2 @@
|
||||
# valid package with invalid version
|
||||
requests==10000
|
||||
@@ -0,0 +1 @@
|
||||
requests==1.2.3
|
||||
@@ -0,0 +1 @@
|
||||
print('hello')
|
||||
@@ -0,0 +1 @@
|
||||
requests==1.2.3
|
||||
@@ -0,0 +1,3 @@
|
||||
# fake setup.py with Trove classifier to fool Python extractor to believe this is Python 2 for sure
|
||||
|
||||
# Programming Language :: Python :: 2.7
|
||||
@@ -0,0 +1 @@
|
||||
requests==1.2.3
|
||||
@@ -0,0 +1,3 @@
|
||||
# fake setup.py with Trove classifier to fool Python extractor to believe this is Python 3 for sure
|
||||
|
||||
# Programming Language :: Python :: 3.7
|
||||
@@ -0,0 +1,11 @@
|
||||
from setuptools import setup
|
||||
|
||||
# has fake Trove classifier to fool Python extractor to believe this is Python 3 for sure
|
||||
|
||||
# Programming Language :: Python :: 3.7
|
||||
|
||||
setup(
|
||||
name="example-setup.py",
|
||||
install_requires=[],
|
||||
extras_require={"all": ["requests==1.2.3"]}
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
raise Exception("some kind of error")
|
||||
@@ -0,0 +1,6 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name="example-setup.py",
|
||||
install_requires=["requests==10000"],
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
from setuptools import setup
|
||||
|
||||
# has fake Trove classifier to fool Python extractor to believe this is Python 2 for sure
|
||||
|
||||
# Programming Language :: Python :: 2.7
|
||||
|
||||
|
||||
setup(
|
||||
name="example-setup.py",
|
||||
install_requires=["requests==1.2.3"],
|
||||
python_requires=">=2.7, <3",
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
from setuptools import setup
|
||||
|
||||
# has fake Trove classifier to fool Python extractor to believe this is Python 3 for sure
|
||||
|
||||
# Programming Language :: Python :: 3.7
|
||||
|
||||
|
||||
setup(
|
||||
name="example-setup.py",
|
||||
install_requires=["requests==1.2.3"],
|
||||
python_requires='>=3.5',
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
from setuptools import setup
|
||||
|
||||
# has fake Trove classifier to fool Python extractor to believe this is Python 3 for sure
|
||||
|
||||
# Programming Language :: Python :: 3.7
|
||||
|
||||
|
||||
setup(
|
||||
name="example-setup.py",
|
||||
install_requires=["requests==1.2.3"],
|
||||
python_requires=">=2.7, <3",
|
||||
)
|
||||
Reference in new issue
Block a user