Update gitlab CI script, add cpp lint

This commit is contained in:
Otto Winter 2019-05-28 10:23:15 +02:00
parent 6a17fe375e
commit 53e8b3ed3e
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
4 changed files with 126 additions and 101 deletions

View File

@ -3,6 +3,8 @@
variables: variables:
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/ DOCKER_HOST: tcp://docker:2375/
BASE_VERSION: '1.5.1'
TZ: UTC
stages: stages:
- lint - lint
@ -10,7 +12,7 @@ stages:
- deploy - deploy
.lint: &lint .lint: &lint
image: esphome/esphome-base-amd64 image: esphome/esphome-lint:latest
stage: lint stage: lint
before_script: before_script:
- script/setup - script/setup
@ -18,14 +20,12 @@ stages:
- docker - docker
.test: &test .test: &test
image: esphome/esphome-base-amd64 image: esphome/esphome-base-amd64:${BASE_VERSION}
stage: test stage: test
before_script: before_script:
- script/setup - script/setup
tags: tags:
- docker - docker
variables:
TZ: UTC
.docker-base: &docker-base .docker-base: &docker-base
image: esphome/esphome-base-builder image: esphome/esphome-base-builder
@ -40,11 +40,11 @@ stages:
- | - |
if [[ "${IS_HASSIO}" == "YES" ]]; then 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} BUILD_TO=esphome/esphome-hassio-${BUILD_ARCH}
DOCKERFILE=docker/Dockerfile.hassio DOCKERFILE=docker/Dockerfile.hassio
else 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 if [[ "${BUILD_ARCH}" == "amd64" ]]; then
BUILD_TO=esphome/esphome BUILD_TO=esphome/esphome
else else
@ -93,12 +93,33 @@ stages:
- docker - docker
stage: deploy stage: deploy
lint-python: lint-custom:
<<: *lint <<: *lint
script: script:
- script/ci-custom.py - script/ci-custom.py
lint-python:
<<: *lint
script:
- script/lint-python - 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: test1:
<<: *test <<: *test
script: script:
@ -115,16 +136,11 @@ test3:
- esphome tests/test3.yaml compile - esphome tests/test3.yaml compile
.deploy-pypi: &deploy-pypi .deploy-pypi: &deploy-pypi
<<: *lint
stage: deploy stage: deploy
image: python:2.7
before_script:
- pip install -e .
- pip install twine
script: script:
- python setup.py sdist bdist_wheel - python setup.py sdist bdist_wheel
- twine upload dist/* - twine upload dist/*
tags:
- docker
deploy-release:pypi: deploy-release:pypi:
<<: *deploy-pypi <<: *deploy-pypi
@ -143,77 +159,64 @@ deploy-beta:pypi:
.latest: &latest .latest: &latest
<<: *docker-base <<: *docker-base
only: only:
- /^v([0-9\.]+)$/ - /^v([0-9\.]+)$/
except: except:
- branches - branches
.latest-vars: &latest-vars
RELEASE: YES
LATEST: YES
# Also push to beta tag
BETA: YES
.beta: &beta .beta: &beta
<<: *docker-base <<: *docker-base
only: only:
- /^v([0-9\.]+b\d+)$/ - /^v([0-9\.]+b\d+)$/
except: except:
- branches - branches
.beta-vars: &beta-vars
RELEASE: YES
BETA: YES
.dev: &dev .dev: &dev
<<: *docker-base <<: *docker-base
only: only:
- dev - dev
.dev-vars: &dev-vars aarch64-beta-docker:
DEV: YES <<: *beta
variables:
#aarch64-beta-docker: BETA: "YES"
# <<: *beta BUILD_ARCH: aarch64
# variables: IS_HASSIO: "NO"
# BETA: "YES" RELEASE: "YES"
# BUILD_ARCH: aarch64 aarch64-beta-hassio:
# IS_HASSIO: "NO" <<: *beta
# RELEASE: "YES" variables:
#aarch64-beta-hassio: BETA: "YES"
# <<: *beta BUILD_ARCH: aarch64
# variables: IS_HASSIO: "YES"
# BETA: "YES" RELEASE: "YES"
# BUILD_ARCH: aarch64 aarch64-dev-docker:
# IS_HASSIO: "YES" <<: *dev
# RELEASE: "YES" variables:
#aarch64-dev-docker: BUILD_ARCH: aarch64
# <<: *dev DEV: "YES"
# variables: IS_HASSIO: "NO"
# BUILD_ARCH: aarch64 aarch64-dev-hassio:
# DEV: "YES" <<: *dev
# IS_HASSIO: "NO" variables:
#aarch64-dev-hassio: BUILD_ARCH: aarch64
# <<: *dev DEV: "YES"
# variables: IS_HASSIO: "YES"
# BUILD_ARCH: aarch64 aarch64-latest-docker:
# DEV: "YES" <<: *latest
# IS_HASSIO: "YES" variables:
#aarch64-latest-docker: BETA: "YES"
# <<: *latest BUILD_ARCH: aarch64
# variables: IS_HASSIO: "NO"
# BETA: "YES" LATEST: "YES"
# BUILD_ARCH: aarch64 RELEASE: "YES"
# IS_HASSIO: "NO" aarch64-latest-hassio:
# LATEST: "YES" <<: *latest
# RELEASE: "YES" variables:
#aarch64-latest-hassio: BETA: "YES"
# <<: *latest BUILD_ARCH: aarch64
# variables: IS_HASSIO: "YES"
# BETA: "YES" LATEST: "YES"
# BUILD_ARCH: aarch64 RELEASE: "YES"
# IS_HASSIO: "YES"
# LATEST: "YES"
# RELEASE: "YES"
amd64-beta-docker: amd64-beta-docker:
<<: *beta <<: *beta
variables: variables:
@ -256,45 +259,45 @@ amd64-latest-hassio:
IS_HASSIO: "YES" IS_HASSIO: "YES"
LATEST: "YES" LATEST: "YES"
RELEASE: "YES" RELEASE: "YES"
armhf-beta-docker: armv7-beta-docker:
<<: *beta <<: *beta
variables: variables:
BETA: "YES" BETA: "YES"
BUILD_ARCH: armhf BUILD_ARCH: armv7
IS_HASSIO: "NO" IS_HASSIO: "NO"
RELEASE: "YES" RELEASE: "YES"
armhf-beta-hassio: armv7-beta-hassio:
<<: *beta <<: *beta
variables: variables:
BETA: "YES" BETA: "YES"
BUILD_ARCH: armhf BUILD_ARCH: armv7
IS_HASSIO: "YES" IS_HASSIO: "YES"
RELEASE: "YES" RELEASE: "YES"
armhf-dev-docker: armv7-dev-docker:
<<: *dev <<: *dev
variables: variables:
BUILD_ARCH: armhf BUILD_ARCH: armv7
DEV: "YES" DEV: "YES"
IS_HASSIO: "NO" IS_HASSIO: "NO"
armhf-dev-hassio: armv7-dev-hassio:
<<: *dev <<: *dev
variables: variables:
BUILD_ARCH: armhf BUILD_ARCH: armv7
DEV: "YES" DEV: "YES"
IS_HASSIO: "YES" IS_HASSIO: "YES"
armhf-latest-docker: armv7-latest-docker:
<<: *latest <<: *latest
variables: variables:
BETA: "YES" BETA: "YES"
BUILD_ARCH: armhf BUILD_ARCH: armv7
IS_HASSIO: "NO" IS_HASSIO: "NO"
LATEST: "YES" LATEST: "YES"
RELEASE: "YES" RELEASE: "YES"
armhf-latest-hassio: armv7-latest-hassio:
<<: *latest <<: *latest
variables: variables:
BETA: "YES" BETA: "YES"
BUILD_ARCH: armhf BUILD_ARCH: armv7
IS_HASSIO: "YES" IS_HASSIO: "YES"
LATEST: "YES" LATEST: "YES"
RELEASE: "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 && \ COPY requirements_test.txt /requirements_test.txt
pip install flake8==3.6.0 pylint==1.9.4 pillow 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 flake8==3.6.0
pillow pillow
pexpect pexpect
twine

View File

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