Update gitlab CI script, add cpp lint

This commit is contained in:
Otto Winter 2019-05-28 10:23:15 +02:00
parent f39d459555
commit a23ebead68
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
4 changed files with 127 additions and 107 deletions

View file

@ -3,6 +3,8 @@
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
BASE_VERSION: '1.5.1'
TZ: UTC
stages:
- lint
@ -10,23 +12,20 @@ stages:
- deploy
.lint: &lint
image: esphome/esphome-base-amd64
image: esphome/esphome-lint:latest
stage: lint
before_script:
- pip install -e .
- pip install flake8==3.6.0 pylint==1.9.4 pillow
- script/setup
tags:
- docker
.test: &test
image: esphome/esphome-base-amd64
image: esphome/esphome-base-amd64:${BASE_VERSION}
stage: test
before_script:
- pip install -e .
- script/setup
tags:
- docker
variables:
TZ: UTC
.docker-base: &docker-base
image: esphome/esphome-base-builder
@ -41,11 +40,11 @@ stages:
- |
if [[ "${IS_HASSIO}" == "YES" ]]; then
BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.5.1
BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:${BASE_VERSION}
BUILD_TO=esphome/esphome-hassio-${BUILD_ARCH}
DOCKERFILE=docker/Dockerfile.hassio
else
BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.5.1
BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:${BASE_VERSION}
if [[ "${BUILD_ARCH}" == "amd64" ]]; then
BUILD_TO=esphome/esphome
else
@ -94,15 +93,32 @@ stages:
- docker
stage: deploy
flake8:
lint-custom:
<<: *lint
script:
- flake8 esphome
- script/ci-custom.py
pylint:
lint-python:
<<: *lint
script:
- pylint esphome
- script/lint-python
lint-tidy:
<<: *lint
script:
- pio init --ide atom
- |
if ! patch -R -p0 -s -f --dry-run <script/.neopixelbus.patch; then
patch -p0 < script/.neopixelbus.patch
fi
- script/clang-tidy --all-headers --fix
- script/ci-suggest-changes
lint-format:
<<: *lint
script:
- script/clang-format -i
- script/ci-suggest-changes
test1:
<<: *test
@ -120,16 +136,11 @@ test3:
- esphome tests/test3.yaml compile
.deploy-pypi: &deploy-pypi
<<: *lint
stage: deploy
image: python:2.7
before_script:
- pip install -e .
- pip install twine
script:
- python setup.py sdist bdist_wheel
- twine upload dist/*
tags:
- docker
deploy-release:pypi:
<<: *deploy-pypi
@ -152,12 +163,6 @@ deploy-beta:pypi:
except:
- branches
.latest-vars: &latest-vars
RELEASE: YES
LATEST: YES
# Also push to beta tag
BETA: YES
.beta: &beta
<<: *docker-base
only:
@ -165,60 +170,53 @@ deploy-beta:pypi:
except:
- branches
.beta-vars: &beta-vars
RELEASE: YES
BETA: YES
.dev: &dev
<<: *docker-base
only:
- dev
.dev-vars: &dev-vars
DEV: YES
#aarch64-beta-docker:
# <<: *beta
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "NO"
# RELEASE: "YES"
#aarch64-beta-hassio:
# <<: *beta
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "YES"
# RELEASE: "YES"
#aarch64-dev-docker:
# <<: *dev
# variables:
# BUILD_ARCH: aarch64
# DEV: "YES"
# IS_HASSIO: "NO"
#aarch64-dev-hassio:
# <<: *dev
# variables:
# BUILD_ARCH: aarch64
# DEV: "YES"
# IS_HASSIO: "YES"
#aarch64-latest-docker:
# <<: *latest
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "NO"
# LATEST: "YES"
# RELEASE: "YES"
#aarch64-latest-hassio:
# <<: *latest
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "YES"
# LATEST: "YES"
# RELEASE: "YES"
aarch64-beta-docker:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "NO"
RELEASE: "YES"
aarch64-beta-hassio:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "YES"
RELEASE: "YES"
aarch64-dev-docker:
<<: *dev
variables:
BUILD_ARCH: aarch64
DEV: "YES"
IS_HASSIO: "NO"
aarch64-dev-hassio:
<<: *dev
variables:
BUILD_ARCH: aarch64
DEV: "YES"
IS_HASSIO: "YES"
aarch64-latest-docker:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "NO"
LATEST: "YES"
RELEASE: "YES"
aarch64-latest-hassio:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "YES"
LATEST: "YES"
RELEASE: "YES"
amd64-beta-docker:
<<: *beta
variables:
@ -261,45 +259,45 @@ amd64-latest-hassio:
IS_HASSIO: "YES"
LATEST: "YES"
RELEASE: "YES"
armhf-beta-docker:
armv7-beta-docker:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "NO"
RELEASE: "YES"
armhf-beta-hassio:
armv7-beta-hassio:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "YES"
RELEASE: "YES"
armhf-dev-docker:
armv7-dev-docker:
<<: *dev
variables:
BUILD_ARCH: armhf
BUILD_ARCH: armv7
DEV: "YES"
IS_HASSIO: "NO"
armhf-dev-hassio:
armv7-dev-hassio:
<<: *dev
variables:
BUILD_ARCH: armhf
BUILD_ARCH: armv7
DEV: "YES"
IS_HASSIO: "YES"
armhf-latest-docker:
armv7-latest-docker:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "NO"
LATEST: "YES"
RELEASE: "YES"
armhf-latest-hassio:
armv7-latest-hassio:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "YES"
LATEST: "YES"
RELEASE: "YES"

View file

@ -1,6 +1,18 @@
FROM python:2.7
FROM esphome/esphome-base-amd64:1.5.1
COPY requirements.txt /requirements.txt
RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
clang-format-7 \
clang-tidy-7 \
patch \
&& rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/*
RUN pip install -r /requirements.txt && \
pip install flake8==3.6.0 pylint==1.9.4 pillow
COPY requirements_test.txt /requirements_test.txt
RUN pip2 install -r /requirements_test.txt
VOLUME ["/esphome"]
WORKDIR /esphome

View file

@ -16,3 +16,4 @@ pylint==2.3.0 ; python_version>"3"
flake8==3.6.0
pillow
pexpect
twine

View file

@ -11,6 +11,19 @@ import sys
sys.path.append(os.path.dirname(__file__))
from helpers import get_output, git_ls_files, filter_changed
curfile = None
def print_error(file, lineno, msg):
global curfile
if curfile != file:
print()
print("\033[0;32m************* File \033[1;32m{}\033[0m".format(file))
curfile = file
print(u'{}:{} - {}'.format(file, lineno, msg))
def main():
parser = argparse.ArgumentParser()
@ -38,7 +51,7 @@ def main():
if not files:
sys.exit(0)
errors = collections.defaultdict(list)
errors = 0
cmd = ['flake8'] + files
print("Running flake8...")
log = get_output(*cmd)
@ -49,7 +62,8 @@ def main():
file_ = line[0]
linno = line[1]
msg = (u':'.join(line[3:])).strip()
errors[file_].append(u'{}:{} - {}'.format(file_, linno, msg))
print_error(file_, linno, msg)
errors += 1
cmd = ['pylint', '-f', 'parseable', '--persistent=n'] + files
print("Running pylint...")
@ -61,15 +75,10 @@ def main():
file_ = line[0]
linno = line[1]
msg = (u':'.join(line[3:])).strip()
errors[file_].append(u'{}:{} - {}'.format(file_, linno, msg))
print_error(file_, linno, msg)
errors += 1
for f, errs in sorted(errors.items()):
print("\033[0;32m************* File \033[1;32m{}\033[0m".format(f))
for err in errs:
print(err)
print()
sys.exit(len(errors))
sys.exit(errors)
if __name__ == '__main__':