Skip to content

Commit

Permalink
More checks on repo files (#4765)
Browse files Browse the repository at this point in the history
* Some pyc files were accidentaly included in bdist
* Add some more checks to travis
* Make checks parallel
* Add copyright statements [skip ci]

Former-commit-id: b22be78 [formerly b22be78 [formerly a820e52]]
Former-commit-id: 73dc895d026ea465504522928252f10a28dad3e6
Former-commit-id: 6c7a77e
  • Loading branch information
daniviga committed May 31, 2019
1 parent 604a38c commit b66ea78
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -18,3 +18,4 @@ demos/*/*.zip
*.swp
.tox
venv
*.whl
12 changes: 7 additions & 5 deletions .travis.yml
Expand Up @@ -60,12 +60,14 @@ jobs:
oq dbserver status | grep -q 'dbserver not-running';
fi
- stage: packaging
env: python
env: EXEC
script:
- pip wheel --no-deps .
- find openquake/ -type f | grep -Ev 'openquake/__init__.py|/tests/|nrml_examples' | sort > sources
- zipinfo -1 openquake.engine*.whl | grep '^openquake/' | grep -v 'nrml_examples' | sort > package
- diff -uN sources package
- ./.travis/py_shebangs.sh
- ./.travis/py_executables.sh
- stage: packaging
env: WHL
script:
- ./.travis/packaging.sh

before_install:
- if [ "$TRAVIS_PULL_REQUEST_BRANCH" != "" ]; then BRANCH=$TRAVIS_PULL_REQUEST_BRANCH; else BRANCH=$TRAVIS_BRANCH; fi
Expand Down
24 changes: 24 additions & 0 deletions .travis/common.sh
@@ -0,0 +1,24 @@
#!/bin/bash
#
# common.sh Copyright (C) 2019 GEM Foundation
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>
#
# This file is meant to be sourced

checkcmd() {
for cmd in "$@"; do
command -v "$cmd" &> /dev/null || { echo >&2 -e "This script requires '$cmd' but it isn't available. Aborting."; exit 1; }
done
}
33 changes: 33 additions & 0 deletions .travis/packaging.sh
@@ -0,0 +1,33 @@
#!/bin/bash
#
# packaging.sh Copyright (C) 2019 GEM Foundation
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>

# shellcheck disable=SC1091
. .travis/common.sh

checkcmd pip find zipinfo diff

function finish {
rm -Rf sources package "$tmp"
}
trap finish EXIT

tmp=$(mktemp -d)

pip wheel --no-deps -w "$tmp" .
find openquake/ -type f ! -name \*.pyc | grep -Ev 'openquake/__init__.py|/tests/|nrml_examples' | sort > sources
zipinfo -1 "$tmp"/openquake.engine*.whl | grep '^openquake/' | grep -v 'nrml_examples' | sort > package
diff -uN sources package
23 changes: 23 additions & 0 deletions .travis/py_executables.sh
@@ -0,0 +1,23 @@
#!/bin/bash
#
# executables.sh Copyright (C) 2019 GEM Foundation
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>

# shellcheck disable=SC1091
. .travis/common.sh

checkcmd find

find . -not -path '*/\.*' -name \*.py -type f -executable -exec grep -LE '^#!.*env python3$' '{}' \; | grep -E '.'; test $? -eq 1
23 changes: 23 additions & 0 deletions .travis/py_shebangs.sh
@@ -0,0 +1,23 @@
#!/bin/bash
#
# packaging.sh Copyright (C) 2019 GEM Foundation
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>

# shellcheck disable=SC1091
. .travis/common.sh

checkcmd find

find . -not -path '*/\.*' -type f -executable -exec grep -lE '#!.*python$|#!.*python2.*$' '{}' \; | grep -E '.'; test $? -eq 1
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -18,3 +18,4 @@ recursive-include openquake/hazardlib/gsim *.csv *.hdf5
recursive-include openquake/commonlib/nrml_examples *.xml *.csv *.geojson
# QA tests data
recursive-include openquake/qa_tests_data *.* README
recursive-exclude openquake/qa_tests_data *.pyc
1 change: 1 addition & 0 deletions openquake/hazardlib/tests/gsim/check_gsim.py
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
Expand Down

0 comments on commit b66ea78

Please sign in to comment.