esphome/.github/workflows/release-dev.yml

247 lines
8.0 KiB
YAML
Raw Normal View History

2020-07-14 14:34:44 +02:00
name: Publish dev releases to docker hub
on:
push:
branches:
- dev
jobs:
# THE LINT/TEST JOBS ARE COPIED FROM ci.yaml
2020-07-15 01:37:30 +02:00
2020-07-14 14:34:44 +02:00
lint-clang-format:
runs-on: ubuntu-latest
# cpp lint job runs with esphome-lint docker image so that clang-format-*
# doesn't have to be installed
2020-07-15 01:37:30 +02:00
container: esphome/esphome-lint:latest
2020-07-14 14:34:44 +02:00
steps:
- uses: actions/checkout@v2
# Set up the pio project so that the cpp checks know how files are compiled
# (build flags, libraries etc)
- name: Set up platformio environment
run: pio init --ide atom
- name: Run clang-format
run: script/clang-format -i
- name: Suggest changes
run: script/ci-suggest-changes
lint-clang-tidy:
runs-on: ubuntu-latest
# cpp lint job runs with esphome-lint docker image so that clang-format-*
# doesn't have to be installed
2020-07-15 01:37:30 +02:00
container: esphome/esphome-lint:latest
2020-07-14 14:34:44 +02:00
# Split clang-tidy check into 4 jobs. Each one will check 1/4th of the .cpp files
strategy:
fail-fast: false
2020-07-14 14:34:44 +02:00
matrix:
split: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v2
# Set up the pio project so that the cpp checks know how files are compiled
# (build flags, libraries etc)
- name: Set up platformio environment
run: pio init --ide atom
2020-07-15 01:37:30 +02:00
2020-07-14 14:34:44 +02:00
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/clang-tidy.json"
echo "::add-matcher::.github/workflows/matchers/gcc.json"
- name: Run clang-tidy
run: script/clang-tidy --all-headers --fix --split-num 4 --split-at ${{ matrix.split }}
- name: Suggest changes
run: script/ci-suggest-changes
lint-python:
# Don't use the esphome-lint docker image because it may contain outdated requirements.
# This way, all dependencies are cached via the cache action.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Cache pip modules
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: esphome-pip-3.7-${{ hashFiles('setup.py') }}
restore-keys: |
esphome-pip-3.7-
- name: Set up python environment
run: script/setup
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/ci-custom.json"
echo "::add-matcher::.github/workflows/matchers/lint-python.json"
echo "::add-matcher::.github/workflows/matchers/python.json"
- name: Lint Custom
run: script/ci-custom.py
- name: Lint Python
run: script/lint-python
2020-07-25 15:57:18 +02:00
- name: Lint CODEOWNERS
run: script/build_codeowners.py --check
2020-07-14 14:34:44 +02:00
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
2020-07-14 14:34:44 +02:00
matrix:
test:
- test1
- test2
- test3
- test4
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Cache pip modules
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: esphome-pip-3.7-${{ hashFiles('setup.py') }}
restore-keys: |
esphome-pip-3.7-
# Use per test platformio cache because tests have different platform versions
- name: Cache ~/.platformio
uses: actions/cache@v1
with:
path: ~/.platformio
key: test-home-platformio-${{ matrix.test }}-${{ hashFiles('esphome/core/config.py') }}
2020-07-14 14:34:44 +02:00
restore-keys: |
test-home-platformio-${{ matrix.test }}-
- name: Set up environment
run: script/setup
2020-07-15 01:37:30 +02:00
2020-07-14 14:34:44 +02:00
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/gcc.json"
echo "::add-matcher::.github/workflows/matchers/python.json"
- run: esphome tests/${{ matrix.test }}.yaml compile
2020-07-15 14:00:02 +02:00
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Cache pip modules
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: esphome-pip-3.7-${{ hashFiles('setup.py') }}
restore-keys: |
esphome-pip-3.7-
- name: Set up environment
run: script/setup
- name: Install Github Actions annotator
run: pip install pytest-github-actions-annotate-failures
2020-07-15 14:00:02 +02:00
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/python.json"
- name: Run pytest
run: |
pytest \
-qq \
--durations=10 \
-o console_output_style=count \
tests
2020-07-14 14:34:44 +02:00
deploy-docker:
name: Build and publish docker containers
if: github.repository == 'esphome/esphome'
2020-07-14 14:34:44 +02:00
runs-on: ubuntu-latest
2020-07-15 14:00:02 +02:00
needs: [lint-clang-format, lint-clang-tidy, lint-python, test, pytest]
2020-07-14 14:34:44 +02:00
strategy:
matrix:
arch: [amd64, armv7, aarch64]
# Hassio dev image doesn't use esphome/esphome-hassio-$arch and uses base directly
build_type: ["docker"]
2020-07-14 14:34:44 +02:00
steps:
- uses: actions/checkout@v2
2020-07-15 01:37:30 +02:00
- name: Set TAG
run: |
TAG="${GITHUB_SHA:0:7}"
echo "TAG=${TAG}" >> $GITHUB_ENV
2020-07-14 14:34:44 +02:00
- name: Set up env variables
run: |
2021-03-20 20:58:46 +01:00
base_version="3.0.0"
2020-07-14 14:34:44 +02:00
if [[ "${{ matrix.build_type }}" == "hassio" ]]; then
build_from="esphome/esphome-hassio-base-${{ matrix.arch }}:${base_version}"
2020-07-15 01:37:30 +02:00
build_to="esphome/esphome-hassio-${{ matrix.arch }}"
2020-07-14 14:34:44 +02:00
dockerfile="docker/Dockerfile.hassio"
else
build_from="esphome/esphome-base-${{ matrix.arch }}:${base_version}"
2020-07-15 01:37:30 +02:00
build_to="esphome/esphome-${{ matrix.arch }}"
2020-07-14 14:34:44 +02:00
dockerfile="docker/Dockerfile"
fi
echo "BUILD_FROM=${build_from}" >> $GITHUB_ENV
echo "BUILD_TO=${build_to}" >> $GITHUB_ENV
echo "DOCKERFILE=${dockerfile}" >> $GITHUB_ENV
2020-07-15 01:37:30 +02:00
- name: Pull for cache
run: |
docker pull "${BUILD_TO}:dev" || true
2020-07-14 14:34:44 +02:00
- name: Register QEMU binfmt
2021-03-20 20:58:46 +01:00
run: docker run --rm --privileged multiarch/qemu-user-static:5.2.0-2 --reset -p yes
2020-07-14 14:34:44 +02:00
- run: |
docker build \
--build-arg "BUILD_FROM=${BUILD_FROM}" \
--build-arg "BUILD_VERSION=${TAG}" \
2020-07-15 01:37:30 +02:00
--tag "${BUILD_TO}:${TAG}" \
--tag "${BUILD_TO}:dev" \
--cache-from "${BUILD_TO}:dev" \
2020-07-14 14:34:44 +02:00
--file "${DOCKERFILE}" \
.
- name: Log in to docker hub
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
2020-07-14 14:34:44 +02:00
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}"
2020-07-15 01:37:30 +02:00
- run: |
docker push "${BUILD_TO}:${TAG}"
docker push "${BUILD_TO}:dev"
2020-07-14 14:34:44 +02:00
deploy-docker-manifest:
if: github.repository == 'esphome/esphome'
2020-07-14 14:34:44 +02:00
runs-on: ubuntu-latest
needs: [deploy-docker]
steps:
- name: Enable experimental manifest support
run: |
mkdir -p ~/.docker
echo "{\"experimental\": \"enabled\"}" > ~/.docker/config.json
2020-07-15 01:37:30 +02:00
- name: Set TAG
run: |
TAG="${GITHUB_SHA:0:7}"
echo "TAG=${TAG}" >> $GITHUB_ENV
2020-07-14 14:34:44 +02:00
- name: Log in to docker hub
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}"
- name: "Create the manifest"
run: |
2020-07-15 01:37:30 +02:00
docker manifest create esphome/esphome:${TAG} \
esphome/esphome-aarch64:${TAG} \
esphome/esphome-amd64:${TAG} \
esphome/esphome-armv7:${TAG}
2020-07-15 01:37:30 +02:00
docker manifest push esphome/esphome:${TAG}
docker manifest create esphome/esphome:dev \
esphome/esphome-aarch64:${TAG} \
esphome/esphome-amd64:${TAG} \
esphome/esphome-armv7:${TAG}
2020-07-15 01:37:30 +02:00
docker manifest push esphome/esphome:dev