Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split workflow processes. #588

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/check_ota_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Check OTA PR
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches: [master]
paths: ['images/**']

jobs:
check-ota-pr:
runs-on: ubuntu-latest
# don't run if PR was closed without merge, or explicitly disabled
if: |
!contains(github.event.pull_request.labels.*.name, 'ignore-ota-workflow')
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build

- name: Check OTA PR
uses: actions/github-script@v7
with:
script: |
const {checkOtaPR} = await import("${{ github.workspace }}/dist/ghw_check_ota_pr.js")

await checkOtaPR(github, core, context)

- uses: actions/upload-artifact@v4
if: always()
with:
name: pr
path: pr/
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build

- name: Lint
run: |
pnpm run format:check
pnpm run eslint

- name: Test
# NOTE: see jest.config.ts `collectCoverageFrom`
run: pnpm run coverage
6 changes: 6 additions & 0 deletions .github/workflows/concat_cacerts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build

- name: Concat CACerts
uses: actions/github-script@v7
with:
script: |
const {concatCaCerts} = await import("${{ github.workspace }}/dist/ghw_concat_cacerts.js")

await concatCaCerts(github, core, context)

- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/overwrite_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build

- name: Overwrite cache
uses: actions/github-script@v7
with:
script: |
const {overwriteCache} = await import("${{ github.workspace }}/dist/gwh_overwrite_cache.js")

await overwriteCache(github, core, context, "${{ inputs.manufacturers || '' }}")

- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/report_ota_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Report OTA PR
on:
workflow_run:
workflows: ['Check OTA PR']
types:
- completed

permissions:
contents: read
pull-requests: write
actions: read

jobs:
report-ota-pr:
runs-on: ubuntu-latest
# should never be anything else...
if: |
github.event.workflow_run.event == 'pull_request'
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build

- name: Check OTA PR
uses: actions/github-script@v7
with:
script: |
const {reportOtaPR} = await import("${{ github.workspace }}/dist/ghw_report_ota_pr.js")

await reportOtaPR(github, core, context)
8 changes: 8 additions & 0 deletions .github/workflows/reprocess_all_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build

- name: Create and checkout new branch
id: create_branch
run: |
Expand All @@ -42,6 +47,7 @@ jobs:
branch_name="reprocess-$(date +'%Y-%m-%d-%H-%M-%S')"
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
git checkout -b $branch_name

- name: Reprocess
uses: actions/github-script@v7
env:
Expand All @@ -51,11 +57,13 @@ jobs:
const {reProcessAllImages} = await import("${{ github.workspace }}/dist/ghw_reprocess_all_images.js")

await reProcessAllImages(github, core, context, ${{ fromJSON(inputs.remove_not_in_manifest) }}, true)

- name: Commit changes in new branch
run: |
git add .
git commit -m "Re-Processed all images" || echo 'Nothing to commit'
git push -u origin HEAD

- name: Create pull request
uses: actions/github-script@v7
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/run_autodl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build

- name: Run Autodl
uses: actions/github-script@v7
env:
Expand All @@ -51,13 +56,15 @@ jobs:
const {runAutodl} = await import("${{ github.workspace }}/dist/ghw_run_autodl.js")

await runAutodl(github, core, context, "${{ inputs.manufacturers || '' }}")

- name: Create Autodl release
uses: actions/github-script@v7
with:
script: |
const {createAutodlRelease} = await import("${{ github.workspace }}/dist/ghw_create_autodl_release.js")

await createAutodlRelease(github, core, context)

- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
name: Update OTA PR
name: Update manifests
on:
pull_request:
types: [opened, synchronize, reopened, edited, closed]
push:
branches: [master]
paths: ['images/**']

permissions:
contents: write
pull-requests: write

jobs:
update-pr:
update-manifests:
runs-on: ubuntu-latest
# don't run if PR was closed without merge, or explicitly disabled
if: |
!contains(github.event.pull_request.labels.*.name, 'ignore-ota-workflow') && (github.event.action != 'closed' || github.event.pull_request.merged == true)
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build
- name: Get changed files
run: |
files=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' | tr '\n' ',')
echo "files=$files" >> $GITHUB_OUTPUT
id: changed_files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update PR

- name: Update manifests
uses: actions/github-script@v7
with:
script: |
const {updateOtaPR} = await import("${{ github.workspace }}/dist/ghw_update_ota_pr.js")
const {updateManifests} = await import("${{ github.workspace }}/dist/ghw_update_manifests.js")

await updateManifests(github, core, context)

await updateOtaPR(github, core, context, "${{steps.changed_files.outputs.files}}")
- name: Commit changes on push
if: github.event.pull_request.merged == true
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dist/
temp/
tmp/
.jest-tmp/
pr/
tsconfig.tsbuildinfo

# used by tests
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zigbee-ota",
"version": "1.0.0",
"version": "1.1.0",
"repository": {
"type": "git",
"url": "git+https://github.com/Koenkk/zigbee-OTA.git"
Expand Down Expand Up @@ -47,19 +47,19 @@
"devDependencies": {
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0",
"@eslint/core": "^0.7.0",
"@eslint/core": "^0.8.0",
"@eslint/js": "^9.13.0",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@octokit/rest": "^21.0.2",
"@types/jest": "^29.5.14",
"@types/node": "^22.8.1",
"@types/node": "^22.8.6",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.12.0"
"typescript-eslint": "^8.12.2"
}
}
Loading