Protect against aborted connections (#42) #129
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Actions" | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
jobs: | |
lint: | |
name: pre-commit | |
runs-on: ubuntu-latest | |
steps: | |
- name: π¦ Checkout the repository | |
uses: actions/checkout@v4 | |
- name: π¦ Set up Python | |
uses: actions/[email protected] | |
- name: β Run pre-commit | |
uses: pre-commit/[email protected] | |
directory: | |
needs: lint | |
name: Validate directory for ${{ matrix.target.name }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- { name: "Current Directory", path: "$PWD" } | |
- { name: "Dev setup", path: "$PWD/config" } | |
- { name: "Container", path: "/tmp/config" } | |
- { name: "Venv", path: "$HOME/.homeassistant" } | |
- { | |
name: "Supervised local", | |
path: "/usr/share/hassio/homeassistant", | |
} | |
steps: | |
- name: π¦ Checkout the repository | |
uses: actions/checkout@v4 | |
- name: π Workaround for action runner limitation | |
if: matrix.target.name == 'Container' | |
run: sed -i 's/"\/config"/"\/tmp\/config"/' get | |
- name: β Test no Home Assistant configuration directory | |
run: | | |
set +e | |
bash ./get | |
if [ "$?" != 1 ];then | |
exit 1 | |
fi | |
set -e | |
- name: βπ» Create .HA_VERSION file | |
run: | | |
mkdir -p ${{ matrix.target.path }} | |
echo "3000.1.1" > ${{ matrix.target.path }}/.HA_VERSION | |
- name: πββοΈ Run the downloader | |
run: bash ./get | |
- name: π Verify content | |
run: | | |
if [ ! -f "${{ matrix.target.path }}/custom_components/hacs/manifest.json" ]; then | |
exit 1 | |
fi | |
if [ -f "${{ matrix.target.path }}/custom_components/hacs.zip" ]; then | |
exit 1 | |
fi | |
version: | |
needs: lint | |
name: Validate version ${{ matrix.version.current }}-${{ matrix.version.target }} (${{ matrix.version.result }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
version: | |
- { current: "2023.1.1", target: "2023.1.1", result: 0 } | |
- { current: "2023.1.1", target: "2023.1.1b4", result: 0 } | |
- { current: "2022.1.1", target: "2023.1.1", result: 1 } | |
- { current: "2022.1.1", target: "2023.1.3", result: 1 } | |
- { current: "2023.12.0", target: "2023.1.3", result: 1 } | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Create .HA_VERSION file | |
run: echo "${{ matrix.version.current }}" > .HA_VERSION | |
- name: Create fake const.py file | |
run: echo 'MINIMUM_HA_VERSION = "${{ matrix.version.target }}"' > const.py | |
- name: Patch script so we can actually check | |
run: sed -i 's|/custom_components/hacs/const.py|/const.py|' get | |
- name: Run the script and check result | |
run: | | |
set +e | |
bash ./get | |
if [ "$?" != ${{ matrix.version.result }} ];then | |
exit 1 | |
fi | |
set -e | |
- name: π Verify content exists | |
if: matrix.version.result == 0 | |
run: | | |
if [ ! -f "./custom_components/hacs/manifest.json" ]; then | |
exit 1 | |
fi | |
- name: π Verify content is missing | |
if: matrix.version.result == 1 | |
run: | | |
if [ -f "./custom_components/hacs/manifest.json" ]; then | |
exit 1 | |
fi | |
- name: π Verify cleanup | |
run: | | |
if [ -f "${{ matrix.target.path }}/custom_components/hacs.zip" ]; then | |
exit 1 | |
fi |