diff --git a/.github/RELEASE_NOTES.template.md b/.github/RELEASE_NOTES.template.md new file mode 100644 index 00000000..bdf04fe3 --- /dev/null +++ b/.github/RELEASE_NOTES.template.md @@ -0,0 +1,33 @@ +[![downloads](https://img.shields.io/github/downloads/xaviml/controllerx/VERSION_TAG/total?style=for-the-badge)](http://github.com/xaviml/controllerx/releases/VERSION_TAG) + + + +_This minor change does not contain any breaking changes._ +_Note: Remember to restart the AppDaemon addon/server after updating to a new version._ +PRERELEASE_NOTE + + + + + + + + + + + + diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 00000000..b6ddd6c9 --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,116 @@ +name: CI/CD + +on: + push: + branches: [main, dev] + tags: ["v*"] + pull_request: + branches: [main, dev] + +jobs: + test: + name: Styling and Testing + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10"] + fail-fast: false + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} + - name: Install dependencies + run: poetry install + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + - name: Testing + run: poetry run pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=apps --cov-report=xml --cov-report=html + - name: Upload coverage + uses: codecov/codecov-action@v2 + pre-commit: + name: pre-commit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install pre-commit + run: pip install pre-commit + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run pre-commit + run: pre-commit run --all-files --show-diff-on-failure + hacs: + name: HACS validation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: hacs/action@main + with: + category: appdaemon + deploy: + name: Deployment + runs-on: ubuntu-latest + needs: [test, pre-commit, hacs] + if: startsWith(github.ref_name,'v') + steps: + - uses: actions/checkout@v3 + - name: Archive Release + uses: thedoctor0/zip-release@master + with: + type: zip + filename: ../../controllerx.zip + directory: apps/controllerx + - run: sed -i 's/VERSION_TAG/${{ github.ref_name }}/g' RELEASE_NOTES.md + - run: "sed -i 's/PRERELEASE_NOTE/_Note: Some links might not work or might be not updated due to being a pre-release, and documentation is not yet available_/g' RELEASE_NOTES.md" + if: contains(github.ref_name, 'b') + - run: sed -i 's/PRERELEASE_NOTE//g' RELEASE_NOTES.md + if: "!contains(github.ref_name, 'b')" + - uses: ncipollo/release-action@v1 + with: + artifacts: controllerx.zip + prerelease: ${{ contains(github.ref_name, 'b') }} + bodyFile: RELEASE_NOTES.md + generateReleaseNotes: true + post_deploy: + name: Post deployment + runs-on: ubuntu-latest + needs: [deploy] + if: startsWith(github.ref_name,'v') && !contains(github.ref_name, 'b') + steps: + - uses: actions/checkout@v3 + with: + ref: main + - run: mv RELEASE_NOTES.md RELEASE_NOTES.old.md + - run: cp .github/RELEASE_NOTES.template.md RELEASE_NOTES.md + - name: Commit report + if: hashFiles('RELEASE_NOTES.old.md') != hashFiles('RELEASE_NOTES.md') + run: | + git config --global user.name 'xaviml' + git config --global user.email 'xaviml@users.noreply.github.com' + git add RELEASE_NOTES.md + git commit -m "Upload RELEASE_NOTES.md" + git push origin HEAD + - name: Merge main -> dev + if: hashFiles('RELEASE_NOTES.old.md') != hashFiles('RELEASE_NOTES.md') + uses: devmasx/merge-branch@master + with: + type: now + from_branch: main + target_branch: dev + github_token: ${{ github.token }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8f0f05e4..c2795306 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -17,35 +17,35 @@ jobs: actions: read contents: read security-events: write - strategy: fail-fast: false matrix: python_version: ["3.7", "3.8", "3.9", "3.10"] - steps: - name: Checkout repository - uses: actions/checkout@v2 - - # Setup Python (faster than using Python container) + uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ matrix.python_version }} - - name: Install poetry - run: | - python -m pip install --upgrade poetry - + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} - name: Install dependencies - run: | - poetry install - + run: poetry install + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: python setup-python-dependencies: false - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/hacs.yml b/.github/workflows/hacs.yml index 8c76f4d6..e510c64a 100644 --- a/.github/workflows/hacs.yml +++ b/.github/workflows/hacs.yml @@ -1,8 +1,6 @@ name: Validate on: - push: - pull_request: schedule: - cron: "0 0 * * *" @@ -10,8 +8,8 @@ jobs: validate: runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v2" + - uses: actions/checkout@v3 - name: HACS validation - uses: "hacs/action@main" + uses: hacs/action@main with: - category: "appdaemon" + category: appdaemon diff --git a/.github/workflows/update-license.yml b/.github/workflows/update-license.yml index 7321100f..af92e28a 100644 --- a/.github/workflows/update-license.yml +++ b/.github/workflows/update-license.yml @@ -9,7 +9,7 @@ jobs: run: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: FantasticFiasco/action-update-license-year@v2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index baca892d..c6d38c36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,7 +140,7 @@ git push HEAD: ## Deployment -Thanks to the Azure Pipelines, we are able to deploy by just creating a new tag on git. Before proceding with new version bump, make sure to have all the changes for this release in the `RELEASE_NOTES.md` file. +Thanks to the GitHub Actions, we are able to deploy by just creating a new tag on git. Before proceding with new version bump, make sure to have all the changes for this release in the `RELEASE_NOTES.md` file. We use `commitizen` to bump version. First, we might want to create a beta version from `dev` branch: diff --git a/README.md b/README.md index 46d44c26..c4c10361 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ [![logo](https://github.com/xaviml/controllerx/raw/dev/docs/android-chrome-192x192.png)](https://github.com/xaviml/controllerx/releases) [![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration) -[![azure-pipelines-build](https://img.shields.io/azure-devops/build/xaviml93/315b7979-e97e-4004-ac60-8a5cdad5a176/1/main?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=main) +[![github-check-status](https://img.shields.io/github/checks-status/xaviml/controllerx/main?style=for-the-badge)](https://github.com/xaviml/controllerx/actions?query=branch%3Amain) [![last-release](https://img.shields.io/github/v/release/xaviml/controllerx.svg?style=for-the-badge)](https://github.com/xaviml/controllerx/releases) [![downloads-latest](https://img.shields.io/github/downloads/xaviml/controllerx/latest/total?style=for-the-badge)](http://github.com/xaviml/controllerx/releases/latest) -[![azure-pipelines-coverage](https://img.shields.io/azure-devops/coverage/xaviml93/315b7979-e97e-4004-ac60-8a5cdad5a176/1/main?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=main) +[![code-coverage](https://img.shields.io/codecov/c/gh/xaviml/controllerx/main?style=for-the-badge&token=7PUZHL97IG)](https://app.codecov.io/gh/xaviml/controllerx/branch/main) [![community-topic](https://img.shields.io/badge/community-topic-blue?style=for-the-badge)](https://community.home-assistant.io/t/controllerx-bring-full-functionality-to-light-and-media-player-controllers/148855) [![buy-me-a-beer](https://img.shields.io/badge/sponsor-Buy%20me%20a%20beer-orange?style=for-the-badge)](https://www.buymeacoffee.com/xaviml) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 10acd575..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,83 +0,0 @@ -# Python package -# Create and test a Python package on multiple Python versions. -# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/python - -trigger: - - main - - dev - - refs/tags/* - -pr: - - main - - dev - -pool: - vmImage: ubuntu-latest - -stages: - - stage: Build - displayName: Build Stage - jobs: - - job: Build - displayName: Build job - strategy: - matrix: - Python37: - python.version: "3.7" - Python38: - python.version: "3.8" - Python39: - python.version: "3.9" - Python310: - python.version: "3.10" - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: $(python.version) - displayName: Prepare Python $(python.version) - - script: pip install poetry - displayName: Install poetry - - script: poetry config virtualenvs.create false && poetry install - displayName: Install dependencies - - script: pre-commit run --all-files --show-diff-on-failure - displayName: Run pre-commit - - script: pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=apps --cov-report=xml --cov-report=html - displayName: Tests (pytest) - - task: PublishCodeCoverageResults@1 - displayName: Publish code coverage - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml - - stage: Deploy - displayName: Deploy Stage - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) - jobs: - - job: Deploy - displayName: Deploy job - steps: - - task: ArchiveFiles@2 - displayName: Zipping apps/controllerx folder - inputs: - rootFolderOrFile: $(System.DefaultWorkingDirectory)/apps/controllerx - includeRootFolder: false - archiveType: zip - archiveFile: $(Build.ArtifactStagingDirectory)/controllerx.zip - - script: sed -i 's/VERSION_TAG/${{ variables['Build.SourceBranchName'] }}/g' RELEASE_NOTES.md - displayName: Replace version in RELEASE_NOTES.md - - script: "sed -i 's/PRERELEASE_NOTE/_Note: Some links might not work or might be not updated due to being a pre-release, and documentation is not yet available_/g' RELEASE_NOTES.md" - displayName: Replace prerelease note in RELEASE_NOTES.md - condition: contains(variables['Build.SourceBranchName'], 'b') - - script: sed -i 's/PRERELEASE_NOTE//g' RELEASE_NOTES.md - displayName: Replace prerelease note in RELEASE_NOTES.md - condition: not(contains(variables['Build.SourceBranchName'], 'b')) - - task: GithubRelease@0 - displayName: Create GitHub Release - inputs: - gitHubConnection: github.com_xaviml - repositoryName: xaviml/controllerx - isPreRelease: ${{ contains(variables['Build.SourceBranchName'], 'b') }} - assets: $(Build.ArtifactStagingDirectory)/controllerx.zip - title: $(Build.SourceBranchName) - releaseNotesSource: file - releaseNotesFile: RELEASE_NOTES.md