Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Test Python Package Installation | ||
|
||
on: | ||
push: | ||
branches: [main, v1] | ||
pull_request: | ||
|
||
jobs: | ||
|
||
test-setup-python-scripts: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- test_dir: python-setup/tests/pipenv/requests-2 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2 | ||
- test_dir: python-setup/tests/pipenv/requests-3 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3 | ||
|
||
- test_dir: python-setup/tests/poetry/requests-2 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2 | ||
- test_dir: python-setup/tests/poetry/requests-3 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3 | ||
|
||
- test_dir: python-setup/tests/requirements/requests-2 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2 | ||
- test_dir: python-setup/tests/requirements/requests-3 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3 | ||
|
||
- test_dir: python-setup/tests/setup_py/requests-2 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2 | ||
- test_dir: python-setup/tests/setup_py/requests-3 | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3 | ||
|
||
# This one shouldn't fail, but also won't install packages | ||
- test_dir: python-setup/tests/requirements/non-standard-location | ||
test_script: test -z $LGTM_INDEX_IMPORT_PATH | ||
|
||
# All of these should fail | ||
- test_dir: python-setup/tests/pipenv/python-version-not-available | ||
test_script: /bin/false | ||
- test_dir: python-setup/tests/poetry/python-version-not-available | ||
test_script: /bin/false | ||
- test_dir: python-setup/tests/requirements/invalid-package | ||
test_script: /bin/false | ||
- test_dir: python-setup/tests/requirements/invalid-version | ||
test_script: /bin/false | ||
- test_dir: python-setup/tests/setup_py/invalid-version | ||
test_script: /bin/false | ||
- test_dir: python-setup/tests/setup_py/invalid-file | ||
test_script: /bin/false | ||
- test_dir: python-setup/tests/setup_py/extra-require-not-installed | ||
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3 | ||
- test_dir: python-setup/tests/setup_py/wrong-python-version | ||
test_script: /bin/false | ||
|
||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v1 | ||
with: | ||
languages: python | ||
|
||
- name: Test Auto Package Installation | ||
run: | | ||
set -x | ||
$GITHUB_WORKSPACE/python-setup/install_tools.sh | ||
echo -e '\n\n\n\n\n' && sleep 0.5 | ||
cd $GITHUB_WORKSPACE/${{ matrix.test_dir }} | ||
$GITHUB_WORKSPACE/python-setup/auto_install_packages.py /opt/hostedtoolcache/CodeQL/0.0.0-20200826/x64/codeql/ | ||
- name: Setup for extractor | ||
run: | | ||
echo $CODEQL_PYTHON | ||
# only run if $CODEQL_PYTHON is set | ||
test ! -z $CODEQL_PYTHON && $GITHUB_WORKSPACE/python-setup/tests/from_python_exe.py $CODEQL_PYTHON || /bin/true | ||
- name: Verify packages installed | ||
run: | | ||
${{ matrix.test_script }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
requests = "*" | ||
|
||
[requires] | ||
python_version = "3.8" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
requests = "*" | ||
|
||
[requires] | ||
python_version = "3.100" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
requests = "*" | ||
|
||
[requires] | ||
python_version = "2.7" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
requests = "*" | ||
|
||
[requires] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.