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

This commit is contained in:
Nerivec
2024-10-28 21:38:11 +01:00
committed by GitHub
parent c1c4488759
commit ea2e6693f8
60 changed files with 10052 additions and 323 deletions

32
.github/workflows/ci.yml vendored Normal file
View File

@@ -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
.github/workflows/concat_cacerts.yml vendored Normal file
View File

@@ -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

View File

@@ -1,30 +0,0 @@
# This workflow executes several linters on changed files based on languages used in your code base whenever
# you push a code or open a pull request.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/github/super-linter
name: Lint Code Base
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
FILTER_REGEX_INCLUDE: .*.json
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

44
.github/workflows/overwrite_cache.yml vendored Normal file
View File

@@ -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

View File

@@ -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
.github/workflows/run_autodl.yml vendored Normal file
View File

@@ -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

View File

@@ -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
.github/workflows/update_ota_pr.yml vendored Normal file
View File

@@ -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