fix: Python compatibility with 3.8 #118
Workflow file for this run
This file contains hidden or 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: CI Pipeline | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ "*.*.*" ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| packages: write | |
| contents: read | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| pip install pipenv | |
| pipenv install --dev | |
| # Install pyupgrade for version compatibility checks | |
| pip install pyupgrade | |
| - name: Run tests | |
| run: pipenv run python3 -m pytest --junitxml=test-results.xml | |
| - name: Check Python syntax | |
| run: | | |
| find . -name "*.py" -type f -exec python3 -m py_compile {} \; || exit 1 | |
| - name: Check Python version compatibility | |
| run: | | |
| # Extract major and minor version numbers | |
| PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") | |
| echo "Checking compatibility with Python $PYTHON_VERSION" | |
| # Run pyupgrade to check for syntax that isn't compatible with the current Python version | |
| find . -name "*.py" -type f -exec pyupgrade --py${PYTHON_VERSION/./} {} \; -exec echo "✓ {}" \; || { | |
| echo "ERROR: Code contains syntax not compatible with Python $PYTHON_VERSION" | |
| exit 1 | |
| } | |
| - name: Validate Python code with flake8 | |
| run: pipenv run python3 -m flake8 --select BLK **/*.py | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.python-version }} | |
| path: test-results.xml | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - platform: linux/amd64 | |
| base: distroless | |
| - platform: linux/arm/v6 | |
| base: alpine | |
| - platform: linux/arm/v7 | |
| base: alpine | |
| - platform: linux/arm64 | |
| base: distroless | |
| uses: ./.github/workflows/build-image.yml | |
| with: | |
| registry: ghcr.io | |
| platform: ${{ matrix.config.platform }} | |
| base: ${{ matrix.config.base }} | |
| context: . | |
| dockerfile: ./Dockerfile | |
| image-suffix: "" | |
| digest-prefix: "digests-base-" | |
| merge: | |
| needs: [build] | |
| uses: ./.github/workflows/merge-manifests.yml | |
| with: | |
| registry: ghcr.io | |
| image-suffix: "" | |
| digest-prefix: "digests-base-" | |
| build-addon: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - linux/amd64 | |
| - linux/arm64 | |
| - linux/arm/v7 | |
| - linux/arm/v6 | |
| uses: ./.github/workflows/build-image.yml | |
| with: | |
| registry: ghcr.io | |
| platform: ${{ matrix.platform }} | |
| context: ./ha_addon | |
| dockerfile: ha_addon/Dockerfile | |
| build-args: | | |
| BUILD_FROM=ghcr.io/hassio-addons/base:14.2.2 | |
| image-suffix: "-addon" | |
| digest-prefix: "digests-addon-" | |
| merge-addon: | |
| needs: [build-addon] | |
| uses: ./.github/workflows/merge-manifests.yml | |
| with: | |
| registry: ghcr.io | |
| image-suffix: "-addon" | |
| digest-prefix: "digests-addon-" |