Skip to content

Commit

Permalink
Merge pull request #55 from cfv-project/fix-ci
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
lxp authored May 16, 2024
2 parents 1debfeb + e49a9f6 commit ed2b4bb
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 42 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/ci-python3-freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,32 @@ on:
branches: [ python3 ]
pull_request:
branches: [ python3 ]
workflow_dispatch:
schedule:
- cron: '37 15 * * 5'

# 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: macos-12
runs-on: ubuntu-latest

strategy:
matrix:
freebsd-release: [ '12.3', '13.1' ]
freebsd-release: [ '13.2', '13.3', '14.0' ]

# 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@v3
- uses: actions/checkout@v4

- name: Test in FreeBSD
uses: vmactions/freebsd-vm@v0.3.0
uses: vmactions/freebsd-vm@v1
with:
release: ${{ matrix.freebsd-release }}
usesh: true
prepare: pkg install -y python3 py39-pip coreutils cksfv git-tiny
prepare: pkg install -y python3 py39-pip coreutils cksfv git-tiny rust
run: |
set -ex
Expand All @@ -49,7 +52,8 @@ jobs:
ln -s /usr/local/bin/gsha384sum /usr/local/bin/sha384sum
ln -s /usr/local/bin/gsha512sum /usr/local/bin/sha512sum
pw useradd runner -u 501 -g staff -d /Users/runner
pw groupadd docker -g 127
pw useradd runner -u 1001 -g docker
# Install test dependencies
pip install pyroma
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/ci-python3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
branches: [ python3 ]
pull_request:
branches: [ python3 ]
workflow_dispatch:
schedule:
- cron: '37 15 * * 5'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -19,24 +22,30 @@ jobs:

strategy:
matrix:
os: [ ubuntu-22.04, ubuntu-20.04, ubuntu-18.04 ]
python-version: [ '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11' ]
os: [ ubuntu-24.04, ubuntu-22.04, ubuntu-20.04 ]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10', '3.11' ]
# Exclude unsupported OS/Python version combinations
exclude:
- os: ubuntu-22.04
python-version: '3.5'
- os: ubuntu-22.04
python-version: '3.6'
- os: ubuntu-24.04
python-version: '3.6'
- os: ubuntu-24.04
python-version: '3.7'
- os: ubuntu-24.04
python-version: '3.8'

# 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@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
check-latest: true

- name: Install test dependencies
run: |
Expand Down Expand Up @@ -67,7 +76,7 @@ jobs:
test/test.py -e --exit-early
- name: Check package quality
continue-on-error: ${{ contains(fromJson('["3.5", "3.6"]'), matrix.python-version) }}
continue-on-error: ${{ contains(fromJson('["3.6"]'), matrix.python-version) }}
run: pyroma -n 9 .

- name: Check the completeness of MANIFEST.in
Expand Down
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
2022-xx-xx - v3.0.1.dev0:
* WARNING: This is a development snapshot, not a stable release.
* Drop support for Python 3.5.
* Python 3.6 is now the minimum supported version.

2022-10-30 - v3.0.0:
* Tested platforms: Linux and FreeBSD. If there is interest in supporting more platforms (e.g. OSX and Windows), please get in contact with the project.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This is a [friendly fork of cfv](https://github.com/cfv-project/cfv) maintained

## Requirements

Python ≥ 3.5 – older versions might work, but are unsupported.
Python ≥ 3.6 – older versions might work, but are unsupported.
For Python 2 support, see the [python2 branch](https://github.com/cfv-project/cfv/tree/python2).

### Optional
Expand Down
52 changes: 26 additions & 26 deletions lib/cfv/BitTorrent/btformats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@


def check_info(info):
if type(info) != dict:
if type(info) is not dict:
raise ValueError('bad metainfo - not a dictionary')
pieces = info.get(b'pieces')
if type(pieces) != bytes or len(pieces) % 20 != 0:
if type(pieces) is not bytes or len(pieces) % 20 != 0:
raise ValueError('bad metainfo - bad pieces key')
piecelength = info.get(b'piece length')
if type(piecelength) != int or piecelength <= 0:
if type(piecelength) is not int or piecelength <= 0:
raise ValueError('bad metainfo - illegal piece length')
name = info.get(b'name')
if type(name) != bytes:
if type(name) is not bytes:
raise ValueError('bad metainfo - bad name')
if not reg.match(name):
raise ValueError('name %s disallowed for security reasons' % name)
if b'files' in info == b'length' in info:
raise ValueError('single/multiple file mix')
if b'length' in info:
length = info.get(b'length')
if type(length) != int or length < 0:
if type(length) is not int or length < 0:
raise ValueError('bad metainfo - bad length')
else:
files = info.get(b'files')
if type(files) != list:
if type(files) is not list:
raise ValueError
for f in files:
if type(f) != dict:
if type(f) is not dict:
raise ValueError('bad metainfo - bad file value')
length = f.get(b'length')
if type(length) != int or length < 0:
if type(length) is not int or length < 0:
raise ValueError('bad metainfo - bad length')
path = f.get(b'path')
if type(path) != list or path == []:
if type(path) is not list or path == []:
raise ValueError('bad metainfo - bad path')
for p in path:
if type(p) != bytes:
if type(p) is not bytes:
raise ValueError('bad metainfo - bad path dir')
if not reg.match(p):
raise ValueError('path %s disallowed for security reasons' % p)
Expand All @@ -54,51 +54,51 @@ def check_info(info):


def check_message(message):
if type(message) != dict:
if type(message) is not dict:
raise ValueError
check_info(message.get(b'info'))
announce = message.get(b'announce')
if type(announce) != bytes or len(announce) == 0:
if type(announce) is not bytes or len(announce) == 0:
raise ValueError('bad torrent file - announce is invalid')


def check_peers(message):
if type(message) != dict:
if type(message) is not dict:
raise ValueError
if b'failure reason' in message:
if type(message[b'failure reason']) != bytes:
if type(message[b'failure reason']) is not bytes:
raise ValueError
return
peers = message.get(b'peers')
if type(peers) == list:
if type(peers) is list:
for p in peers:
if type(p) != dict:
if type(p) is not dict:
raise ValueError
if type(p.get(b'ip')) != bytes:
if type(p.get(b'ip')) is not bytes:
raise ValueError
port = p.get(b'port')
if type(port) != int or p <= 0:
if type(port) is not int or p <= 0:
raise ValueError
if b'peer id' in p:
id = p.get(b'peer id')
if type(id) != bytes or len(id) != 20:
if type(id) is not bytes or len(id) != 20:
raise ValueError
elif type(peers) != bytes or len(peers) % 6 != 0:
elif type(peers) is not bytes or len(peers) % 6 != 0:
raise ValueError
interval = message.get(b'interval', 1)
if type(interval) != int or interval <= 0:
if type(interval) is not int or interval <= 0:
raise ValueError
minint = message.get(b'min interval', 1)
if type(minint) != int or minint <= 0:
if type(minint) is not int or minint <= 0:
raise ValueError
if type(message.get(b'tracker id', b'')) != bytes:
if type(message.get(b'tracker id', b'')) is not bytes:
raise ValueError
npeers = message.get(b'num peers', 0)
if type(npeers) != int or npeers < 0:
if type(npeers) is not int or npeers < 0:
raise ValueError
dpeers = message.get(b'done peers', 0)
if type(dpeers) != int or dpeers < 0:
if type(dpeers) is not int or dpeers < 0:
raise ValueError
last = message.get(b'last', 0)
if type(last) != int or last < 0:
if type(last) is not int or last < 0:
raise ValueError
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def _get_version(path):
'Topic :: Utilities',
'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
Expand All @@ -56,7 +55,7 @@ def _get_version(path):
'Source Code': 'https://github.com/cfv-project/cfv',
'Original Project': 'http://cfv.sourceforge.net/',
},
python_requires='>=3.5',
python_requires='>=3.6',
packages=find_packages('lib'),
package_dir={'': 'lib'},
include_package_data=True,
Expand Down

0 comments on commit ed2b4bb

Please sign in to comment.