Merge pull request #94 from mithro/gha Convert travis to GitHub Actions
diff --git a/.github/travis/check_license.sh b/.github/ci/check_license.sh similarity index 78% rename from .github/travis/check_license.sh rename to .github/ci/check_license.sh index 2efc7f3..45f5e3b 100755 --- a/.github/travis/check_license.sh +++ b/.github/ci/check_license.sh
@@ -8,6 +8,8 @@ # # SPDX-License-Identifier: ISC +set -e + echo echo "===========================" echo "Check SPDX identifier" @@ -17,8 +19,13 @@ ERROR_FILES="" FILES_TO_CHECK=`find . \ -type f \( -name '*.sh' -o -name '*.py' -o -name 'Makefile' -o -name '*.v' \) \ - \( -not -path "*/.*/*" -not -path "*/third_party/*" -not -path "*/env/*" \) \ - \( -not -path "*/*/__init__.py" -not -path "./miniconda.sh" \)` + \( -not -path "*/.*/*" \) \ + \( -not -path "*/build/*" \) \ + \( -not -path "*/env/*" \) \ + \( -not -path "*/src/*" \) \ + \( -not -path "*/third_party/*" \) \ + \( -not -path "*/*/__init__.py" \) \ + \( -not -path "./miniconda.sh" \) | sort` for file in $FILES_TO_CHECK; do echo "Checking $file" @@ -29,7 +36,14 @@ for file in $ERROR_FILES; do echo "ERROR: $file does not have license information." done - return 1 + exit 1 +fi + +THIRD_PARTY_DIRS=$(shopt -s nullglob; echo third_party/*) +ERROR_NO_LICENSE="" + +if [ -z "$THIRD_PARTY_DIRS" ]; then + exit 0 fi echo @@ -46,9 +60,6 @@ done } -THIRD_PARTY_DIRS=`ls -d third_party/*` -ERROR_NO_LICENSE="" - for dir in $THIRD_PARTY_DIRS; do # Checks if we are not in a submodule if check_if_submodule $dir; then @@ -61,5 +72,5 @@ for dir in $ERROR_NO_LICENSE; do echo "ERROR: $dir does not have the LICENSE file." done - return 1 -fi \ No newline at end of file + exit 1 +fi
diff --git a/.github/ci/check_python_script.sh b/.github/ci/check_python_script.sh new file mode 100755 index 0000000..ff5e3ac --- /dev/null +++ b/.github/ci/check_python_script.sh
@@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (C) 2020 The SymbiFlow Authors. +# +# Use of this source code is governed by a ISC-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/ISC +# +# SPDX-License-Identifier: ISC + +set -e + +echo +echo "===================================" +echo "Check python utf coding and shebang" +echo "===================================" +echo + +ERROR_FILES_SHEBANG="" +ERROR_FILES_UTF_CODING="" +FILES_TO_CHECK=`find . \ + -type f \( -name '*.py' \) \ + \( -not -path "*/.*/*" \) \ + \( -not -path "*/build/*" \) \ + \( -not -path "*/env/*" \) \ + \( -not -path "*/src/*" \) \ + \( -not -path "*/third_party/*" \) \ + \( -not -path "*/*/__init__.py" \) \ + \( -not -path "./miniconda.sh" \) | sort` + +for file in $FILES_TO_CHECK; do + echo "Checking $file" + grep -q "\#\!/usr/bin/env python3" $file || ERROR_FILES_SHEBANG="$ERROR_FILES_SHEBANG $file" + grep -q "\#.*coding: utf-8" $file || ERROR_FILES_UTF_CODING="$ERROR_FILES_UTF_CODING $file" +done + +if [ ! -z "$ERROR_FILES_SHEBANG" ]; then + for file in $ERROR_FILES_SHEBANG; do + echo "ERROR: $file does not have the python3 shebang." + done +fi + +if [ ! -z "$ERROR_FILES_UTF_CODING" ]; then + for file in $ERROR_FILES_UTF_CODING; do + echo "ERROR: $file does not have the utf encoding set." + done +fi +echo +if [ ! -z "${ERROR_FILES_SHEBANG}${ERROR_FILES_UTF_CODING}" ]; then + exit 1 +fi
diff --git a/.github/travis/check_python_script.sh b/.github/travis/check_python_script.sh deleted file mode 100644 index 57d792f..0000000 --- a/.github/travis/check_python_script.sh +++ /dev/null
@@ -1,35 +0,0 @@ -#!/bin/bash - -echo -echo "===================================" -echo "Check python utf coding and shebang" -echo "===================================" -echo - -ERROR_FILES_SHEBANG="" -ERROR_FILES_UTF_CODING="" -FILES_TO_CHECK=`find . \ - -type f \( -name '*.py' \) \ - \( -not -path "*/.*/*" -not -path "*/third_party/*" -not -path "*/env/*" \)` - -for file in $FILES_TO_CHECK; do - echo "Checking $file" - grep -q "\#\!/usr/bin/env python3" $file || ERROR_FILES_SHEBANG="$ERROR_FILES_SHEBANG $file" - grep -q "\#.*coding: utf-8" $file || ERROR_FILES_UTF_CODING="$ERROR_FILES_UTF_CODING $file" -done - -if [ ! -z "$ERROR_FILES_SHEBANG" ]; then - for file in $ERROR_FILES_SHEBANG; do - echo "ERROR: $file does not have the python3 shebang." - done - return 1 -fi - -if [ ! -z "$ERROR_FILES_UTF_CODING" ]; then - for file in $ERROR_FILES_UTF_CODING; do - echo "ERROR: $file does not have the utf encoding set." - done - return 1 -fi - -echo \ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3286b14 --- /dev/null +++ b/.github/workflows/ci.yml
@@ -0,0 +1,44 @@ +name: CI + +on: [push, pull_request] + +jobs: + Checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Licenses + run: ./.github/ci/check_license.sh + - name: Python Script Headers + run: ./.github/ci/check_python_script.sh + + Tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + + - name: Setup + run: | + sed -i -e's/- python/- python=${{ matrix.python-version }}/' environment.yml + cat environment.yml + # FIXME: #65 - Replace with `make-env` + ./prepareenv.sh + + - name: Test + run: | + source "$HOME/miniconda/etc/profile.d/conda.sh" + conda activate yosys-env + which python + python --version + which tox + TOXENV="$(echo py${{ matrix.python-version }} | sed -e's/\.//g')" tox + - name: Upload test results + uses: actions/upload-artifact@v2 + with: + name: test-results-${{ matrix.python-version }} + path: junit/python${{ matrix.python-version }}-test-results.xml + if: ${{ always() }}
diff --git a/.gitignore b/.gitignore index 5cce36f..ce56640 100644 --- a/.gitignore +++ b/.gitignore
@@ -18,6 +18,7 @@ lib64/ parts/ sdist/ +src/ var/ wheels/ *.egg-info/ @@ -104,3 +105,7 @@ .mypy_cache/ *.sw* + +miniconda.sh +junit +docs/tests
diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c9d1b5e..0000000 --- a/.travis.yml +++ /dev/null
@@ -1,19 +0,0 @@ -language: python - -python: - - 3.5 - - 3.6 - - 3.7 - -install: - - source prepareenv.sh - - source .github/travis/check_license.sh - - source .github/travis/check_python_script.sh - -script: - - conda activate yosys-env - - which tox - - TOXENV="py${TRAVIS_PYTHON_VERSION//./}" tox - -notifications: - email: false
diff --git a/MANIFEST.in b/MANIFEST.in index e278e4f..cb0dfbe 100644 --- a/MANIFEST.in +++ b/MANIFEST.in
@@ -1,7 +1,9 @@ exclude .readthedocs.yml +exclude environment.yml exclude tox.ini exclude *.swp prune conf +prune third_party # Include the README include *.md
diff --git a/conf/environment.yml b/environment.yml similarity index 64% rename from conf/environment.yml rename to environment.yml index fcdf0c1..336dad0 100644 --- a/conf/environment.yml +++ b/environment.yml
@@ -2,7 +2,8 @@ channels: - symbiflow dependencies: + - python - symbiflow-yosys + - pip - pip: - - tox - - flake8 + - -r requirements.txt
diff --git a/prepareenv.sh b/prepareenv.sh index 0ff3322..238f04c 100755 --- a/prepareenv.sh +++ b/prepareenv.sh
@@ -15,6 +15,6 @@ conda config --set always_yes yes --set changeps1 no conda install -q setuptools conda update -q conda -conda env create --file conf/environment.yml +conda env create --file environment.yml conda config --set env_prompt '({name})' conda activate yosys-env
diff --git a/requirements.txt b/requirements.txt index 31ca074..27481cc 100644 --- a/requirements.txt +++ b/requirements.txt
@@ -1,3 +1,7 @@ +docutils lxml pyjson +pylint +tox + -e git://github.com/SymbiFlow/vtr-xml-utils#egg=vtr-xml-utils
diff --git a/setup.py b/setup.py index cd18169..55a9729 100644 --- a/setup.py +++ b/setup.py
@@ -25,7 +25,7 @@ description="Python library for generating VPR architecture \ description files from Verilog models.", long_description=long_description, - long_description_content_type="text/markdown", + long_description_content_type="text/x-rst", url="https://github.com/SymbiFlow/python-symbiflow-v2x", packages=setuptools.find_packages(), install_requires=[
diff --git a/third_party/.keepme b/third_party/.keepme new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/third_party/.keepme
diff --git a/tox.ini b/tox.ini index 7320ce1..2d1ac65 100644 --- a/tox.ini +++ b/tox.ini
@@ -1,30 +1,26 @@ [tox] -envlist = py{27,34,35,36,37} +envlist = py{35,36,37,38,39} [testenv] setenv = PYTHONPATH={toxinidir}/v2x basepython = - py27: python2.7 - py34: python3.4 py35: python3.5 py36: python3.6 py37: python3.7 + py38: python3.8 + py39: python3.9 deps = check-manifest - # If your project uses README.rst, uncomment the following: - # readme_renderer + readme_renderer flake8 pytest commands = check-manifest --ignore tox.ini,tests,*.pyc,*.swp python --version - # This repository uses a Markdown long_description, so the -r flag to - # `setup.py check` is not needed. If your project contains a README.rst, - # use `python setup.py check -m -r -s` instead. - python setup.py check -m -s + python setup.py check -m -r -s flake8 setup.py v2x - pytest --doctest-modules -vv v2x + pytest --doctest-modules -vv v2x --junitxml=junit/{basepython}-test-results.xml pytest -vv [flake8] exclude = .tox,*.egg,build,data