diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f97e962 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,66 @@ +# 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 install flake8 + 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: Run flake + continue-on-error: false + 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 + twine check dist/* 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):