mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 16:09:05 +00:00
See working run here https://github.com/openobserve/openobserve/actions/runs/19761555623/job/56624451400 Also check the timeline items that mention gh actions bot added the label and milestone to it. This adds a CI which will automatically label every PR on approve and add it to the lowest open milestone (ignoring backlog) So if current open milestones are backlog, v0.20.0, v0.20.1 , it will auto add this on approval to v0.20.0 and add `Needs-Testing` label. --------- Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com> Co-authored-by: Yashodhan Joshi <yjdoc2@gmail.com>
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
const ORG = "openobserve";
|
|
const REPO = process.env.REPO || "openobserve";
|
|
|
|
const ver_regexp = new RegExp("[a-zA-Z]*([0-9]+\\.[0-9]+\\.[0-9]+)");
|
|
|
|
function get_lowest_milestone(ms1, ms2) {
|
|
// the first index will be the first captured group
|
|
let v1 = ver_regexp.exec(ms1.title)[1];
|
|
let v2 = ver_regexp.exec(ms2.title)[1];
|
|
|
|
let [v11, v12, v13] = v1.split(".").map((v) => parseInt(v));
|
|
let [v21, v22, v23] = v2.split(".").map((v) => parseInt(v));
|
|
|
|
// if the major version mismatch,
|
|
// return one with lowest major version
|
|
if (v11 != v21) {
|
|
return v11 < v21 ? ms1 : ms2;
|
|
}
|
|
|
|
// if major match, but minor do not, return one with lowest minor
|
|
if (v12 != v22) {
|
|
return v12 < v22 ? ms1 : ms2;
|
|
}
|
|
|
|
// if both major and minor match, return
|
|
// one with lowest patch number
|
|
if (v13 != v23) {
|
|
return v13 < v23 ? ms1 : ms2;
|
|
}
|
|
|
|
// default is first arg
|
|
return ms1;
|
|
}
|
|
|
|
async function main() {
|
|
const res = await fetch(
|
|
`https://api.github.com/repos/${ORG}/${REPO}/milestones`
|
|
);
|
|
const body = await res.json();
|
|
let milestones = [];
|
|
body.forEach((ms) => {
|
|
// always ignore backlog for auto labeling, and skip non-open milestones
|
|
if (ms.title == "Backlog" || ms.state !== "open") {
|
|
return;
|
|
}
|
|
|
|
milestones.push({
|
|
title: ms.title,
|
|
created_at: ms.created_at,
|
|
due_on: ms.due_on,
|
|
});
|
|
});
|
|
let lowest_milestone = milestones.reduce((prev, crr) =>
|
|
get_lowest_milestone(prev, crr)
|
|
);
|
|
console.log(lowest_milestone.title);
|
|
}
|
|
|
|
main().then(() => {});
|