generated from nhcarrigan/template
d9f959d115
## Summary Minori now automatically merges dependency update PRs when they meet safety criteria, reducing manual work whilst maintaining safety for potentially breaking changes. ## Changes - ✨ Add version comparison utility to detect major version bumps - ✨ Add Gitea service methods for checking commit status and merging PRs - ✨ Add auto-merge logic that checks: - Is it a major version bump? (if yes, skip auto-merge) - Did CI checks pass? (if no, skip auto-merge) - If both conditions pass → auto-merge! 🎉 - ✅ Add comprehensive tests for all new functionality - 📊 Maintain ~94% test coverage ## How It Works When Minori processes a dependency update: 1. Check if a PR already exists for that dependency 2. If it exists, verify: - **Not a major version bump** (major bumps need manual review) - **CI status = "success"** (all checks must pass) 3. If both conditions are met → automatically merge the PR and delete the branch ## Test Plan - [x] All 114 tests passing - [x] New tests for version comparison utility - [x] New tests for Gitea service extensions - [x] Build successful - [x] Linting clean --- ✨ This PR was created with help from Hikari~ 🌸 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Reviewed-on: #5 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
109 lines
3.4 KiB
TypeScript
109 lines
3.4 KiB
TypeScript
/**
|
|
* @copyright NHCarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
|
|
/* eslint-disable vitest/valid-expect -- Test expectations don't need messages */
|
|
/* eslint-disable max-lines-per-function -- Test suites naturally have many cases */
|
|
/* eslint-disable max-nested-callbacks -- Vitest structure requires nesting */
|
|
/* eslint-disable vitest/prefer-to-be-truthy -- toBe(true) is clearer for boolean functions */
|
|
/* eslint-disable vitest/prefer-to-be-falsy -- toBe(false) is clearer for boolean functions */
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
isMajorVersionBump,
|
|
stripVersionPrefix,
|
|
} from "../../src/utils/versionComparison.js";
|
|
|
|
describe("versionComparison", () => {
|
|
describe("stripVersionPrefix", () => {
|
|
it("should strip caret prefix", () => {
|
|
expect.assertions(1);
|
|
expect(stripVersionPrefix("^1.2.3")).toBe("1.2.3");
|
|
});
|
|
|
|
it("should strip tilde prefix", () => {
|
|
expect.assertions(1);
|
|
expect(stripVersionPrefix("~1.2.3")).toBe("1.2.3");
|
|
});
|
|
|
|
it("should strip greater than prefix", () => {
|
|
expect.assertions(1);
|
|
expect(stripVersionPrefix(">1.2.3")).toBe("1.2.3");
|
|
});
|
|
|
|
it("should strip less than prefix", () => {
|
|
expect.assertions(1);
|
|
expect(stripVersionPrefix("<1.2.3")).toBe("1.2.3");
|
|
});
|
|
|
|
it("should strip equals prefix", () => {
|
|
expect.assertions(1);
|
|
expect(stripVersionPrefix("=1.2.3")).toBe("1.2.3");
|
|
});
|
|
|
|
it("should strip multiple prefix characters", () => {
|
|
expect.assertions(1);
|
|
expect(stripVersionPrefix(">=1.2.3")).toBe("1.2.3");
|
|
});
|
|
|
|
it("should return version without prefix unchanged", () => {
|
|
expect.assertions(1);
|
|
expect(stripVersionPrefix("1.2.3")).toBe("1.2.3");
|
|
});
|
|
});
|
|
|
|
describe("isMajorVersionBump", () => {
|
|
it("should detect major version bump", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("1.2.3", "2.0.0")).toBe(true);
|
|
});
|
|
|
|
it("should detect major version bump with prefixes", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("^1.2.3", "^2.0.0")).toBe(true);
|
|
});
|
|
|
|
it("should not detect minor version bump as major", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("1.2.3", "1.3.0")).toBe(false);
|
|
});
|
|
|
|
it("should not detect patch version bump as major", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("1.2.3", "1.2.4")).toBe(false);
|
|
});
|
|
|
|
it("should handle version with pre-release tags", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("1.2.3", "2.0.0-beta.1")).toBe(true);
|
|
});
|
|
|
|
it("should return false for invalid from version", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("invalid", "2.0.0")).toBe(false);
|
|
});
|
|
|
|
it("should return false for invalid to version", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("1.2.3", "invalid")).toBe(false);
|
|
});
|
|
|
|
it("should return false for both invalid versions", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("invalid", "also-invalid")).toBe(false);
|
|
});
|
|
|
|
it("should handle 0.x.x to 1.x.x as major bump", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("0.9.5", "1.0.0")).toBe(true);
|
|
});
|
|
|
|
it("should not detect same version as major bump", () => {
|
|
expect.assertions(1);
|
|
expect(isMajorVersionBump("1.2.3", "1.2.3")).toBe(false);
|
|
});
|
|
});
|
|
});
|