Move from azure pipelines to github action for CI (#1646)

* Move from azure pipelines to github action for CI

* pin version

* pin directly
This commit is contained in:
Joakim Sørensen
2020-10-25 16:53:45 +01:00
committed by GitHub
parent 4ee8832db6
commit 8b7dc6d50f
29 changed files with 170 additions and 653 deletions

View File

@@ -66,7 +66,7 @@ function cleanup_hass_data() {
function cleanup_docker() {
echo "Cleaning up stopped containers..."
docker rm $(docker ps -a -q)
docker rm "$(docker ps -a -q)"
}
function cleanup_lastboot() {

8
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
time: "06:00"
open-pull-requests-limit: 10

View File

@@ -1,72 +0,0 @@
name: Build
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- master
jobs:
init:
runs-on: ubuntu-latest
name: Initialize builds
outputs:
changed_files: ${{ steps.changed_files.outputs.all }}
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Get changed files
id: changed_files
uses: jitterbit/get-changed-files@v1
build:
needs: init
runs-on: ubuntu-latest
name: Build ${{ matrix.addon }} add-on
outputs:
changed: ${{ steps.changed.outputs.changed }}
strategy:
fail-fast: False
matrix:
addon:
- ada
- almond
- cec_scan
- check_config
- configurator
- deconz
- dhcp_server
- dnsmasq
- duckdns
- git_pull
- google_assistant
- homematic
- letsencrypt
- mariadb
- mosquitto
- nginx_proxy
- rpc_shutdown
- samba
- ssh
- tellstick
- zwave
steps:
- name: Check if ${{ matrix.addon }} was changed
id: changed
run: |
if [[ "${{ needs.init.outputs.changed_files }}" =~ "${{ matrix.addon }}" ]]; then
echo "::set-output name=changed::true"
fi
- name: Check out repository
if: steps.changed.outputs.changed == 'true'
uses: actions/checkout@v2
- name: Test docker build for ${{ matrix.addon }}
if: steps.changed.outputs.changed == 'true'
uses: home-assistant/builder@master
with:
args: |
--test \
--all \
--target /data/${{ matrix.addon }}

109
.github/workflows/builder.yml vendored Normal file
View File

@@ -0,0 +1,109 @@
name: Build add-on
env:
BUILD_ARGS: "--test"
MONITORED_FILES: "apparmor.txt build.json config.json Dockerfile data rootfs"
on:
pull_request:
branches: ["master"]
push:
branches: ["master"]
jobs:
init:
runs-on: ubuntu-latest
name: Initialize builds
outputs:
changed_files: ${{ steps.changed_files.outputs.all }}
changed_addons: ${{ steps.changed_addons.outputs.addons }}
changed: ${{ steps.changed_addons.outputs.changed }}
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Get changed files
id: changed_files
uses: jitterbit/get-changed-files@v1
- name: Get add-ons
id: addons
run: |
addons=$(find ./ -name config.json | cut -d "/" -f2 | sort -u)
echo "::set-output name=addons::$addons"
- name: Get changed add-ons
id: changed_addons
run: |
declare -a changed_addons
for addon in ${{ steps.addons.outputs.addons }}; do
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then
for file in ${{ env.MONITORED_FILES }}; do
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then
changed_addons+=("\"${addon}\",");
fi
done
fi
done
changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev)
echo "::set-output name=addons::[$changed]"
if [[ ! -z ${changed} ]]; then
echo "Changed add-ons: $changed"
echo "::set-output name=changed::true"
else
echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"
fi
build:
needs: init
runs-on: ubuntu-latest
if: needs.init.outputs.changed == 'true'
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
strategy:
matrix:
addon: ${{ fromJson(needs.init.outputs.changed_addons) }}
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Get information
id: info
uses: home-assistant/actions/helpers/info@master
with:
path: "./${{ matrix.addon }}"
- name: Check add-on
id: check
run:
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
echo "::set-output name=buld_arch::true";
else
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"
fi
- name: Set build arguments
if: steps.check.outputs.buld_arch == 'true'
run: |
if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then
echo "BUILD_ARGS=--docker-hub-check" >> $GITHUB_ENV;
fi
- name: Login to DockerHub
if: env.BUILD_ARGS == '--docker-hub-check'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build ${{ matrix.addon }} add-on
if: steps.check.outputs.buld_arch == 'true'
uses: home-assistant/builder@master
with:
args: |
${{ env.BUILD_ARGS }} \
--${{ matrix.arch }} \
--target /data/${{ matrix.addon }} \
--docker-hub homeassistant

52
.github/workflows/lint.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
name: Lint
env:
HADOLINT_VERSION: v1.17.2
SHELLCHECK_OPTS: -e SC1008 -s bash
on:
pull_request:
branches: ["master"]
push:
branches: ["master"]
jobs:
hadolint:
runs-on: ubuntu-latest
name: hadolint
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Run linter
id: changed_files
run: |
shopt -s globstar
for dockerfile in **/Dockerfile; do
echo "Linting: $dockerfile"
docker run --rm -i \
-v $(pwd)/.hadolint.yaml:/.hadolint.yaml:ro \
hadolint/hadolint:${{ env.HADOLINT_VERSION }} < "$dockerfile"
done
jq:
runs-on: ubuntu-latest
name: JQ
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Run linter
run: |
shopt -s globstar
cat **/*.json | jq '.'
shellcheck:
runs-on: ubuntu-latest
name: ShellCheck
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Run linter
uses: ludeeus/action-shellcheck@0.5.0

View File

@@ -1 +0,0 @@
disable=SC1008

View File

@@ -1,7 +1,5 @@
# Home Assistant Add-ons: The official repository
[![Build Status](https://dev.azure.com/home-assistant/Hass.io/_apis/build/status/addons?branchName=master)](https://dev.azure.com/home-assistant/Hass.io/_build/latest?definitionId=7&branchName=master)
Add-ons for Home Assistant, allow you to extend the functionality
around your Home Assistant setup. These add-ons can consist of an application
that Home Assistant can integrate with (e.g., a MQTT broker or database server)

View File

@@ -1,28 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- ada/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "ada"
arch:
- amd64
- armv7
- armhf

View File

@@ -1,28 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- almond/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "almond"
arch:
- amd64
- armv7
- aarch64

View File

@@ -1,54 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
pr:
- master
variables:
versionHadolint: "v1.17.2"
versionShellCheck: "v0.7.0"
jobs:
- job: "Hadolint"
pool:
vmImage: "ubuntu-latest"
steps:
- script: sudo docker pull hadolint/hadolint:$(versionHadolint)
displayName: "Install Hadolint"
- script: |
set -e
shopt -s globstar
for dockerfile in **/Dockerfile
do
echo "Linting: $dockerfile"
sudo docker run --rm -i \
-v $(pwd)/.hadolint.yaml:/.hadolint.yaml:ro \
hadolint/hadolint:$(versionHadolint) < "$dockerfile"
done
displayName: "Run Hadolint"
- job: "ShellCheck"
pool:
vmImage: "ubuntu-latest"
steps:
- script: sudo docker pull koalaman/shellcheck:$(versionShellCheck)
displayName: "Install ShellCheck"
- script: |
shopt -s globstar
sudo docker run --rm -i \
-v $(pwd):/mnt:ro koalaman/shellcheck:$(versionShellCheck) -s bash **/{*.sh,run}
displayName: "Run ShellCheck"
- job: "JQ"
pool:
vmImage: "ubuntu-latest"
steps:
- script: sudo apt-get install -y jq
displayName: "Install JQ"
- bash: |
shopt -s globstar
cat **/*.json | jq '.'
displayName: "Run JQ"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- cec_scan/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "cec_scan"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- check_config/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "check_config"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- configurator/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "configurator"

View File

@@ -1,28 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- deconz/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "deconz"
arch:
- armhf
- amd64
- aarch64

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- dhcp_server/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "dhcp_server"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- dnsmasq/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "dnsmasq"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- duckdns/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "duckdns"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- git_pull/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "git_pull"

View File

@@ -1,28 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- google_assistant/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "google_assistant"
arch:
- armv7
- armhf
- amd64

View File

@@ -1,27 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- homematic/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "homematic"
arch:
- armv7
- i386

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- letsencrypt/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "letsencrypt"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- mariadb/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "mariadb"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- mosquitto/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "mosquitto"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- nginx_proxy/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "nginx_proxy"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- rpc_shutdown/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "rpc_shutdown"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- samba/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "samba"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- ssh/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "ssh"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- tellstick/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "tellstick"

View File

@@ -1,24 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
branches:
include:
- master
paths:
include:
- zwave/*
pr: none
resources:
repositories:
- repository: azure
type: github
name: "home-assistant/ci-azure"
endpoint: "home-assistant"
variables:
- group: docker
jobs:
- template: templates/azp-job-addon.yaml@azure
parameters:
addon: "zwave"