Skip to content

Commit

Permalink
Merge pull request #36307 from m-kuhn/code_layout_test_to_github_work…
Browse files Browse the repository at this point in the history
…flow

Code layout test to GitHub workflow
  • Loading branch information
m-kuhn committed May 11, 2020
2 parents 915957c + f171232 commit 02df257
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 60 deletions.
150 changes: 150 additions & 0 deletions .github/workflows/code_layout.yml
@@ -0,0 +1,150 @@
name: Code Layout

on: [push, pull_request]

jobs:
documentation_checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install Requirements
run: |
sudo apt install -y \
doxygen \
cpanminus \
libyaml-tiny-perl \
libio-socket-ssl-perl \
libhttp-date-perl \
libgetopt-long-descriptive-perl \
libmoo-perl \
libnamespace-clean-perl \
libpath-tiny-perl \
libpod-constants-perl \
libscalar-list-utils-perl \
libsort-key-perl \
libstrictures-perl \
libstring-escape-perl \
libtry-tiny-perl \
expect
cpanm --notest App::Licensecheck
python -m pip install --upgrade pip
pip install autopep8 nose2 mock termcolor
- name: Make
run: |
mkdir build
cd build
cmake -DWITH_SERVER=ON -DUSE_CCACHE=OFF -DWITH_CORE=OFF -DWITH_APIDOC=ON -DWITH_ASTYLE=ON -DENABLE_TESTS=ON -DWITH_DOT=NO ..
make -j3
- name: Run Tests
run: cd build && ctest -R doc

license_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirements
run: |
sudo apt install -y \
cpanminus
cpanm --notest App::Licensecheck
- name: Run License Check
run: ./tests/code_layout/test_licenses.sh

shell_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirements
run: |
sudo apt install -y \
shellcheck
- name: Run Shellcheck
run: ./tests/code_layout/test_shellcheck.sh

banned_keywords_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Banned Keywords Test
run: ./tests/code_layout/test_banned_keywords.sh

def_window_title_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Def Window Title Test
run: ./tests/code_layout/test_defwindowtitle.sh

doxygen_layout_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Doxygen Layout Test
run: ./tests/code_layout/test_doxygen_layout.sh

indentation_check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Indentation Test
run: ./scripts/verify_indentation.sh HEAD~1

spell_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Indentation Test
run: ./scripts/spell_check/spell_test.sh

sip_check:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install Requirements
run: |
sudo apt install -y \
cpanminus \
libyaml-tiny-perl \
libio-socket-ssl-perl \
libhttp-date-perl \
libgetopt-long-descriptive-perl \
libmoo-perl \
libnamespace-clean-perl \
libpath-tiny-perl \
libpod-constants-perl \
libscalar-list-utils-perl \
libsort-key-perl \
libstrictures-perl \
libstring-escape-perl \
libtry-tiny-perl \
expect
python -m pip install --upgrade pip
pip install autopep8 nose2 mock termcolor
- name: Checkout
uses: actions/checkout@v2
- name: Sip Checks
run: ./tests/code_layout/test_sipify.sh
- name: Sip Include Test
run: ./tests/code_layout/test_sip_include.sh
- name: Sip Files Up To Date
run: ./tests/code_layout/test_sipfiles_uptodate.sh
@@ -1,4 +1,4 @@
name: Pyflakes
name: flake8

on: [push, pull_request]

Expand All @@ -12,7 +12,7 @@ jobs:
python-version: 3.7.6
architecture: x64
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v2
- name: Install flake8
run: pip install flake8
- name: Run flake8
Expand Down
41 changes: 0 additions & 41 deletions .travis.yml
Expand Up @@ -49,47 +49,6 @@ matrix:
# Label ID can be found here https://api.github.com/repos/qgis/QGIS/labels
- RUN_FLAKY_TESTS=$(.ci/travis/scripts/pr_has_label.py $TRAVIS_PULL_REQUEST 1271248184)

##########################################################
# CODE LAYOUT
##########################################################
- os: linux
name: code layout 👗
if: type != cron
env:
- TRAVIS_CONFIG=code_layout
addons:
apt:
sources:
# - sourceline: 'ppa:jonathonf/backports' # silversearcher-ag backport
packages:
- doxygen
- graphviz
- txt2tags
- pkg-config
- xvfb
- flip
# used for spell checks
- perl # sipify, lookahead regex in spell check script
- silversearcher-ag
- expect-dev # unbuffer
- coreutils
# dependencies for licensecheck
- cpanminus
- libyaml-tiny-perl
- libio-socket-ssl-perl
- libhttp-date-perl
- libgetopt-long-descriptive-perl
- libmoo-perl
- libnamespace-clean-perl
- libpath-tiny-perl
- libpod-constants-perl
- libscalar-list-utils-perl
- libsort-key-perl
- libstrictures-perl
- libstring-escape-perl
- libtry-tiny-perl



##########################################################
#
Expand Down
4 changes: 2 additions & 2 deletions cmake_templates/Doxyfile.in
Expand Up @@ -2143,7 +2143,7 @@ PERL_PATH = /usr/bin/env perl
# powerful graphs.
# The default value is: YES.

CLASS_DIAGRAMS = YES
CLASS_DIAGRAMS = @WITH_DOT@

# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see:
Expand Down Expand Up @@ -2174,7 +2174,7 @@ HIDE_UNDOC_RELATIONS = YES
# set to NO
# The default value is: NO.

HAVE_DOT = YES
HAVE_DOT = @WITH_DOT@

# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
# to run in parallel. When set to 0 doxygen will base this on the number of
Expand Down
2 changes: 2 additions & 0 deletions doc/CMakeLists.txt
Expand Up @@ -180,6 +180,8 @@ IF(WITH_APIDOC)
IF(GENERATE_QHP)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/api/qch/qgis.qch DESTINATION ${QGIS_DATA_DIR}/doc/api)
ENDIF(GENERATE_QHP)
SET(WITH_DOT YES CACHE STRING "Determines if the dot application should be used to generate class diagrams for the documentation")
MARK_AS_ADVANCED(WITH_DOT)
ELSE(DOXYGEN_FOUND)
MESSAGE(STATUS "QGIS api documentation not built - Doxygen not found")
ENDIF(DOXYGEN_FOUND)
Expand Down
23 changes: 9 additions & 14 deletions scripts/verify_indentation.sh
Expand Up @@ -3,8 +3,9 @@ cd $(git rev-parse --show-toplevel)

export PATH=$PATH:$PWD/scripts

if [ -z "$TRAVIS_COMMIT_RANGE" ]; then
echo "No commit range given"
if [ -z "$1" ]; then
echo "No commit range given. "
echo " Usage: ./scripts/verify_indentation [HEAD_REF]..[BASE_REF]"
exit 0
fi

Expand All @@ -19,22 +20,16 @@ ASTYLEDIFF=/tmp/astyle.diff
true > $ASTYLEDIFF


if [[ -n $TRAVIS_PULL_REQUEST_BRANCH ]]; then
# if on a PR, just analyze the changed files
echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
FILES=$(git diff --diff-filter=AM --name-only $(git merge-base HEAD ${TRAVIS_BRANCH}) | tr '\n' ' ' )
elif [[ -n $TRAVIS_COMMIT_RANGE ]]; then
echo "TRAVIS COMMIT RANGE: $TRAVIS_COMMIT_RANGE"
FILES=$(git diff --diff-filter=AM --name-only ${TRAVIS_COMMIT_RANGE/.../..} | tr '\n' ' ' )
fi
echo "Commit range: $1"
FILES=$(git diff --diff-filter=AM --name-only $1 | tr '\n' ' ' )

for f in $FILES; do
if ! [ -f "$f" ]; then
echo "$f was removed." >>/tmp/ctest-important.log
continue
fi

echo "Checking $f" >>/tmp/ctest-important.log
# echo "Checking $f"
case "$f" in
*.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py)
;;
Expand All @@ -50,7 +45,7 @@ for f in $FILES; do
if diff -u "$m" "$f" >>$ASTYLEDIFF; then
rm "$m"
else
echo "File $f needs indentation"
echo "File $f is not styled properly."
fi
done

Expand All @@ -62,9 +57,9 @@ if [ -s "$ASTYLEDIFF" ]; then
cat <<EOF
Tips to prevent and resolve:
* Enable WITH_ASTYLE in your cmake configuration to format C++ code
* Install astyle to format C++ code
* Install autopep8 (>= 1.2.1) to format python code
* Use "scripts/astyle.sh file" to fix the now badly indented files
* Use "scripts/astyle.sh file" to fix the now incorrectly formatted files
* Consider using scripts/prepare_commit.sh as pre-commit hook to avoid this
in the future (ln -s ../../scripts/prepare_commit.sh .git/hooks/pre-commit) or
run it manually before each commit.
Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsexpressionpreviewbase.ui
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Expression Preview</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
Expand Down

0 comments on commit 02df257

Please sign in to comment.