diff options
author | hodbn <hodbn@users.noreply.github.com> | 2020-09-14 00:05:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-13 16:05:08 -0500 |
commit | b2ee10887c62ad8b1fadc2543383d0ab8552e57b (patch) | |
tree | 00c14c35a40f2c227a584d95bd7cde54a7fcd1d0 | |
parent | 5c1fa71bf4d6dbe6fef0836a03f6b5d85e924f41 (diff) | |
download | urllib3-b2ee10887c62ad8b1fadc2543383d0ab8552e57b.tar.gz |
Migrate Windows CI to GitHub Actions
-rw-r--r-- | .github/workflows/ci.yml | 47 | ||||
-rw-r--r-- | README.rst | 2 | ||||
-rw-r--r-- | _appveyor/install.ps1 | 229 | ||||
-rw-r--r-- | appveyor.yml | 58 | ||||
-rwxr-xr-x | ci/run_tests.sh | 4 |
5 files changed, 35 insertions, 305 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb838a82..d7cc62c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,10 @@ name: CI on: [push, pull_request] +defaults: + run: + shell: bash + jobs: package: runs-on: ubuntu-latest @@ -19,36 +23,45 @@ jobs: python3.7 setup.py sdist bdist_wheel; rstcheck README.rst CHANGES.rst python3.7 -m twine check dist/* - macOS: - runs-on: macos-latest - + test: strategy: fail-fast: false matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9-dev] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8] + os: [macos-latest, windows-latest] + experimental: [false] + include: + - python-version: 3.9-dev + os: macos-latest + experimental: true + runs-on: ${{ matrix.os }} + name: ${{ fromJson('{"macos-latest":"macOS","windows-latest":"Windows"}')[matrix.os] }} (${{ matrix.python-version }}) + continue-on-error: ${{ matrix.experimental }} steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set Up Python 3.7 to run nox - uses: actions/setup-python@v2 - with: - python-version: 3.7 + - name: Set Up Python - ${{ matrix.python-version }} - if: matrix.python_version != '3.7' uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + + - name: Set Up Python 3.7 to run nox + if: matrix.python-version != '3.7' + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install Dependencies - run: | - python3.7 -m pip install --upgrade nox + run: python -m pip install --upgrade nox + - name: Run Tests - run: | - version=${{ matrix.python-version }} - NOX_SESSION=test-${version%-dev} - nox -s $NOX_SESSION --error-on-missing-interpreters + run: ./ci/run_tests.sh + env: + PYTHON_VERSION: ${{ matrix.python-version }} + - name: Upload Coverage run: ./ci/upload_coverage.sh - shell: bash env: - JOB_NAME: 'macOS (${{ matrix.python-version }})' + JOB_NAME: "${{ runner.os }} (${{ matrix.python-version }})" @@ -7,7 +7,7 @@ </p> <p align="center"> <a href="https://travis-ci.org/urllib3/urllib3"><img alt="Build status on Travis" src="https://travis-ci.org/urllib3/urllib3.svg?branch=master" /></a> - <a href="https://ci.appveyor.com/project/urllib3/urllib3"><img alt="Build status on AppVeyor" src="https://img.shields.io/appveyor/ci/urllib3/urllib3/master.svg" /></a> + <a href="https://github.com/urllib3/urllib3/actions?query=workflow%3ACI"><img alt="Build status on GitHub" src="https://github.com/urllib3/urllib3/workflows/CI/badge.svg" /></a> <a href="https://urllib3.readthedocs.io/en/latest/"><img alt="Documentation Status" src="https://readthedocs.org/projects/urllib3/badge/?version=latest" /></a> <a href="https://codecov.io/gh/urllib3/urllib3"><img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/urllib3/urllib3.svg" /></a> <a href="https://pypi.org/project/urllib3/"><img alt="PyPI Version" src="https://img.shields.io/pypi/v/urllib3.svg?maxAge=86400" /></a> diff --git a/_appveyor/install.ps1 b/_appveyor/install.ps1 deleted file mode 100644 index 94d6f018..00000000 --- a/_appveyor/install.ps1 +++ /dev/null @@ -1,229 +0,0 @@ -# Sample script to install Python and pip under Windows -# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer -# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ - -$MINICONDA_URL = "http://repo.continuum.io/miniconda/" -$BASE_URL = "https://www.python.org/ftp/python/" -$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" -$GET_PIP_PATH = "C:\get-pip.py" - -$PYTHON_PRERELEASE_REGEX = @" -(?x) -(?<major>\d+) -\. -(?<minor>\d+) -\. -(?<micro>\d+) -(?<prerelease>[a-z]{1,2}\d+) -"@ - - -function Download ($filename, $url) { - $webclient = New-Object System.Net.WebClient - - $basedir = $pwd.Path + "\" - $filepath = $basedir + $filename - if (Test-Path $filename) { - Write-Host "Reusing" $filepath - return $filepath - } - - # Download and retry up to 3 times in case of network transient errors. - Write-Host "Downloading" $filename "from" $url - $retry_attempts = 2 - for ($i = 0; $i -lt $retry_attempts; $i++) { - try { - $webclient.DownloadFile($url, $filepath) - break - } - Catch [Exception]{ - Start-Sleep 1 - } - } - if (Test-Path $filepath) { - Write-Host "File saved at" $filepath - } else { - # Retry once to get the error message if any at the last try - $webclient.DownloadFile($url, $filepath) - } - return $filepath -} - - -function ParsePythonVersion ($python_version) { - if ($python_version -match $PYTHON_PRERELEASE_REGEX) { - return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro, - $matches.prerelease) - } - $version_obj = [version]$python_version - return ($version_obj.major, $version_obj.minor, $version_obj.build, "") -} - - -function DownloadPython ($python_version, $platform_suffix) { - $major, $minor, $micro, $prerelease = ParsePythonVersion $python_version - - if (($major -le 2 -and $micro -eq 0) ` - -or ($major -eq 3 -and $minor -le 2 -and $micro -eq 0) ` - ) { - $dir = "$major.$minor" - $python_version = "$major.$minor$prerelease" - } else { - $dir = "$major.$minor.$micro" - } - - if ($prerelease) { - if (($major -le 2) ` - -or ($major -eq 3 -and $minor -eq 1) ` - -or ($major -eq 3 -and $minor -eq 2) ` - -or ($major -eq 3 -and $minor -eq 3) ` - ) { - $dir = "$dir/prev" - } - } - - if (($major -le 2) -or ($major -le 3 -and $minor -le 4)) { - $ext = "msi" - if ($platform_suffix) { - $platform_suffix = ".$platform_suffix" - } - } else { - $ext = "exe" - if ($platform_suffix) { - $platform_suffix = "-$platform_suffix" - } - } - - $filename = "python-$python_version$platform_suffix.$ext" - $url = "$BASE_URL$dir/$filename" - $filepath = Download $filename $url - return $filepath -} - - -function InstallPython ($python_version, $architecture, $python_home) { - Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home - if (Test-Path $python_home) { - Write-Host $python_home "already exists, skipping." - return $false - } - if ($architecture -eq "32") { - $platform_suffix = "" - } else { - $platform_suffix = "amd64" - } - $installer_path = DownloadPython $python_version $platform_suffix - $installer_ext = [System.IO.Path]::GetExtension($installer_path) - Write-Host "Installing $installer_path to $python_home" - $install_log = $python_home + ".log" - if ($installer_ext -eq '.msi') { - InstallPythonMSI $installer_path $python_home $install_log - } else { - InstallPythonEXE $installer_path $python_home $install_log - } - if (Test-Path $python_home) { - Write-Host "Python $python_version ($architecture) installation complete" - } else { - Write-Host "Failed to install Python in $python_home" - Get-Content -Path $install_log - Exit 1 - } -} - - -function InstallPythonEXE ($exepath, $python_home, $install_log) { - $install_args = "/quiet InstallAllUsers=1 TargetDir=$python_home" - RunCommand $exepath $install_args -} - - -function InstallPythonMSI ($msipath, $python_home, $install_log) { - $install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home" - $uninstall_args = "/qn /x $msipath" - RunCommand "msiexec.exe" $install_args - if (-not(Test-Path $python_home)) { - Write-Host "Python seems to be installed else-where, reinstalling." - RunCommand "msiexec.exe" $uninstall_args - RunCommand "msiexec.exe" $install_args - } -} - -function RunCommand ($command, $command_args) { - Write-Host $command $command_args - Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru -} - - -function InstallPip ($python_home) { - $pip_path = $python_home + "\Scripts\pip.exe" - $python_path = $python_home + "\python.exe" - if (-not(Test-Path $pip_path)) { - Write-Host "Installing pip..." - $webclient = New-Object System.Net.WebClient - $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) - Write-Host "Executing:" $python_path $GET_PIP_PATH - & $python_path $GET_PIP_PATH - } else { - Write-Host "pip already installed." - } -} - - -function DownloadMiniconda ($python_version, $platform_suffix) { - if ($python_version -eq "3.4") { - $filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe" - } else { - $filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe" - } - $url = $MINICONDA_URL + $filename - $filepath = Download $filename $url - return $filepath -} - - -function InstallMiniconda ($python_version, $architecture, $python_home) { - Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home - if (Test-Path $python_home) { - Write-Host $python_home "already exists, skipping." - return $false - } - if ($architecture -eq "32") { - $platform_suffix = "x86" - } else { - $platform_suffix = "x86_64" - } - $filepath = DownloadMiniconda $python_version $platform_suffix - Write-Host "Installing" $filepath "to" $python_home - $install_log = $python_home + ".log" - $args = "/S /D=$python_home" - Write-Host $filepath $args - Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru - if (Test-Path $python_home) { - Write-Host "Python $python_version ($architecture) installation complete" - } else { - Write-Host "Failed to install Python in $python_home" - Get-Content -Path $install_log - Exit 1 - } -} - - -function InstallMinicondaPip ($python_home) { - $pip_path = $python_home + "\Scripts\pip.exe" - $conda_path = $python_home + "\Scripts\conda.exe" - if (-not(Test-Path $pip_path)) { - Write-Host "Installing pip..." - $args = "install --yes pip" - Write-Host $conda_path $args - Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru - } else { - Write-Host "pip already installed." - } -} - -function main () { - InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON - InstallPip $env:PYTHON -} - -main
\ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 633b1d38..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,58 +0,0 @@ -# AppVeyor.yml from https://github.com/ogrisel/python-appveyor-demo -# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ - -skip_branch_with_pr: true -build: off - -environment: - - matrix: - - PYTHON: "C:\\Python27-x64" - PYTHON_VERSION: "2.7.x" - PYTHON_ARCH: "64" - NOX_SESSION: "test-2.7" - - - PYTHON: "C:\\Python35-x64" - PYTHON_VERSION: "3.5.x" - PYTHON_ARCH: "64" - NOX_SESSION: "test-3.5" - - - PYTHON: "C:\\Python36-x64" - PYTHON_VERSION: "3.6.x" - PYTHON_ARCH: "64" - NOX_SESSION: "test-3.6" - - - PYTHON: "C:\\Python37-x64" - PYTHON_VERSION: "3.7.x" - PYTHON_ARCH: "64" - NOX_SESSION: "test-3.7" - - - PYTHON: "C:\\Python38-x64" - PYTHON_VERSION: "3.8.x" - PYTHON_ARCH: "64" - NOX_SESSION: "test-3.8" - -cache: - - C:\Users\appveyor\AppData\Local\pip\Cache - -install: - # Install Python (from the official .msi of http://python.org) and pip when - # not already installed. - - ps: if (-not(Test-Path($env:PYTHON))) { & _appveyor\install.ps1 } - - # Prepend newly installed Python to the PATH of this build (this cannot be - # done from inside the powershell script as it would require to restart - # the parent CMD process). - - SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH% - - # Upgrade to the latest version of pip to avoid it displaying warnings - # about it being out of date. - - C:\Python36-x64\python.exe -m pip install --upgrade pip wheel - - C:\Python36-x64\python.exe -m pip install nox - -test_script: - - C:\Python36-x64\python.exe -m nox -s "%NOX_SESSION%" - -on_success: - - pip install codecov - - codecov --env NOX_SESSION --file coverage.xml diff --git a/ci/run_tests.sh b/ci/run_tests.sh new file mode 100755 index 00000000..df8726a7 --- /dev/null +++ b/ci/run_tests.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +NOX_SESSION=test-${PYTHON_VERSION%-dev} +nox -s $NOX_SESSION --error-on-missing-interpreters |