Skip to content

Commit 7843f6f

Browse files
authored
Merge pull request #166 from elacuesta/github-actions
[CI] Migrate CI to GitHub actions
2 parents 4f5fcf9 + a5ab6e0 commit 7843f6f

File tree

7 files changed

+112
-81
lines changed

7 files changed

+112
-81
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
4-
name: Python package
1+
name: Build
52

63
on:
74
push:
8-
branches: [ master ]
5+
branches:
6+
- master
97
pull_request:
10-
branches: [ master ]
8+
branches:
9+
- master
1110

1211
jobs:
1312
build:
1413

1514
runs-on: ubuntu-20.04
1615
strategy:
1716
matrix:
18-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy3]
17+
include:
18+
- python-version: 3.7
19+
env:
20+
TOXENV: docs
21+
- python-version: 3.8
22+
env:
23+
TOXENV: flake8
24+
- python-version: 3.8
25+
env:
26+
TOXENV: pylint
27+
- python-version: 3.8
28+
env:
29+
TOXENV: security
1930

2031
steps:
2132
- uses: actions/checkout@v2
33+
2234
- name: Set up Python ${{ matrix.python-version }}
2335
uses: actions/setup-python@v2
2436
with:
2537
python-version: ${{ matrix.python-version }}
26-
- name: Greet
27-
run: python -c "print('hello there')"
38+
39+
- name: Run check
40+
env: ${{ matrix.env }}
41+
run: |
42+
pip install --upgrade pip
43+
pip install --upgrade tox
44+
tox

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-20.04
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Set up Python 3.8
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: 3.8
19+
20+
- name: Check Tag
21+
id: check-release-tag
22+
run: |
23+
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+[.][0-9]+[.][0-9]+(rc[0-9]+|[.]dev[0-9]+)?$ ]]; then
24+
echo ::set-output name=release_tag::true
25+
fi
26+
27+
- name: Publish to PyPI
28+
if: steps.check-release-tag.outputs.release_tag == 'true'
29+
run: |
30+
pip install --upgrade pip
31+
pip install --upgrade setuptools wheel twine
32+
python setup.py sdist bdist_wheel
33+
export TWINE_USERNAME=__token__
34+
export TWINE_PASSWORD=${{ secrets.PYPI_TOKEN }}
35+
twine upload dist/*

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
tests:
13+
14+
runs-on: ubuntu-20.04
15+
strategy:
16+
matrix:
17+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy3]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Run tests
28+
run: |
29+
pip install --upgrade pip
30+
pip install --upgrade tox
31+
tox -e py
32+
33+
- name: Upload coverage report
34+
run: bash <(curl -s https://codecov.io/bash)

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dist
88
docs/_build
99
_trial_temp
1010
.coverage
11-
.cache
11+
coverage.xml
12+
.cache

.travis.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

tests/test_url.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
from __future__ import absolute_import
33
import os
44
import unittest
5+
6+
import pytest
7+
from six.moves.urllib.parse import urlparse
8+
59
from w3lib.url import (is_url, safe_url_string, safe_download_url,
610
url_query_parameter, add_or_replace_parameter, url_query_cleaner,
711
file_uri_to_path, parse_data_uri, path_to_file_uri, any_to_uri,
812
urljoin_rfc, canonicalize_url, parse_url, add_or_replace_parameters)
9-
from six.moves.urllib.parse import urlparse
1013

1114

1215
class UrlTests(unittest.TestCase):
@@ -76,17 +79,16 @@ def test_safe_url_string_remove_ascii_tab_and_newlines(self):
7679
def test_safe_url_string_unsafe_chars(self):
7780
safeurl = safe_url_string(r"http://localhost:8001/unwise{,},|,\,^,[,],`?|=[]&[]=|")
7881
self.assertEqual(safeurl, r"http://localhost:8001/unwise%7B,%7D,|,%5C,%5E,[,],%60?|=[]&[]=|")
79-
82+
8083
def test_safe_url_string_quote_path(self):
8184
safeurl = safe_url_string(u'http://google.com/"hello"', quote_path=True)
8285
self.assertEqual(safeurl, u'http://google.com/%22hello%22')
83-
86+
8487
safeurl = safe_url_string(u'http://google.com/"hello"', quote_path=False)
8588
self.assertEqual(safeurl, u'http://google.com/"hello"')
86-
89+
8790
safeurl = safe_url_string(u'http://google.com/"hello"')
8891
self.assertEqual(safeurl, u'http://google.com/%22hello%22')
89-
9092

9193
def test_safe_url_string_with_query(self):
9294
safeurl = safe_url_string(u"http://www.example.com/£?unit=µ")
@@ -310,10 +312,6 @@ def test_add_or_replace_parameter(self):
310312
self.assertEqual(add_or_replace_parameter(url, 'arg3', 'nv3'),
311313
'http://domain/test?arg1=v1&arg2=v2&arg3=nv3')
312314

313-
url = 'http://domain/test?arg1=v1;arg2=v2'
314-
self.assertEqual(add_or_replace_parameter(url, 'arg1', 'v3'),
315-
'http://domain/test?arg1=v3&arg2=v2')
316-
317315
self.assertEqual(add_or_replace_parameter("http://domain/moreInfo.asp?prodID=", 'prodID', '20'),
318316
'http://domain/moreInfo.asp?prodID=20')
319317
url = 'http://rmc-offers.co.uk/productlist.asp?BCat=2%2C60&CatID=60'
@@ -338,6 +336,13 @@ def test_add_or_replace_parameter(self):
338336
self.assertEqual(add_or_replace_parameter(url, 'arg1', 'v3'),
339337
'http://domain/test?arg1=v3&arg2=v2')
340338

339+
@pytest.mark.xfail(reason="https://github.com/scrapy/w3lib/issues/164")
340+
def test_add_or_replace_parameter_fail(self):
341+
self.assertEqual(
342+
add_or_replace_parameter('http://domain/test?arg1=v1;arg2=v2', 'arg1', 'v3'),
343+
'http://domain/test?arg1=v3&arg2=v2'
344+
)
345+
341346
def test_add_or_replace_parameters(self):
342347
url = 'http://domain/test'
343348
self.assertEqual(add_or_replace_parameters(url, {'arg': 'v'}),
@@ -767,4 +772,3 @@ def test_scheme_case_insensitive(self):
767772

768773
if __name__ == "__main__":
769774
unittest.main()
770-

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deps =
1313
commands =
1414
py.test \
1515
--doctest-modules \
16-
--cov=w3lib --cov-report=term \
16+
--cov=w3lib --cov-report=term --cov-report=xml \
1717
{posargs:w3lib tests}
1818

1919
[testenv:security]

0 commit comments

Comments
 (0)