-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add CI tests for template Generate the default project. Check pre-commit is OK. Check pytests suite is OK. * Fix missing working-directory key * Use instance creation script to have same code * Fix generated folder name used in CI * Remove Python 3.7 and Windows Windows is failing for an not yet understand reason and Windows is not a really a supported OS for Home Assistant development. Python 3.7 is no more supported by the lib used for pytest suite. * Update CONTRIBUTING documentation
- Loading branch information
1 parent
31f4f54
commit 77f62ec
Showing
2 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Tests | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- { python-version: 3.9, os: ubuntu-latest } | ||
# - { python-version: 3.9, os: windows-latest } | ||
- { python-version: 3.9, os: macos-latest } | ||
- { python-version: 3.8, os: ubuntu-latest } | ||
# - { python-version: 3.7, os: ubuntu-latest } | ||
name: Python ${{ matrix.python-version }} (${{ matrix.os }}) | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2.3.4 | ||
with: | ||
path: cookiecutter-homeassistant-custom-component | ||
- uses: actions/setup-python@v2.2.0 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install tools using pip | ||
working-directory: cookiecutter-homeassistant-custom-component | ||
run: | | ||
pip install --constraint=.github/workflows/constraints.txt pip | ||
pip install --constraint=.github/workflows/constraints.txt cookiecutter | ||
- name: Generate project using Cookiecutter | ||
run: cookiecutter-homeassistant-custom-component/scripts/gen_instance | ||
- name: Create git repository | ||
if: matrix.os != 'windows-latest' | ||
run: | | ||
git init | ||
git config --local user.name "GitHub Action" | ||
git config --local user.email "action@github.com" | ||
git add . | ||
git commit --message="Initial import" | ||
working-directory: cookiecutter-homeassistant-custom-component-instance | ||
- name: Create git repository (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
git init | ||
git config --local user.name "GitHub Action" | ||
git config --local user.email "action@github.com" | ||
# https://github.com/cookiecutter/cookiecutter/issues/405 | ||
$ErrorActionPreference = "Continue" | ||
git add . | ||
$ErrorActionPreference = "Stop" | ||
git add --renormalize . | ||
git commit --message="Initial import" | ||
working-directory: cookiecutter-homeassistant-custom-component-instance | ||
- name: Compute cache key for pre-commit | ||
if: matrix.os != 'windows-latest' | ||
id: cache_key | ||
shell: python | ||
run: | | ||
import hashlib | ||
import sys | ||
python = "py{}.{}".format(*sys.version_info[:2]) | ||
payload = sys.version.encode() + sys.executable.encode() | ||
digest = hashlib.sha256(payload).hexdigest() | ||
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest) | ||
print("::set-output name=result::{}".format(result)) | ||
- uses: actions/cache@v2.1.3 | ||
if: matrix.os != 'windows-latest' | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: ${{ steps.cache_key.outputs.result }}-${{ hashFiles('cookiecutter-homeassistant-custom-component-instance/.pre-commit-config.yaml') }} | ||
restore-keys: | | ||
${{ steps.cache_key.outputs.result }}- | ||
- name: Install Python modules | ||
run: | | ||
pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports | ||
pip install -r requirements_test.txt | ||
working-directory: cookiecutter-homeassistant-custom-component-instance | ||
|
||
- name: Run pre-commit on all files | ||
run: | | ||
pre-commit run --all-files --show-diff-on-failure --color=always | ||
working-directory: cookiecutter-homeassistant-custom-component-instance | ||
|
||
- name: Tests suite | ||
run: | | ||
pytest \ | ||
--timeout=9 \ | ||
--durations=10 \ | ||
-n auto \ | ||
-p no:sugar \ | ||
tests | ||
working-directory: cookiecutter-homeassistant-custom-component-instance |
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