From d86ef8a547781dd8be2914496e976d0ae8fa9d41 Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 6 Oct 2020 20:55:35 +0200 Subject: [PATCH 1/4] Create github actions configuration Run all test steps previously done by the travis configuration (minus flake, which is failing) --- .github/workflows/main.yml | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..47a7173 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,61 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + test: + # The type of runner that the job will run on + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-18.04] + python-version: [2.7] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install test dependencies + run: | + pip install pyroma + pip install check-manifest + pip install twine + pip install wheel + pip list + + - name: Compile code + run: python -m compileall -f . + + - name: Run unit tests + run: test/test.py --unit --exit-early + + - name: Run integration tests + run: test/test.py + + - name: Check package quality + run: pyroma -n 9 . + + - name: Check the completeness of MANIFEST.in + run: check-manifest . + + - name: Check distribution + run: | + python setup.py sdist bdist_wheel + twine check dist/* From 8dd8c2c2c615d93b6dee225abd56a6c1ea5a897b Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 6 Oct 2020 22:41:28 +0200 Subject: [PATCH 2/4] Run flake --- .github/workflows/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 47a7173..6ee8a13 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,7 @@ jobs: pip install check-manifest pip install twine pip install wheel + pip install flake8 pip list - name: Compile code @@ -54,7 +55,11 @@ jobs: - name: Check the completeness of MANIFEST.in run: check-manifest . - + + - name: Run flake + continue-on-error: true + run: flake8 --exclude=build,venv --ignore= --max-line-length=200 --max-complexity=75 --show-source --statistics . + - name: Check distribution run: | python setup.py sdist bdist_wheel From 323b9cfab216bcf4e3e09061acc0a0f0c9024708 Mon Sep 17 00:00:00 2001 From: Mathias Tausig Date: Wed, 7 Oct 2020 19:15:54 +0000 Subject: [PATCH 3/4] Improve codestyle [Flake error E741](https://www.flake8rules.com/rules/E741.html) fixed. Replaced single digit variablenames with meaningful names Replaced re enum with its long version Fixes #14 --- lib/cfv/common.py | 34 +++++++++++++++++----------------- lib/cfv/osutil.py | 2 +- lib/cfv/strutil.py | 6 +++--- test/cfvtest.py | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/cfv/common.py b/lib/cfv/common.py index 99ef83e..142c4f0 100644 --- a/lib/cfv/common.py +++ b/lib/cfv/common.py @@ -735,10 +735,10 @@ class FooSum_Base(TextChksumType): def do_test_chksumfile_print_testingline(self, file): TextChksumType.do_test_chksumfile_print_testingline(self, file, parse_commentline(file.peekline(512), ';#')) - def do_test_chksumline(self, l): - if l[0] in ';#': + def do_test_chksumline(self, line): + if line[0] in ';#': return - x = self._foosum_rem.match(l) + x = self._foosum_rem.match(line) if not x: return -1 if x.group(2) == ' ': @@ -897,8 +897,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(r'MD5 \(.+\) = [0-9a-fA-F]{3 _bsdmd5rem = re.compile(r'MD5 \((.+)\) = ([0-9a-fA-F]{32})[\r\n]*$') - def do_test_chksumline(self, l): - x = self._bsdmd5rem.match(l) + def do_test_chksumline(self, line): + x = self._bsdmd5rem.match(line) if not x: return -1 self.test_file(x.group(1), unhexlify(x.group(2))) @@ -1397,10 +1397,10 @@ def do_test_chksumfile_print_testingline(self, file): # override the default testing line to show first SFV comment line, if any TextChksumType.do_test_chksumfile_print_testingline(self, file, parse_commentline(file.peekline(512), ';')) - def do_test_chksumline(self, l): - if l[0] == ';': + def do_test_chksumline(self, line): + if line[0] == ';': return - x = self._sfvrem.match(l) + x = self._sfvrem.match(line) if not x: return -1 self.test_file(x.group(1), unhexlify(x.group(2))) @@ -1502,8 +1502,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(_csvfnautore + '[0-9]+,[0-9a _csvrem = re.compile(_csvfnre + r'([0-9]+),([0-9a-fA-F]{8}),') - def do_test_chksumline(self, l): - x = self._csvrem.match(l) + def do_test_chksumline(self, line): + x = self._csvrem.match(line) if not x: return -1 self.test_file(csvunquote(x.group(1), x.group(2)), unhexlify(x.group(4)), int(x.group(3))) @@ -1534,8 +1534,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(r'%s[0-9]+,[0-9a-fA-F]{8},%s _csv4rem = re.compile(r'%s([0-9]+),([0-9a-fA-F]{8}),%s' % (_csvfnre, _csvstrre)) - def do_test_chksumline(self, l): - x = self._csv4rem.match(l) + def do_test_chksumline(self, line): + x = self._csv4rem.match(line) if not x: return -1 name = csvunquote(x.group(1), x.group(2)) @@ -1569,8 +1569,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(_csvfnautore + '[0-9]+,[\n\r _csv2rem = re.compile(_csvfnre + r'([0-9]+),') - def do_test_chksumline(self, l): - x = self._csv2rem.match(l) + def do_test_chksumline(self, line): + x = self._csv2rem.match(line) if not x: return -1 self.test_file(csvunquote(x.group(1), x.group(2)), None, int(x.group(3))) @@ -1646,11 +1646,11 @@ def do_test_chksumfile_print_testingline(self, file): _commentboundary = re.compile(r'^-+(\s+-+){1,4}\s*$') _nstrip = re.compile(r'[.,]') - def do_test_chksumline(self, l): - if self._commentboundary.match(l): + def do_test_chksumline(self, line): + if self._commentboundary.match(line): self.in_comments = not self.in_comments return - x = self._crcrem.match(l) + x = self._crcrem.match(line) if not x: if self.in_comments: return diff --git a/lib/cfv/osutil.py b/lib/cfv/osutil.py index d09e76c..188a1e0 100644 --- a/lib/cfv/osutil.py +++ b/lib/cfv/osutil.py @@ -109,7 +109,7 @@ def path_split(filename): return parts -def strippath(filename, num='a', _splitdrivere=re.compile(r'[a-z]:[/\\]', re.I)): +def strippath(filename, num='a', _splitdrivere=re.compile(r'[a-z]:[/\\]', re.IGNORECASE)): """Strip off path components from the left side of the filename. >>> strippath(os.path.join('c:','foo','bar','baz')) diff --git a/lib/cfv/strutil.py b/lib/cfv/strutil.py index 15af9bf..ef174ea 100644 --- a/lib/cfv/strutil.py +++ b/lib/cfv/strutil.py @@ -3,17 +3,17 @@ from StringIO import StringIO -def safesort(l): +def safesort(line): sl = [] ul = [] - for s in l: + for s in line: if isinstance(s, str): sl.append(s) else: ul.append(s) sl.sort() ul.sort() - l[:] = ul + sl + line[:] = ul + sl def showfn(s): diff --git a/test/cfvtest.py b/test/cfvtest.py index f46dfd1..f7a83bd 100644 --- a/test/cfvtest.py +++ b/test/cfvtest.py @@ -46,7 +46,7 @@ def isatty(self): def write(self, s): pass - def writelines(self, l): + def writelines(self, lines): pass def flush(self): From 3d1a5fc2ae58be45b4302dc0fa1c79eba0a337a4 Mon Sep 17 00:00:00 2001 From: Mathias Tausig Date: Wed, 7 Oct 2020 19:19:26 +0000 Subject: [PATCH 4/4] Do not ignore flake errors in the CI build --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ee8a13..f97e962 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: run: check-manifest . - name: Run flake - continue-on-error: true + continue-on-error: false run: flake8 --exclude=build,venv --ignore= --max-line-length=200 --max-complexity=75 --show-source --statistics . - name: Check distribution