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

Automate via workflows. Add auto-archiving for downgrade. #581

Merged
merged 1 commit into from
Oct 28, 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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI
on:
pull_request:
types: [opened, synchronize]
branches: [main]
paths: ['src/**', 'tests/**']
workflow_dispatch:

jobs:
ci:
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
41 changes: 41 additions & 0 deletions .github/workflows/concat_cacerts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Concatenate CA certificates
on:
push:
branches: [main]
paths: ['cacerts/**']
workflow_dispatch:

permissions:
contents: write

jobs:
concat-cacerts:
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]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Concatenate CA certificates" || echo 'Nothing to commit'
git push
30 changes: 0 additions & 30 deletions .github/workflows/linter.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/overwrite_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Overwrite cache
on:
workflow_dispatch:
inputs:
manufacturers:
description: 'Only trigger overwrite for given manufacturers (CSV, no space).'
required: false
default: ''
type: string

permissions:
contents: write

jobs:
overwrite-cache:
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]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Cache overwrite" || echo 'Nothing to commit'
git push
66 changes: 66 additions & 0 deletions .github/workflows/reprocess_all_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Re-Process All Images
on:
workflow_dispatch:
inputs:
remove_not_in_manifest:
description: 'Remove images not found in manifest (if false, will be moved to separate dir instead).'
required: true
default: false
type: boolean
# TODO: remove this and the logic behind it once the first run has been executed to prevent following accidental executions
skip_download_third_parties:
description: 'Skip the step that downloads firmware with 3rd party URLs in manifest (logic should be removed after first run after 2024-10 revamp).'
required: true
default: true
type: boolean

permissions:
contents: write
pull-requests: write

jobs:
reprocess-all-images:
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: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
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:
NODE_EXTRA_CA_CERTS: cacerts.pem
with:
script: |
const {reProcessAllImages} = await import("${{ github.workspace }}/dist/ghw_reprocess_all_images.js")

await reProcessAllImages(github, core, context, ${{ fromJSON(inputs.remove_not_in_manifest) }}, ${{ fromJSON(inputs.skip_download_third_parties) }})
- 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:
script: |
const {createPRToDefault} = await import("${{ github.workspace }}/dist/ghw_create_pr_to_default.js")

await createPRToDefault(github, core, context, "${{steps.create_branch.outputs.branch_name}}", "Re-Processed all images")
68 changes: 68 additions & 0 deletions .github/workflows/run_autodl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Run auto download
on:
# schedule:
# # * is a special character in YAML, always quote this string
# - cron: '0 1 * * 1'
workflow_dispatch:
inputs:
prev:
description: 'Get previous firmware versions (if available) instead of latest.'
required: false
default: false
type: boolean
manufacturers:
description: 'Only trigger updates for given manufacturers (CSV, no space).'
required: false
default: ''
type: string
ignore_cache:
description: 'Ignore cached data in .cache for this run.'
required: false
default: false
type: boolean

permissions:
contents: write

jobs:
run-autodl:
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:
NODE_EXTRA_CA_CERTS: cacerts.pem
PREV: ${{ fromJSON(inputs.prev) && '1' || '' }}
IGNORE_CACHE: ${{ fromJSON(inputs.ignore_cache) && '1' || '' }}
with:
script: |
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]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Autodl update" || echo 'Nothing to commit'
git push
33 changes: 20 additions & 13 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
name: "Close stale issues/pull requests"
name: 'Close stale issues/pull requests'
on:
schedule:
- cron: "0 0 * * *"
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

permissions:
# contents: write # only for delete-branch option
issues: write
pull-requests: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days'
stale-pr-message: 'This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days'
days-before-stale: 180
days-before-close: 30
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days'
stale-pr-message: 'This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days'
exempt-issue-labels: dont-stale
days-before-stale: 180
days-before-close: 30
53 changes: 53 additions & 0 deletions .github/workflows/update_ota_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Update OTA PR
on:
pull_request:
types: [opened, synchronize, reopened, edited, closed]
branches: [main]
paths: ['images/**']

permissions:
contents: write
pull-requests: write

jobs:
update-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') && (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
uses: actions/github-script@v7
with:
script: |
const {updateOtaPR} = await import("${{ github.workspace }}/dist/ghw_update_ota_pr.js")

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'
git add .
git commit -m "Update after PR with OTA images merged" || echo 'Nothing to commit'
git push
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules/
coverage/
dist/
temp/
tmp/
.jest-tmp/
tsconfig.tsbuildinfo

# used by tests
images/jest-tmp
images1/jest-tmp
not-in-manifest-images/jest-tmp
not-in-manifest-images1/jest-tmp

# MacOS indexing files
.DS_Store
Loading