Skip to content

Protect against aborted connections (#42) #129

Protect against aborted connections (#42)

Protect against aborted connections (#42) #129

Workflow file for this run

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