From 8b1ec1591c7f86b93b75c49df1e63b12c519b812 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 5 Dec 2022 13:40:10 +0300 Subject: [PATCH] Feat: Migrate to Github Actions --- .../.github/workflows/test-publish.yaml | 77 ++++++++++++++++ project_template/.travis.yml | 39 -------- project_template/appveyor.yml | 90 ------------------- .../{ => devscripts}/run_with_env.cmd | 0 4 files changed, 77 insertions(+), 129 deletions(-) create mode 100644 project_template/.github/workflows/test-publish.yaml delete mode 100644 project_template/.travis.yml delete mode 100644 project_template/appveyor.yml rename project_template/{ => devscripts}/run_with_env.cmd (100%) diff --git a/project_template/.github/workflows/test-publish.yaml b/project_template/.github/workflows/test-publish.yaml new file mode 100644 index 0000000..5242df7 --- /dev/null +++ b/project_template/.github/workflows/test-publish.yaml @@ -0,0 +1,77 @@ +name: Test, build, publish + +# Run tests (all branches), +# for tags build wheels, publish wheels to PyPI. + +on: [push, pull_request] + +jobs: + run-tests: + + strategy: + matrix: + os: [ubuntu-latest, macos-11, windows-latest] + python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy-2.7", "pypy-3.7"] + include: + - os: ubuntu-latest + os-name: Linux + pip-cache-path: ~/.cache/pip + - os: macos-11 + os-name: MacOS + pip-cache-path: ~/Library/Caches/pip + - os: windows-latest + os-name: w32 + pip-cache-path: ~\AppData\Local\pip\Cache + + name: Python ${{ matrix.python-version }} @ ${{ matrix.os-name }} + runs-on: ${{ matrix.os }} + + steps: + + # Setup Python/pip + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Cache pip + uses: actions/cache@v3 + with: + path: ${{ matrix.pip-cache-path }} + key: ${{ runner.os }}-pip + + # Setup tox + - name: Install dependencies + run: | + python --version + python -m pip install --upgrade pip setuptools wheel + pip --version + pip install --upgrade virtualenv tox + - name: Set TOXENV + run: | + import os, sys + if hasattr(sys, 'pypy_version_info'): + toxenv = 'pypy' + else: + pyver = '%d%d' % tuple(sys.version_info[:2]) + toxenv = 'py%s' % pyver + if os.name == 'posix': + toxenv += ',py%s-flake8' % pyver + with open(os.environ['GITHUB_ENV'], 'a') as f: + f.write('TOXENV=' + toxenv + '\n') + print(toxenv) + shell: python + + - name: Run tox + run: | + python -c "import os; print(os.environ['TOXENV'])" + tox --version + tox + + - name: Build and publish wheel + run: | + pip install -U pip setuptools twine wheel + python setup.py bdist_wheel + twine upload --disable-progress-bar --skip-existing dist\* + if: ${{ startsWith(github.ref, 'refs/tags/') }} + env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} diff --git a/project_template/.travis.yml b/project_template/.travis.yml deleted file mode 100644 index c3d76aa..0000000 --- a/project_template/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: python - -python: - - "2.7" - -cache: pip - -matrix: - include: - - python: "2.7" - env: TOXENV=py27 - - python: "3.4" - env: TOXENV=py34 - - python: "3.5" - env: TOXENV=py35 - - python: "3.6" - env: TOXENV=py36 - - python: "3.7" - dist: xenial - env: TOXENV=py37 - - python: "2.7" - env: TOXENV=py27-flake8 - - python: "3.7" - dist: xenial - env: TOXENV=py37-flake8 - - python: "pypy" - env: TOXENV=pypy - - allow_failures: - - env: TOXENV=pypy - -install: - - travis_retry pip install --upgrade "pip < 19.1" setuptools tox ppu - -script: - - tox - -before_cache: - - remove-old-files.py -o 180 ~/.cache/pip diff --git a/project_template/appveyor.yml b/project_template/appveyor.yml deleted file mode 100644 index 4452853..0000000 --- a/project_template/appveyor.yml +++ /dev/null @@ -1,90 +0,0 @@ -# Test on windows -# Heavily inspired by Oliver Grisel's appveyor-demo (https://github.com/ogrisel/python-appveyor-demo) -version: '{branch}-{build}' - -cache: - - '%LOCALAPPDATA%\pip\Cache' - -# Match travis -clone_depth: 50 - -environment: - global: - # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the - # /E:ON and /V:ON options are not enabled in the batch script intepreter - # See: http://stackoverflow.com/a/13751649/163740 - CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\run_with_env.cmd" - - matrix: - - TOXENV: "py27" - PYTHON_VERSION: "2.7" - PYTHON_ARCH: "32" - PYTHON_HOME: "C:\\Python27" - - TOXENV: "py27" - PYTHON_VERSION: "2.7" - PYTHON_ARCH: "64" - PYTHON_HOME: "C:\\Python27-x64" - - TOXENV: "py34" - PYTHON_VERSION: "3.4" - PYTHON_ARCH: "32" - PYTHON_HOME: "C:\\Python34" - - TOXENV: "py34" - PYTHON_VERSION: "3.4" - PYTHON_ARCH: "64" - PYTHON_HOME: "C:\\Python34-x64" - - TOXENV: "py35" - PYTHON_VERSION: "3.5" - PYTHON_ARCH: "32" - PYTHON_HOME: "C:\\Python35" - - TOXENV: "py35" - PYTHON_VERSION: "3.5" - PYTHON_ARCH: "64" - PYTHON_HOME: "C:\\Python35-x64" - - TOXENV: "py36" - PYTHON_VERSION: "3.6" - PYTHON_ARCH: "32" - PYTHON_HOME: "C:\\Python36" - - TOXENV: "py36" - PYTHON_VERSION: "3.6" - PYTHON_ARCH: "64" - PYTHON_HOME: "C:\\Python36-x64" - - TOXENV: "py37" - PYTHON_VERSION: "3.7" - PYTHON_ARCH: "32" - PYTHON_HOME: "C:\\Python37" - - TOXENV: "py37" - PYTHON_VERSION: "3.7" - PYTHON_ARCH: "64" - PYTHON_HOME: "C:\\Python37-x64" - -install: - # Ensure we use the right python version - - "SET PATH=%PYTHON_HOME%;%PYTHON_HOME%\\Scripts;%PATH%" - - "SET TOXPYTHON=%PYTHON_HOME%\\python.exe" - - "python --version" - - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" - - "python -m pip install --upgrade \"pip < 19.1\" setuptools" - - "pip install --upgrade \"tox < 3.1\" ppu" - - "pip --version" - -# No build step - we don't have C extensions -build: false - -test_script: - - "%CMD_IN_ENV% tox" - -#after_test: -# # If tests are successful and we've tested a tag, create binary package -# - if "%APPVEYOR_REPO_TAG%" == "true" ( -# pip install --upgrade wheel && -# %CMD_IN_ENV% python setup.py bdist_wheel && -# ls dist -# ) -# - remove-old-files.py -o 180 %LOCALAPPDATA%\\pip\\Cache -# -#artifacts: -# # Archive the generated packages in the ci.appveyor.com build report -# - path: dist\* - -after_test: - - "remove-old-files.py -o 180 %LOCALAPPDATA%\\pip\\Cache" diff --git a/project_template/run_with_env.cmd b/project_template/devscripts/run_with_env.cmd similarity index 100% rename from project_template/run_with_env.cmd rename to project_template/devscripts/run_with_env.cmd -- 2.39.2