1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 13:44:14 +01:00

Switch to github actions

This commit is contained in:
Johan Andersson 2020-09-06 15:08:16 +02:00
parent 7c2b93bcc4
commit 295d924a44
2 changed files with 97 additions and 25 deletions

85
.github/workflows/tests.yaml vendored Normal file
View File

@ -0,0 +1,85 @@
name: Tests
on: [push]
jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {name: '3.8', python: '3.8', os: ubuntu-latest, architecture: 'x64', cibuild: "yes"}
- {name: '3.7', python: '3.7', os: ubuntu-latest, architecture: 'x64', cibuild: "no"}
- {name: '3.6', python: '3.6', os: ubuntu-latest, architecture: 'x64', cibuild: "no"}
- {name: Windows, python: '3.8', os: windows-latest, architecture: 'x64', arch-cx: 'win-amd64', cx_name: 'amd64', cibuild: "no"}
- {name: WindowsX86, python: '3.8', os: windows-latest, architecture: 'x86', arch-cx: 'win32', cx_name: 'win32', cibuild: "no"}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.architecture }}
- name: update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- name: get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements*.txt') }}
- name: set full Python version in PY env var
# See https://pre-commit.com/#github-actions-example
run: echo "::set-env name=PY::$(python -VV | sha256sum | cut -d' ' -f1)"
- name: install deps
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: cache pre-commit
uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
if: matrix.os == 'ubuntu-latest'
- name: pre-commit
run: pre-commit run --all-files --show-diff-on-failure
if: matrix.os == 'ubuntu-latest'
- name: pytest
run: pytest -v --cov
- name: set version
run: python setversion.py
# Build .zip fil for *nix
- run: make
if: matrix.os == 'ubuntu-latest'
# Build .exe for windows
- name: build .exe
run: python setup.py build_exe
if: matrix.os == 'windows-latest'
- name: run the .exe file
run: build\\exe.${{ matrix.arch-cx }}-${{ matrix.python }}\\svtplay-dl.exe --version
if: matrix.os == 'windows-latest'
- run: |
mkdir svtplay-dl
xcopy /s build\\exe.${{ matrix.arch-cx }}-${{ matrix.python }} svtplay-dl
if: matrix.os == 'windows-latest'
- run: 7z a -tzip svtplay-dl-${{ matrix.cx_name }}.zip svtplay-dl
if: matrix.os == 'windows-latest'
- name: cibuild
run: python scripts/cibuild.py
env:
CIBUILD: ${{ matrix.cibuild }}
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}

View File

@ -1,49 +1,36 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse
import glob import glob
import logging import logging
import os import os
import re
import subprocess import subprocess
import sys import sys
from datetime import datetime from datetime import datetime
if sys.version_info[0] == 3 and sys.version_info[1] < 7:
from backports.datetime_fromisoformat import MonkeyPatch
MonkeyPatch.patch_fromisoformat()
root = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("cibuild") logger = logging.getLogger("cibuild")
parser = argparse.ArgumentParser(prog="cibuild")
general = parser.add_argument_group()
general.add_argument("-s", "--snapshots", action="store_true", dest="snapshot", default=False)
general.add_argument("-r", "--release", action="store_true", dest="release", default=False)
options = parser.parse_args()
twine_username = os.environ.get("TWINE_USERNAME") twine_username = os.environ.get("TWINE_USERNAME")
twine_password = os.environ.get("TWINE_PASSWORD") twine_password = os.environ.get("TWINE_PASSWORD")
docker_username = os.environ.get("DOCKER_USERNAME") docker_username = os.environ.get("DOCKER_USERNAME")
docker_password = os.environ.get("DOCKER_PASSWORD") docker_password = os.environ.get("DOCKER_PASSWORD")
aws_creds = os.environ.get("AWS_ACCESS_KEY_ID") aws_creds = os.environ.get("AWS_ACCESS_KEY_ID")
travis = os.environ.get("TRAVIS", "")
travis_tag = os.environ.get("TRAVIS_TAG", "")
travis_branch = os.environ.get("TRAVIS_BRANCH", "")
appveyor_tag = os.environ.get("APPVEYOR_REPO_TAG_NAME", "")
appveyor_branch = os.environ.get("APPVEYOR_REPO_BRANCH", "")
def tag(): def tag():
return travis_tag or appveyor_tag match = re.search("refs/tags/(.*)", os.environ.get("GITHUB_REF"))
if match:
return match.group(1)
return None
def branch(): def branch():
return travis_branch or appveyor_branch match = re.search("refs/heads/(.*)", os.environ.get("GITHUB_REF"))
if match:
return match.group(1)
return None
def docker_name(version): def docker_name(version):
@ -99,7 +86,7 @@ def aws_upload():
folder = "snapshots" folder = "snapshots"
version = snapshot_folder() version = snapshot_folder()
logger.info("Upload to aws {}/{}".format(folder, version)) logger.info("Upload to aws {}/{}".format(folder, version))
for file in ["svtplay-dl", "svtplay-dl.zip"]: for file in ["svtplay-dl", "svtplay-dl-amd64.zip", "svtplay-dl-win32.zip"]:
if os.path.isfile(file): if os.path.isfile(file):
subprocess.check_call(["aws", "s3", "cp", "{}".format(file), "s3://svtplay-dl/{}/{}/{}".format(folder, version, file)]) subprocess.check_call(["aws", "s3", "cp", "{}".format(file), "s3://svtplay-dl/{}/{}/{}".format(folder, version, file)])
@ -120,9 +107,9 @@ if not tag() and branch() != "master":
sys.exit(0) sys.exit(0)
build_package() build_package()
if travis: if os.environ.get("CIBUILD") == "yes":
build_docker() build_docker()
aws_upload() aws_upload()
if tag() and travis: if tag() and os.environ.get("CIBUILD") == "yes":
pypi_upload() pypi_upload()