Skip to content

Commit 58c2de4

Browse files
Panaetiusjsam
authored andcommitted
fix: migration timezones (#683)
* Removes pytz dependency and fixes Project date converter code * Changes travis build to runi unit tests and test docs separately * Cleans up run-tests.sh and add release configs for travis * Updates git actions for new run-tests.sh
1 parent 3fbde5e commit 58c2de4

File tree

6 files changed

+128
-27
lines changed

6 files changed

+128
-27
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on: [push]
44

55
jobs:
6-
test-linux:
6+
docs-linux:
77
runs-on: ubuntu-latest
88
strategy:
99
max-parallel: 4
@@ -17,12 +17,32 @@ jobs:
1717
version: ${{ matrix.python-version }}
1818
- name: Install dependencies
1919
run: |
20-
python -m pip install --upgrade pip
20+
python -m pip install --upgrade pip
2121
python -m pip install .[all]
2222
git config --global --add user.name "Renku @ SDSC"
2323
git config --global --add user.email "[email protected]"
24+
- name: Test docs
25+
run: ./run-tests.sh -d
26+
test-linux:
27+
runs-on: ubuntu-latest
28+
strategy:
29+
max-parallel: 4
30+
matrix:
31+
python-version: [3.6, 3.7]
32+
steps:
33+
- uses: actions/checkout@master
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v1
36+
with:
37+
version: ${{ matrix.python-version }}
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
python -m pip install .[nodocs]
42+
git config --global --add user.name "Renku @ SDSC"
43+
git config --global --add user.email "[email protected]"
2444
- name: Test with pytest
25-
run: ./run-tests.sh
45+
run: ./run-tests.sh -s -t
2646

2747
test-macos:
2848
runs-on: macos-latest
@@ -40,7 +60,7 @@ jobs:
4060
run: |
4161
brew update
4262
brew install git-lfs shellcheck node || brew link --overwrite node
43-
python -m pip install --upgrade pip
63+
python -m pip install --upgrade pip
4464
python -m pip install .[all]
4565
git config --global --add user.name "Renku @ SDSC"
4666
git config --global --add user.email "[email protected]"

.travis.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ python:
4343

4444
stages:
4545
- name: test
46+
- name: docs
4647
- name: integration
4748
if: branch = master AND (type != pull_request)
4849
- name: test OSX
@@ -64,6 +65,9 @@ before_install:
6465
requirements-builder -e all --level=min setup.py > .travis-lowest-requirements.txt;
6566
requirements-builder -e all --level=pypi setup.py > .travis-release-requirements.txt;
6667
requirements-builder -e all --level=dev --req requirements-devel.txt setup.py > .travis-devel-requirements.txt;
68+
requirements-builder -e nodocs --level=min setup.py > .travis-lowest-requirements-nodocs.txt;
69+
requirements-builder -e nodocs --level=pypi setup.py > .travis-release-requirements-nodocs.txt;
70+
requirements-builder -e nodocs --level=dev --req requirements-devel.txt setup.py > .travis-devel-requirements-nodocs.txt;
6771
elif [[ $TRAVIS_OS_NAME == 'osx' ]]; then
6872
brew update;
6973
brew upgrade python;
@@ -75,22 +79,33 @@ before_install:
7579

7680
install:
7781
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then
78-
travis_retry python -m pip install -r .travis-${REQUIREMENTS}-requirements.txt;
79-
travis_retry python -m pip install -e .[all];
82+
travis_retry python -m pip install -r .travis-${REQUIREMENTS}-requirements-nodocs.txt;
83+
travis_retry python -m pip install -e .[nodocs];
8084
elif [[ $TRAVIS_OS_NAME == 'osx' ]]; then
8185
travis_retry pipenv install --deploy;
8286
source "$(pipenv --venv)/bin/activate";
83-
travis_retry pip install -e .[all];
87+
travis_retry pip install -e .[nodocs];
8488
fi
8589

8690
script:
87-
- "./run-tests.sh"
91+
- "./run-tests.sh -t -s"
8892

8993
after_success:
9094
- coveralls
9195

9296
jobs:
9397
include:
98+
- stage: docs
99+
os: linux
100+
dist: xenial
101+
language: python
102+
env:
103+
- REQUIREMENTS=lowest
104+
- REQUIREMENTS=release
105+
install:
106+
- travis_retry python -m pip install -r .travis-${REQUIREMENTS}-requirements-all.txt;
107+
travis_retry python -m pip install -e .[all];
108+
script: ./run-tests.sh -d
94109
- stage: integration
95110
os: linux
96111
dist: xenial

renku/models/projects.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
import datetime
2121

22-
import pytz
23-
2422
from renku.utils.datetime8601 import parse_date
2523

2624
from . import _jsonld as jsonld
@@ -62,14 +60,6 @@ def _now(self):
6260
"""Define default value for datetime fields."""
6361
return datetime.datetime.now(datetime.timezone.utc)
6462

65-
def __attrs_post_init__(self):
66-
"""Initialize computed attributes."""
67-
if self.created and self.created.tzinfo is None:
68-
self.created = pytz.utc.localize(self.created)
69-
70-
if self.updated and self.updated.tzinfo is None:
71-
self.updated = pytz.utc.localize(self.updated)
72-
7363

7464
class ProjectCollection(Collection):
7565
"""Represent projects on the server.

renku/utils/datetime8601.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ def validate_iso8601(str_val):
4242
def parse_date(value):
4343
"""Convert date to datetime."""
4444
if isinstance(value, datetime.datetime):
45-
return value
46-
date = dateutil_parse_date(value)
45+
date = value
46+
else:
47+
date = dateutil_parse_date(value)
4748
if not date.tzinfo:
4849
# set timezone to local timezone
4950
tz = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo

run-tests.sh

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,79 @@ set -o errexit
2323
# quit on unbound symbols:
2424
set -o nounset
2525

26-
pydocstyle renku tests conftest.py docs
27-
isort -rc -c -df
28-
unify -c -r renku tests conftest.py docs
29-
check-manifest --ignore ".travis-*,renku/version.py"
30-
find . -iname \*.sh -print0 | xargs -0 shellcheck
31-
sphinx-build -qnNW docs docs/_build/html
32-
pytest -v -m "not integration"
26+
USAGE=$(cat <<-END
27+
Usage:
28+
run-tests.sh [-s | --styles] [-d | --docs] [-t | --tests]
29+
run-tests.sh -h | --help
30+
Options:
31+
-h, --help Show this screen.
32+
-s, --styles check styles
33+
-d, --docs build and test docs
34+
-t, --tests run unit tests
35+
END
36+
)
37+
38+
check_styles(){
39+
pydocstyle renku tests conftest.py docs
40+
isort -rc -c -df
41+
unify -c -r renku tests conftest.py docs
42+
check-manifest --ignore ".travis-*,renku/version.py"
43+
find . -iname \*.sh -print0 | xargs -0 shellcheck
44+
}
45+
46+
build_docs(){
47+
sphinx-build -qnNW docs docs/_build/html
48+
pytest -v -m "not integration" -o testpaths="docs conftest.py"
49+
}
50+
51+
run_tests(){
52+
pytest -v -m "not integration" -o testpaths="tests renku conftest.py"
53+
}
54+
55+
usage(){
56+
echo "$USAGE"
57+
}
58+
59+
all=1
60+
tests=
61+
docs=
62+
styles=
63+
64+
while [ "${1-}" != "" ]; do
65+
case $1 in
66+
-t | --tests )
67+
tests=1
68+
all=0
69+
;;
70+
-d | --docs )
71+
docs=1
72+
all=0
73+
;;
74+
75+
-s | --styles )
76+
styles=1
77+
all=0
78+
;;
79+
-h | --help )
80+
usage
81+
exit
82+
;;
83+
esac
84+
shift
85+
done
86+
87+
docs=$((docs||all))
88+
tests=$((tests||all))
89+
styles=$((styles||all))
90+
91+
if [ "$docs" = "1" ]; then
92+
build_docs
93+
fi
94+
95+
if [ "$styles" = "1" ]; then
96+
check_styles
97+
fi
98+
99+
if [ "$tests" = "1" ]; then
100+
run_tests
101+
fi

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
continue
6666
extras_require['all'].extend(reqs)
6767

68+
extras_require['nodocs'] = list(setup_requires)
69+
for name, reqs in extras_require.items():
70+
if name.startswith(':') or name == 'docs':
71+
continue
72+
extras_require['nodocs'].extend(reqs)
73+
6874
install_requires = [
6975
'appdirs>=1.4.3',
7076
'attrs>=18.2.0',

0 commit comments

Comments
 (0)