mirror of
https://github.com/github/codeql-action.git
synced 2026-05-04 12:50:14 +00:00
a190d3876a
This allows us to set it automatically in the workflow generator, simplifying things and reducing the scope for error.
191 lines
6.3 KiB
YAML
191 lines
6.3 KiB
YAML
name: Test Python Package Installation on Linux and Mac
|
|
|
|
on:
|
|
push:
|
|
branches: [main, releases/v1, releases/v2]
|
|
pull_request:
|
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
|
# by other workflows.
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
paths:
|
|
# Changes to this workflow.
|
|
- '.github/workflows/python-deps.yml'
|
|
# Changes to the Python package installation scripts and their tests.
|
|
- 'python-setup/**'
|
|
# Changes to the default CodeQL bundle version.
|
|
- '**/defaults.json'
|
|
schedule:
|
|
# Weekly on Monday.
|
|
- cron: '0 0 * * 1'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test-setup-python-scripts:
|
|
timeout-minutes: 45
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-20.04, ubuntu-22.04, macos-latest]
|
|
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
|
python_version: [2, 3]
|
|
exclude:
|
|
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
|
|
- python_version: 2
|
|
python_deps_type: poetry
|
|
# Python2 and pipenv are not supported since pipenv v2021.11.5
|
|
- python_version: 2
|
|
python_deps_type: pipenv
|
|
# Python2 is not available on ubuntu-22.04 by default -- see https://github.com/github/codeql-action/pull/1257
|
|
- python_version: 2
|
|
os: ubuntu-22.04
|
|
|
|
|
|
env:
|
|
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
|
PYTHON_VERSION: ${{ matrix.python_version }}
|
|
|
|
steps:
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Initialize CodeQL
|
|
uses: ./init
|
|
id: init
|
|
with:
|
|
tools: latest
|
|
languages: python
|
|
setup-python-dependencies: false
|
|
|
|
- name: Test Auto Package Installation
|
|
run: |
|
|
set -x
|
|
$GITHUB_WORKSPACE/python-setup/install_tools.sh
|
|
|
|
cd $GITHUB_WORKSPACE/python-setup/tests/${PYTHON_DEPS_TYPE}/requests-${PYTHON_VERSION}
|
|
|
|
case ${{ matrix.os }} in
|
|
ubuntu-20.04*) basePath="/opt";;
|
|
ubuntu-22.04*) basePath="/opt";;
|
|
macos-latest*) basePath="/Users/runner";;
|
|
esac
|
|
echo ${basePath}
|
|
|
|
$GITHUB_WORKSPACE/python-setup/auto_install_packages.py "$(dirname ${{steps.init.outputs.codeql-path}})"
|
|
- name: Setup for extractor
|
|
run: |
|
|
echo $CODEQL_PYTHON
|
|
# only run if $CODEQL_PYTHON is set
|
|
if [ ! -z $CODEQL_PYTHON ]; then
|
|
$GITHUB_WORKSPACE/python-setup/tests/from_python_exe.py $CODEQL_PYTHON;
|
|
fi
|
|
|
|
- name: Verify packages installed
|
|
run: |
|
|
$GITHUB_WORKSPACE/python-setup/tests/check_requests_2_26_0.sh ${PYTHON_VERSION}
|
|
|
|
# This one shouldn't fail, but also won't install packages
|
|
test-setup-python-scripts-non-standard-location:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-20.04, ubuntu-22.04, macos-latest]
|
|
|
|
steps:
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Initialize CodeQL
|
|
uses: ./init
|
|
id: init
|
|
with:
|
|
tools: latest
|
|
languages: python
|
|
setup-python-dependencies: false
|
|
|
|
- name: Test Auto Package Installation
|
|
run: |
|
|
set -x
|
|
$GITHUB_WORKSPACE/python-setup/install_tools.sh
|
|
|
|
cd $GITHUB_WORKSPACE/python-setup/tests/requirements/non-standard-location
|
|
|
|
case ${{ matrix.os }} in
|
|
ubuntu-20.04*) basePath="/opt";;
|
|
ubuntu-22.04*) basePath="/opt";;
|
|
macos-latest*) basePath="/Users/runner";;
|
|
esac
|
|
echo ${basePath}
|
|
|
|
$GITHUB_WORKSPACE/python-setup/auto_install_packages.py "$(dirname ${{steps.init.outputs.codeql-path}})"
|
|
|
|
- name: Setup for extractor
|
|
run: |
|
|
echo $CODEQL_PYTHON
|
|
# only run if $CODEQL_PYTHON is set
|
|
if [ ! -z $CODEQL_PYTHON ]; then
|
|
$GITHUB_WORKSPACE/python-setup/tests/from_python_exe.py $CODEQL_PYTHON;
|
|
fi
|
|
|
|
- name: Verify packages installed
|
|
run: |
|
|
test -z $LGTM_INDEX_IMPORT_PATH
|
|
|
|
test-setup-python-scripts-windows:
|
|
runs-on: windows-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
|
python_version: [2, 3]
|
|
exclude:
|
|
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
|
|
- python_version: 2
|
|
python_deps_type: poetry
|
|
# Python2 and pipenv are not supported since pipenv v2021.11.5
|
|
- python_version: 2
|
|
python_deps_type: pipenv
|
|
|
|
env:
|
|
CODEQL_ACTION_TEST_MODE: true
|
|
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
|
PYTHON_VERSION: ${{ matrix.python_version }}
|
|
|
|
steps:
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-python@v3
|
|
with:
|
|
python-version: ${{ matrix.python_version }}
|
|
|
|
- name: Initialize CodeQL
|
|
uses: ./init
|
|
with:
|
|
tools: latest
|
|
languages: python
|
|
setup-python-dependencies: false
|
|
|
|
- name: Test Auto Package Installation
|
|
run: |
|
|
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\install_tools.ps1"
|
|
powershell -File $cmd
|
|
|
|
cd $Env:GITHUB_WORKSPACE\\python-setup/tests/$Env:PYTHON_DEPS_TYPE/requests-$Env:PYTHON_VERSION
|
|
$DefaultsPath = Join-Path (Join-Path $Env:GITHUB_WORKSPACE "src") "defaults.json"
|
|
$CodeQLBundleName = (Get-Content -Raw -Path $DefaultsPath | ConvertFrom-Json).bundleVersion
|
|
$CodeQLVersion = "0.0.0-" + $CodeQLBundleName.split("-")[-1]
|
|
py -3 $Env:GITHUB_WORKSPACE\\python-setup\\auto_install_packages.py C:\\hostedtoolcache\\windows\\CodeQL\\$CodeQLVersion\\x64\\codeql
|
|
|
|
- name: Setup for extractor
|
|
run: |
|
|
echo $Env:CODEQL_PYTHON
|
|
|
|
py -3 $Env:GITHUB_WORKSPACE\\python-setup\\tests\\from_python_exe.py $Env:CODEQL_PYTHON
|
|
|
|
- name: Verify packages installed
|
|
run: |
|
|
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\tests\\check_requests_2_26_0.ps1"
|
|
powershell -File $cmd $Env:PYTHON_VERSION
|