Skip to content
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
30 changes: 30 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# PR path -> label rules for actions/labeler (add-only).
# Adapted for the kernel tree (armbian/linux-rockchip); the rest of the
# labelling automation is copied verbatim from armbian/build.

"Needs review":
- changed-files:
- any-glob-to-any-file: '**'

"Device Tree":
- changed-files:
- any-glob-to-any-file: ['arch/*/boot/dts/**']

"defconfig":
- changed-files:
- any-glob-to-any-file: ['arch/*/configs/**']

"GitHub Actions":
- all:
- changed-files:
- any-glob-to-any-file: ['.github/workflows/**/*']

"GitHub":
- all:
- changed-files:
- any-glob-to-any-file: ['.github/**/*']
- all-globs-to-any-file: ['!.github/workflows/**/*']

"Documentation":
- changed-files:
- any-glob-to-any-file: '**/*.md'
117 changes: 117 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
- name: "02"
color: "76B4D9"
description: "Milestone: First quarter release"
- name: "05"
color: "AADB79"
description: "Milestone: Second quarter release"
- name: "08"
color: "4B649F"
description: "Milestone: Third quarter release"
- name: "11"
color: "D58125"
description: "Milestone: Fourth quarter release"
- name: "Backlog"
color: "d4c5f9"
description: "Stalled work that needs to be completed"
- name: "Breaking change"
color: "f4bd13"
description: "Can potentially break core functionality"
- name: "Bug"
color: "F92C01"
description: "Something isn't working as it should"
- name: "Bugfix"
color: "F92C01"
description: "Pull request is fixing a bug"
- name: "Dependencies"
color: "0366d6"
description: "Pull requests that update a dependency"
- name: "Discussion"
color: "EDFFE3"
description: "Being discussed - Voice your opinions :)"
- name: "Duplicate"
color: "f4bd13"
description: "Issue is already present"
- name: "Feature Request"
color: "1aac63"
description: "Feature suggestion"
- name: "Good first issue"
color: "ffb3ff"
description: "Feel free to contribute :) "
- name: "Not framework bug"
color: "CD456C"
description: "Bug in 3rd party component"
- name: "Python"
color: "2b67c6"
description: "Pull requests that update Python code "
- name: "User error"
color: "CD456C"
description: "A mistake that is made by the user"
- name: "size/small"
color: "ededed"
description: "PR with less then 50 lines"
- name: "size/medium"
color: "ededed"
description: "PR with more then 50 and less then 250 lines"
- name: "size/large"
color: "ededed"
description: "PR with 250 lines or more"
- name: "Task/To-Do"
color: "2f95f1"
description: "Project management: To-Do or task(s) someone is working on"
- name: "Desktop"
color: "bfd4f2"
description: "Graphical user interface"
- name: "Hardware"
color: "bfd4f2"
description: "Hardware related like kernel, U-Boot, ..."
- name: "Framework"
color: "bfd4f2"
description: "Framework components"
- name: "BSP"
color: "bfd4f2"
description: "Board Support Packages"
- name: "GitHub Actions"
color: "bfd4f2"
description: "GitHub Actions code"
- name: "GitHub"
color: "bfd4f2"
description: "GitHub-related changes like labels, templates, ..."
- name: "Patches"
color: "bfd4f2"
description: "Patches related to kernel, U-Boot, ..."
- name: "Documentation"
color: "bfd4f2"
description: "Documentation changes or additions"
- name: "Work in progress"
color: "29E414"
description: "Unfinished / work in progress"
- name: "Ready to merge"
color: "1d7136"
description: "Reviewed, tested and ready for merge"
- name: "Help needed"
color: "EA1BCE"
description: "We need your involvement"
- name: "Needs review"
color: "AEE054"
description: "Seeking for review"
- name: "Can be closed?"
color: "9b75fc"
description: "Ping developers on stalled issue / PR"
- name: "Build"
color: "5ee3d0"
description: "Executing build train (permission needed)"
- name: "Needs Documentation"
color: "4FD1EF"
description: "New feature needs documentation entry"
- name: "Documentation finished"
color: "0052CC"
description: "New feature was properly added to docs"
- name: "Improper usage"
color: "CD456C"
description: "Provided input is not in the expected data format or structure"
- name: "Device Tree"
color: "bfd4f2"
description: "Device tree (.dts/.dtsi) changes"
- name: "defconfig"
color: "bfd4f2"
description: "Kernel defconfig changes"
103 changes: 103 additions & 0 deletions .github/scripts/wip-label.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Shared logic for the "Work in progress" label automation.
//
// A pull request is "work in progress" when a reviewer has requested changes
// OR any review conversation is still unresolved. The label is recomputed from
// the PR's live state, so it is idempotent and the same regardless of what
// triggered the run.
//
// Used by:
// - maintenance-label-wip.yml (workflow_run worker: instant, one PR)
// - maintenance-label-wip-sweep.yml (cron backstop: all open PRs)
//
// These run from the default branch context (workflow_run / schedule), which
// has a read/write GITHUB_TOKEN even for fork PRs -- unlike a pull_request_review
// trigger, whose token is read-only on forks.

const LABEL = "Work in progress";

// Returns { wip, reviewDecision, unresolved } for a single PR.
async function evaluate(github, owner, repo, number) {
let reviewDecision = null;
let unresolved = 0;
let after = null;

do {
const query = `
query($owner:String!, $repo:String!, $number:Int!, $after:String) {
repository(owner:$owner, name:$repo) {
pullRequest(number:$number) {
reviewDecision
reviewThreads(first:100, after:$after) {
nodes { isResolved }
pageInfo { hasNextPage endCursor }
}
}
}
}`;
const data = await github.graphql(query, { owner, repo, number, after });
const pr = data.repository.pullRequest;
reviewDecision = pr.reviewDecision;
for (const t of pr.reviewThreads.nodes) {
if (!t.isResolved) unresolved++;
}
after = pr.reviewThreads.pageInfo.hasNextPage
? pr.reviewThreads.pageInfo.endCursor
: null;
} while (after);

return { wip: reviewDecision === "CHANGES_REQUESTED" || unresolved > 0, reviewDecision, unresolved };
}

// Add or remove the label on one PR to match its evaluated state.
async function syncOne({ github, core, owner, repo, number }) {
const { wip, reviewDecision, unresolved } = await evaluate(github, owner, repo, number);

const current = await github.rest.issues.listLabelsOnIssue({
owner, repo, issue_number: number, per_page: 100,
});
const has = current.data.some(l => l.name === LABEL);
const state = `reviewDecision=${reviewDecision} unresolved=${unresolved}`;

if (wip && !has) {
await github.rest.issues.addLabels({ owner, repo, issue_number: number, labels: [LABEL] });
core.info(`PR #${number}: added "${LABEL}" (${state})`);
} else if (!wip && has) {
await github.rest.issues.removeLabel({ owner, repo, issue_number: number, name: LABEL });
core.info(`PR #${number}: removed "${LABEL}" (${state})`);
} else {
core.info(`PR #${number}: no change, has=${has} (${state})`);
}
}

// Sweep every open PR (paginated). One PR failing does not abort the rest.
async function syncAllOpen({ github, core, owner, repo }) {
let after = null;
let count = 0;

do {
const query = `
query($owner:String!, $repo:String!, $after:String) {
repository(owner:$owner, name:$repo) {
pullRequests(states: OPEN, first: 50, after: $after) {
nodes { number }
pageInfo { hasNextPage endCursor }
}
}
}`;
const data = await github.graphql(query, { owner, repo, after });
const conn = data.repository.pullRequests;
for (const pr of conn.nodes) {
count++;
try {
await syncOne({ github, core, owner, repo, number: pr.number });
} catch (e) {
core.warning(`PR #${pr.number}: sync failed: ${e.message}`);
}
}
after = conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null;
} while (after);

core.info(`Swept ${count} open PR(s).`);
}

module.exports = { syncOne, syncAllOpen };
41 changes: 41 additions & 0 deletions .github/workflows/data-sync-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Data: Sync labels"
run-name: Sync Labels from YML on ${{ github.event_name }}

on:
workflow_dispatch:
push:
branches:
- "main"
paths:
- ".github/labels.yml"
pull_request:
paths:
- ".github/labels.yml"

permissions:
contents: read

jobs:
labeler:
permissions:
contents: read # for actions/labeler to determine modified files
pull-requests: write # for actions/labeler to add labels to PRs
issues: write # for actions/labeler to add labels to issues

if: ${{ github.repository_owner == 'Armbian' }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Run Labeler
uses: crazy-max/ghaction-github-labeler@548a7c3603594ec17c819e1239f281a3b801ab4d # v6.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
dry-run: ${{ github.event_name == 'pull_request' }}
exclude: |
Maintenance*
Loading
Loading