From b963cbde238c9f1425026e23908ae5f2d3ae66ca Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Sun, 22 Sep 2024 13:27:27 +0100 Subject: [PATCH] chore: Updated workflows --- .github/workflows/deploy_docs.yml | 29 -------------- .github/workflows/docs.yml | 57 ++++++++++++++++++++++++++++ .github/workflows/inactive.yml | 4 +- .github/workflows/main.yml | 55 +++++++++++++++++++-------- .tool-versions | 4 +- package-lock.json | 63 +++++++++++-------------------- package.json | 5 ++- 7 files changed, 126 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/deploy_docs.yml create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml deleted file mode 100644 index 785f850..0000000 --- a/.github/workflows/deploy_docs.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Deploy docs -on: - workflow_dispatch: - push: - paths: - - 'mkdocs.yml' - - '_docs/**' - branches: - - main -permissions: - contents: write -jobs: - deploy_docs: - name: Deploy docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: 3.x - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV - - uses: actions/cache@v3 - with: - key: mkdocs-material-${{ env.cache_id }} - path: .cache - restore-keys: | - mkdocs-material- - - run: pip install mkdocs-material - - run: mkdocs gh-deploy --force diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..0a73263 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,57 @@ +name: Docs +on: + workflow_dispatch: + push: + paths: + - 'mkdocs.yml' + - '_docs/**' + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build_docs: + if: ${{ (github.repository_owner == 'BottlecapDave' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main')) == false }} + name: Build docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + sparse-checkout: | + _docs + - name: asdf_install + uses: asdf-vm/actions/install@v3 + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: pip install -r requirements.txt + - run: mkdocs build --strict + + deploy_docs: + if: ${{ github.repository_owner == 'BottlecapDave' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main') }} + name: Deploy docs + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + sparse-checkout: | + _docs + - name: asdf_install + uses: asdf-vm/actions/install@v3 + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: pip install -r requirements.txt + - run: mkdocs gh-deploy --strict --force diff --git a/.github/workflows/inactive.yml b/.github/workflows/inactive.yml index b107eea..a330396 100644 --- a/.github/workflows/inactive.yml +++ b/.github/workflows/inactive.yml @@ -2,15 +2,15 @@ name: Close inactive issues on: schedule: - cron: "30 1 * * *" - jobs: close-issues: + if: ${{ github.repository_owner == 'BottlecapDave' }} runs-on: ubuntu-latest permissions: issues: write pull-requests: write steps: - - uses: actions/stale@v4 + - uses: actions/stale@v9 with: days-before-issue-stale: 30 days-before-issue-close: 14 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4aabf84..7f19971 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,57 +3,80 @@ on: schedule: - cron: '0 1 * * *' push: - paths-ignore: - - '**.md' branches: - develop - main + paths-ignore: + - 'mkdocs.yml' + - '_docs/**' pull_request: - workflow_dispatch: + branches-ignore: + - main + paths-ignore: + - 'mkdocs.yml' + - '_docs/**' jobs: validate: + if: ${{ github.event_name != 'schedule' || github.repository_owner == 'BottlecapDave' }} + name: Validate runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v3" + - uses: actions/checkout@v4 - uses: "home-assistant/actions/hassfest@master" - name: HACS Action uses: "hacs/action@main" with: - ignore: "brands" category: "integration" - test: - name: Test + unit_tests: + if: ${{ github.event_name != 'schedule' || github.repository_owner == 'BottlecapDave' }} + name: Unit Tests runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: asdf_install - uses: asdf-vm/actions/install@v1 + uses: asdf-vm/actions/install@v3 - name: Install Python modules run: | pip install -r requirements.test.txt - - name: Unit tests suite + - name: Run unit tests run: | python -m pytest tests/unit - - name: Integration tests suite + integration_tests: + # Tests are geared towards my account, so ignore for others + if: ${{ github.repository_owner == 'BottlecapDave' }} + name: Integration Tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: asdf_install + uses: asdf-vm/actions/install@v3 + - name: Install Python modules + run: | + pip install -r requirements.test.txt + - name: Run integration tests run: | python -m pytest tests/integration release: name: Release - if: github.ref == 'refs/heads/main' - needs: + if: ${{ github.repository_owner == 'BottlecapDave' && github.ref == 'refs/heads/main' }} + needs: - validate - - test + - unit_tests + - integration_tests runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: asdf_install - uses: asdf-vm/actions/install@v1 + uses: asdf-vm/actions/install@v3 - name: Install dependencies run: npm ci - name: Release diff --git a/.tool-versions b/.tool-versions index f062b71..c50d650 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -nodejs 16.13.0 -python 3.10.1 \ No newline at end of file +nodejs 22.4.0 +python 3.12.4 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 68b8bb3..a5b4024 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "ISC", "devDependencies": { - "@semantic-release/changelog": "^6.0.1", - "@semantic-release/exec": "^6.0.2", + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/exec": "^6.0.3", "@semantic-release/git": "^10.0.1", "commitizen": "^4.2.4", "conventional-changelog-eslint": "^3.0.9", @@ -533,14 +533,14 @@ } }, "node_modules/@semantic-release/changelog": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-6.0.1.tgz", - "integrity": "sha512-FT+tAGdWHr0RCM3EpWegWnvXJ05LQtBkQUaQRIExONoXjVjLuOILNm4DEKNaV+GAQyJjbLRVs57ti//GypH6PA==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-6.0.3.tgz", + "integrity": "sha512-dZuR5qByyfe3Y03TpmCvAxCyTnp7r5XwtHRf/8vD9EAn4ZWbavUX8adMtXYzE86EVh0gyLA7lm5yW4IV30XUag==", "dev": true, "dependencies": { "@semantic-release/error": "^3.0.0", "aggregate-error": "^3.0.0", - "fs-extra": "^9.0.0", + "fs-extra": "^11.0.0", "lodash": "^4.17.4" }, "engines": { @@ -551,18 +551,17 @@ } }, "node_modules/@semantic-release/changelog/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", "dev": true, "dependencies": { - "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" }, "engines": { - "node": ">=10" + "node": ">=14.14" } }, "node_modules/@semantic-release/commit-analyzer": { @@ -596,9 +595,9 @@ } }, "node_modules/@semantic-release/exec": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-6.0.2.tgz", - "integrity": "sha512-ciaqJTHB1TFtU6C78xrgmoNI9UyfheR9+Bk6Ico7CJ7+ADOEAvUrPBKvz64UCfoWlg+SlKGTVGbFnA509wRUVw==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-6.0.3.tgz", + "integrity": "sha512-bxAq8vLOw76aV89vxxICecEa8jfaWwYITw6X74zzlO0mc/Bgieqx9kBRz9z96pHectiTAtsCwsQcUyLYWnp3VQ==", "dev": true, "dependencies": { "@semantic-release/error": "^3.0.0", @@ -930,15 +929,6 @@ "node": ">=0.10.0" } }, - "node_modules/at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true, - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -8333,24 +8323,23 @@ } }, "@semantic-release/changelog": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-6.0.1.tgz", - "integrity": "sha512-FT+tAGdWHr0RCM3EpWegWnvXJ05LQtBkQUaQRIExONoXjVjLuOILNm4DEKNaV+GAQyJjbLRVs57ti//GypH6PA==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-6.0.3.tgz", + "integrity": "sha512-dZuR5qByyfe3Y03TpmCvAxCyTnp7r5XwtHRf/8vD9EAn4ZWbavUX8adMtXYzE86EVh0gyLA7lm5yW4IV30XUag==", "dev": true, "requires": { "@semantic-release/error": "^3.0.0", "aggregate-error": "^3.0.0", - "fs-extra": "^9.0.0", + "fs-extra": "^11.0.0", "lodash": "^4.17.4" }, "dependencies": { "fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", "dev": true, "requires": { - "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" @@ -8380,9 +8369,9 @@ "dev": true }, "@semantic-release/exec": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-6.0.2.tgz", - "integrity": "sha512-ciaqJTHB1TFtU6C78xrgmoNI9UyfheR9+Bk6Ico7CJ7+ADOEAvUrPBKvz64UCfoWlg+SlKGTVGbFnA509wRUVw==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-6.0.3.tgz", + "integrity": "sha512-bxAq8vLOw76aV89vxxICecEa8jfaWwYITw6X74zzlO0mc/Bgieqx9kBRz9z96pHectiTAtsCwsQcUyLYWnp3VQ==", "dev": true, "requires": { "@semantic-release/error": "^3.0.0", @@ -8646,12 +8635,6 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, - "at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true - }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", diff --git a/package.json b/package.json index e291cc4..266aa7a 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Home Assistant integration for interacting with Carbon Intensity", "main": "index.js", "scripts": { + "build": "tsc ./.build/*.ts --noEmit", "commit": "cz", "release": "semantic-release", "test-unit": "python -m pytest tests/unit", @@ -21,8 +22,8 @@ }, "homepage": "https://github.com/BottlecapDave/HomeAssistant-CarbonIntensity#readme", "devDependencies": { - "@semantic-release/changelog": "^6.0.1", - "@semantic-release/exec": "^6.0.2", + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/exec": "^6.0.3", "@semantic-release/git": "^10.0.1", "commitizen": "^4.2.4", "conventional-changelog-eslint": "^3.0.9",