Skip to content

v0.3.0 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Manual triggered GitHub action to build a distribution binary of the Python integration driver and attach it to a release draft including a hash file
---
name: "Build & Draft Release"

on:
workflow_dispatch:
push:
branches: dev

env:
INTG_NAME: requests
# Python version to use in the builder image. See https://hub.docker.com/r/unfoldedcircle/r2-pyinstaller for possible versions.
PYTHON_VER: 3.11.6-0.2.0

jobs:
build:
name: Build Release
runs-on: ubuntu-latest
#Save version to env output variable to be able to use it in the following release job as a tag
outputs:
version: ${{ steps.get-version-and-id.outputs.VERSION }}
driver_id: ${{ steps.get-version-and-id.outputs.DRIVER_ID }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# History of 200 should be more than enough to calculate commit count since last release tag
fetch-depth: 200
# Only for testing. Delete when merging with main branch
ref: dev

- name: Get version and id
#Id needed for env output variable
id: get-version-and-id
run: |
echo "VERSION=$(jq .version -r driver.json)" >> $GITHUB_ENV
echo "DRIVER_ID=$(jq .driver_id -r driver.json)" >> $GITHUB_ENV
# Save to Github output to later use it in Create Release job
echo "VERSION=$(jq .version -r driver.json)" >> $GITHUB_OUTPUT
echo "DRIVER_ID=$(jq .driver_id -r driver.json)" >> $GITHUB_OUTPUT

- name: Build
run: |
sudo apt-get update && sudo apt-get install -y qemu binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
echo "Starting pyinstaller build"
docker run --rm --name builder \
--platform=aarch64 \
--user=$(id -u):$(id -g) \
-v ${GITHUB_WORKSPACE}:/workspace \
docker.io/unfoldedcircle/r2-pyinstaller:${PYTHON_VER} \
bash -c \
"cd /workspace && \
python -m pip install -r requirements.txt && \
pyinstaller --clean --onedir --name intg-${DRIVER_ID} --collect-all zeroconf intg-${INTG_NAME}/driver.py"

- name: Prepare artifacts
shell: bash
run: |
mkdir -p artifacts/bin
mv dist/intg-${{ env.DRIVER_ID }}/* artifacts/bin
mv artifacts/bin/intg-${{ env.DRIVER_ID }} artifacts/bin/driver
cp driver.json artifacts/
echo "ARTIFACT_NAME=uc-intg-${{ env.DRIVER_ID }}-${{ env.VERSION }}-aarch64" >> $GITHUB_ENV

- name: Create upload artifact archive
shell: bash
run: |
tar czvf ${{ env.ARTIFACT_NAME }}.tar.gz -C ${GITHUB_WORKSPACE}/artifacts .
ls -lah

- uses: actions/upload-artifact@v4
id: upload_artifact
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}.tar.gz
if-no-files-found: error
retention-days: 3

release:
name: Create Release
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: write

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4

- name: Extract build archives from downloaded files
run: |
ls -R
# extract tar.gz build archives from downloaded artifacts
# (wrapped in tar from actions/upload-artifact, then extracted into a directory by actions/download-artifact)
for D in *
do if [ -d "${D}" ]; then
mv $D/* ./
fi
done;

- name: Create hash file
run: |
for filename in *.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{needs.build.outputs.driver_id}}.hash; done;

- name: Create release draft
uses: ncipollo/release-action@v1
with:
artifacts: "*.tar.gz,${{needs.build.outputs.driver_id}}.hash"
draft: true
generateReleaseNotes: true
artifactErrorsFailBuild: true
tag: v${{needs.build.outputs.version}}

7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,9 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
*.sln.iml
*.sln.iml

# Test and config files
config.json
.venv/
manual-build+upload.sh
29 changes: 29 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[FORMAT]

# Maximum number of characters on a single line.
max-line-length=175

[MESSAGES CONTROL]

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then re-enable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"

disable=
global-statement,
too-many-instance-attributes,
too-many-arguments,
too-many-public-methods,
fixme # temporary

[STRING]

# This flag controls whether inconsistent-quotes generates a warning when the
# character used as a quote delimiter is used inconsistently within a module.
check-quote-consistency=yes
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

*Changes in the next release*

### Breaking changes
- **🎉 This integration can now also run on the remote. From now on each release will have a tar.gz file attached that can be installed on the remote** (see [Run on the remote as a custom integration driver](/README.md#Run-on-the-remote-as-a-custom-integration-driver))
- ⚠️ Running custom integrations on the remote is currently only available in beta firmware releases and requires version 1.9.2 or newer. Please keep in mind that due to the beta status there are missing firmware features that require workarounds (see link above) and that changes in future beta updates may temporarily or permanently break the functionality of this integration as a custom integration. Please wait until custom integrations are available in stable firmware releases if you don't want to take these risks.
- When running as an external integration driver the working directory when starting driver.py should now be the root of the repository. The path in docker-entry.sh has been adjusted. The configuration json file is therefore now created in the root of the integration directory. Existing users have to move config.json from the intg-requests directory

### Added
- Support for HTTP delete and head requests
- Support for adding json or xml payload data to a http request (see [Adding payload data](/README.md#adding-payload-data))
- Added an option to ignore HTTP requests errors and always return a OK/200 status code to the remote. Helpful if the server doesn't send any response or closes the connection after a command is received (fire and forget). The error message will still be logged but at debug instead of error level
- The wake-on-lan entity now supports an ipv4/v6 address or a hostname (ipv4 only) as a parameter when running as an external integration
- This feature is not supported when running the integration on the remote due to sandbox limitations
- Discover the mac address from an ip address or a hostname may not work on all systems. Please refer to the [getmac supported platforms](https://github.com/GhostofGoes/getmac?tab=readme-ov-file#platforms-currently-supported). Docker containers need to be run in the host network (`--net=host`)
- Add build.yml Github action to automatically build a self-contained binary of the integration and create a release draft with the current driver version as a tag/name

### Changed
- Due to the custom integration driver upload feature setup.json has been renamed to driver.json and moved to the root of the repository
- Add custom user agent for http requests (uc-intg-requests)
- Corrected the semantic version scheme in driver.json (x.x to x.x.x)



## [0.2-beta] - 2024-06-26

### Breaking changes
Expand All @@ -16,11 +39,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added a more granular http status code response handling
- Added optional parameter to send form data in the request body as key/value pairs (see README)
- Added optional custom global entity-independent timeout and ssl verify option in the integration setup. For self signed ssl certificates to work the ssl verify option needs to be deactivated.
- Added optional custom global entity-independent timeout and ssl verify options in the integration setup. For self signed ssl certificates to work the ssl verify option needs to be deactivated.

### Changed
- Only return an error response to the remote if the http response code is in the 400 or 500 range. Otherwise display the status code in the integration log if it's not 200/Ok



## [0.1-beta] - 2024-04-27

### Added
Expand Down
Loading