Skip to content

Commit

Permalink
Merge pull request #475 from xaviml/ci/github-actions
Browse files Browse the repository at this point in the history
ci: add github actions
  • Loading branch information
xaviml authored May 2, 2022
2 parents 340f8ae + 94de593 commit 8007e16
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 106 deletions.
33 changes: 33 additions & 0 deletions .github/RELEASE_NOTES.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[![downloads](https://img.shields.io/github/downloads/xaviml/controllerx/VERSION_TAG/total?style=for-the-badge)](http://github.com/xaviml/controllerx/releases/VERSION_TAG)

<!--:warning: This major/minor change contains a breaking change.-->

_This minor change does not contain any breaking changes._
_Note: Remember to restart the AppDaemon addon/server after updating to a new version._
PRERELEASE_NOTE

<!--
## :pencil2: Features
-->

<!--
## :hammer: Fixes
-->

<!--
## :clock2: Performance
-->

<!--
## :scroll: Docs
-->

<!--
## :wrench: Refactor
-->

<!--
## :video_game: New devices
- [XYZ](https://xaviml.github.io/controllerx/controllers/XYZ) - add device with Z2M support. [ #123 ]
-->
116 changes: 116 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: CI/CD

on:
push:
branches: [main, dev]
tags: ["v*"]
pull_request:
branches: [main, dev]

jobs:
test:
name: Styling and Testing
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Testing
run: poetry run pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=apps --cov-report=xml --cov-report=html
- name: Upload coverage
uses: codecov/codecov-action@v2
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install pre-commit
run: pip install pre-commit
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure
hacs:
name: HACS validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hacs/action@main
with:
category: appdaemon
deploy:
name: Deployment
runs-on: ubuntu-latest
needs: [test, pre-commit, hacs]
if: startsWith(github.ref_name,'v')
steps:
- uses: actions/checkout@v3
- name: Archive Release
uses: thedoctor0/zip-release@master
with:
type: zip
filename: ../../controllerx.zip
directory: apps/controllerx
- run: sed -i 's/VERSION_TAG/${{ github.ref_name }}/g' RELEASE_NOTES.md
- run: "sed -i 's/PRERELEASE_NOTE/_Note: Some links might not work or might be not updated due to being a pre-release, and documentation is not yet available_/g' RELEASE_NOTES.md"
if: contains(github.ref_name, 'b')
- run: sed -i 's/PRERELEASE_NOTE//g' RELEASE_NOTES.md
if: "!contains(github.ref_name, 'b')"
- uses: ncipollo/release-action@v1
with:
artifacts: controllerx.zip
prerelease: ${{ contains(github.ref_name, 'b') }}
bodyFile: RELEASE_NOTES.md
generateReleaseNotes: true
post_deploy:
name: Post deployment
runs-on: ubuntu-latest
needs: [deploy]
if: startsWith(github.ref_name,'v') && !contains(github.ref_name, 'b')
steps:
- uses: actions/checkout@v3
with:
ref: main
- run: mv RELEASE_NOTES.md RELEASE_NOTES.old.md
- run: cp .github/RELEASE_NOTES.template.md RELEASE_NOTES.md
- name: Commit report
if: hashFiles('RELEASE_NOTES.old.md') != hashFiles('RELEASE_NOTES.md')
run: |
git config --global user.name 'xaviml'
git config --global user.email 'xaviml@users.noreply.github.com'
git add RELEASE_NOTES.md
git commit -m "Upload RELEASE_NOTES.md"
git push origin HEAD
- name: Merge main -> dev
if: hashFiles('RELEASE_NOTES.old.md') != hashFiles('RELEASE_NOTES.md')
uses: devmasx/merge-branch@master
with:
type: now
from_branch: main
target_branch: dev
github_token: ${{ github.token }}
28 changes: 14 additions & 14 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ jobs:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
python_version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Setup Python (faster than using Python container)
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python_version }}

- name: Install poetry
run: |
python -m pip install --upgrade poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry install
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: python
setup-python-dependencies: false

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
8 changes: 3 additions & 5 deletions .github/workflows/hacs.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Validate

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"

jobs:
validate:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: actions/checkout@v3
- name: HACS validation
uses: "hacs/action@main"
uses: hacs/action@main
with:
category: "appdaemon"
category: appdaemon
2 changes: 1 addition & 1 deletion .github/workflows/update-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: FantasticFiasco/action-update-license-year@v2
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ git push <username> HEAD:<branch>

## Deployment

Thanks to the Azure Pipelines, we are able to deploy by just creating a new tag on git. Before proceding with new version bump, make sure to have all the changes for this release in the `RELEASE_NOTES.md` file.
Thanks to the GitHub Actions, we are able to deploy by just creating a new tag on git. Before proceding with new version bump, make sure to have all the changes for this release in the `RELEASE_NOTES.md` file.

We use `commitizen` to bump version. First, we might want to create a beta version from `dev` branch:

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
[![logo](https://github.com/xaviml/controllerx/raw/dev/docs/android-chrome-192x192.png)](https://github.com/xaviml/controllerx/releases)

[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration)
[![azure-pipelines-build](https://img.shields.io/azure-devops/build/xaviml93/315b7979-e97e-4004-ac60-8a5cdad5a176/1/main?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=main)
[![github-check-status](https://img.shields.io/github/checks-status/xaviml/controllerx/main?style=for-the-badge)](https://github.com/xaviml/controllerx/actions?query=branch%3Amain)
[![last-release](https://img.shields.io/github/v/release/xaviml/controllerx.svg?style=for-the-badge)](https://github.com/xaviml/controllerx/releases)
[![downloads-latest](https://img.shields.io/github/downloads/xaviml/controllerx/latest/total?style=for-the-badge)](http://github.com/xaviml/controllerx/releases/latest)
[![azure-pipelines-coverage](https://img.shields.io/azure-devops/coverage/xaviml93/315b7979-e97e-4004-ac60-8a5cdad5a176/1/main?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=main)
[![code-coverage](https://img.shields.io/codecov/c/gh/xaviml/controllerx/main?style=for-the-badge&token=7PUZHL97IG)](https://app.codecov.io/gh/xaviml/controllerx/branch/main)
[![community-topic](https://img.shields.io/badge/community-topic-blue?style=for-the-badge)](https://community.home-assistant.io/t/controllerx-bring-full-functionality-to-light-and-media-player-controllers/148855)
[![buy-me-a-beer](https://img.shields.io/badge/sponsor-Buy%20me%20a%20beer-orange?style=for-the-badge)](https://www.buymeacoffee.com/xaviml)

Expand Down
83 changes: 0 additions & 83 deletions azure-pipelines.yml

This file was deleted.

0 comments on commit 8007e16

Please sign in to comment.