Skip to content
Open
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
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"private": true,
"description": "automate the submodule update process",
"type": "module",
"main": "index.js",
"scripts": {
"build": "tsc",
Expand Down Expand Up @@ -38,8 +39,8 @@
"vitest": "^4.1.1"
},
"dependencies": {
"@octokit/auth-app": "^6.0.2",
"@octokit/rest": "^20.0.2",
"@octokit/auth-app": "^8.0.0",
"@octokit/rest": "^22.0.0",
"debug": "^3.1.0",
"probot": "^14.2.4",
"semver": "^7.5.2",
Expand Down
2 changes: 1 addition & 1 deletion src/actions-runner-cron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rollActionsRunner } from './actions-runner-handler';
import { rollActionsRunner } from './actions-runner-handler.js';

if (require.main === module) {
rollActionsRunner().catch((err: Error) => {
Expand Down
10 changes: 5 additions & 5 deletions src/actions-runner-handler.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import debug from 'debug';

import { WINDOWS_DOCKER_FILE, ARC_RUNNER_ENVIRONMENTS } from './constants';
import { getOctokit } from './utils/octokit';
import { WINDOWS_DOCKER_FILE, ARC_RUNNER_ENVIRONMENTS } from './constants.js';
import { getOctokit } from './utils/octokit.js';

import { getLatestRunnerImages } from './utils/get-latest-runner-images';
import { getLatestRunnerImages } from './utils/get-latest-runner-images.js';
import {
getCurrentWindowsRunnerVersion,
getFileContent,
currentLinuxImages,
} from './utils/arc-image';
import { rollInfra } from './utils/roll-infra';
} from './utils/arc-image.js';
import { rollInfra } from './utils/roll-infra.js';

export async function rollActionsRunner() {
const d = debug(`roller/infra:rollActionsRunner()`);
Expand Down
2 changes: 1 addition & 1 deletion src/build-images-chromium-deps-cron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handleBuildImagesChromiumDepsCheck } from './build-images-chromium-deps-handler';
import { handleBuildImagesChromiumDepsCheck } from './build-images-chromium-deps-handler.js';

if (require.main === module) {
handleBuildImagesChromiumDepsCheck().catch((err) => {
Expand Down
8 changes: 4 additions & 4 deletions src/build-images-chromium-deps-handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import debug from 'debug';

import { REPOS, BUILD_IMAGES_INSTALL_DEPS_FILE, CHROMIUM_DEPS_FILES } from './constants';
import { getOctokit } from './utils/octokit';
import { getChromiumHeadSha, didChromiumFilesChange } from './utils/chromium-gitiles';
import { rollBuildImages, getFileContentFromBuildImages } from './utils/roll-build-images';
import { REPOS, BUILD_IMAGES_INSTALL_DEPS_FILE, CHROMIUM_DEPS_FILES } from './constants.js';
import { getOctokit } from './utils/octokit.js';
import { getChromiumHeadSha, didChromiumFilesChange } from './utils/chromium-gitiles.js';
import { rollBuildImages, getFileContentFromBuildImages } from './utils/roll-build-images.js';

// Regex to extract CHROMIUM_SRC_SHA from install-deps.sh
const CHROMIUM_SHA_REGEX = /CHROMIUM_SRC_SHA="([a-f0-9]{40})"/;
Expand Down
4 changes: 2 additions & 2 deletions src/build-images-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import debug from 'debug';
import { Octokit } from '@octokit/rest';
import type { Context } from 'probot';

import { getOctokit } from './utils/octokit';
import { MAIN_BRANCH, REPOS } from './constants';
import { getOctokit } from './utils/octokit.js';
import { MAIN_BRANCH, REPOS } from './constants.js';

const files = [
'.github/workflows/clean-src-cache.yml',
Expand Down
2 changes: 1 addition & 1 deletion src/chromium-cron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handleChromiumCheck } from './chromium-handler';
import { handleChromiumCheck } from './chromium-handler.js';

if (require.main === module) {
handleChromiumCheck().catch((err) => {
Expand Down
14 changes: 7 additions & 7 deletions src/chromium-handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import debug from 'debug';

import { MAIN_BRANCH, REPOS, ROLL_TARGETS } from './constants';
import { compareChromiumVersions } from './utils/compare-chromium-versions';
import { getChromiumReleases, Release } from './utils/get-chromium-tags';
import { getSupportedBranches } from './utils/get-supported-branches';
import { getOctokit } from './utils/octokit';
import { roll } from './utils/roll';
import { ReposGetBranchResponseItem, ReposListBranchesResponseItem } from './types';
import { MAIN_BRANCH, REPOS, ROLL_TARGETS } from './constants.js';
import { compareChromiumVersions } from './utils/compare-chromium-versions.js';
import { getChromiumReleases, Release } from './utils/get-chromium-tags.js';
import { getSupportedBranches } from './utils/get-supported-branches.js';
import { getOctokit } from './utils/octokit.js';
import { roll } from './utils/roll.js';
import { ReposGetBranchResponseItem, ReposListBranchesResponseItem } from './types.js';
import { Octokit } from '@octokit/rest';

type BranchItem = ReposGetBranchResponseItem | ReposListBranchesResponseItem;
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import debug from 'debug';
import type { Probot } from 'probot';
import { handleNodeCheck } from './node-handler';
import { handleChromiumCheck } from './chromium-handler';
import { handleBuildImagesCheck } from './build-images-handler';
import { handleBuildImagesChromiumDepsCheck } from './build-images-chromium-deps-handler';
import { ROLL_TARGETS } from './constants';
import { handleNodeCheck } from './node-handler.js';
import { handleChromiumCheck } from './chromium-handler.js';
import { handleBuildImagesCheck } from './build-images-handler.js';
import { handleBuildImagesChromiumDepsCheck } from './build-images-chromium-deps-handler.js';
import { ROLL_TARGETS } from './constants.js';

const handler = (robot: Probot) => {
robot.on('pull_request.closed', async (context) => {
Expand Down Expand Up @@ -97,4 +97,4 @@ const handler = (robot: Probot) => {
});
};

module.exports = handler;
export default handler;
2 changes: 1 addition & 1 deletion src/node-cron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handleNodeCheck } from './node-handler';
import { handleNodeCheck } from './node-handler.js';

if (require.main === module) {
handleNodeCheck().catch((err) => {
Expand Down
12 changes: 6 additions & 6 deletions src/node-handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import debug from 'debug';
import * as semver from 'semver';

import { MAIN_BRANCH, REPOS, ROLL_TARGETS } from './constants';
import { getOctokit } from './utils/octokit';
import { roll } from './utils/roll';
import { ReposListBranchesResponseItem } from './types';
import { getSupportedBranches } from './utils/get-supported-branches';
import { getLatestLTSVersion } from './utils/get-nodejs-lts';
import { MAIN_BRANCH, REPOS, ROLL_TARGETS } from './constants.js';
import { getOctokit } from './utils/octokit.js';
import { roll } from './utils/roll.js';
import { ReposListBranchesResponseItem } from './types.js';
import { getSupportedBranches } from './utils/get-supported-branches.js';
import { getLatestLTSVersion } from './utils/get-nodejs-lts.js';

export async function handleNodeCheck(target?: string): Promise<void> {
const d = debug('roller/node:handleNodeCheck()');
Expand Down
4 changes: 2 additions & 2 deletions src/utils/arc-image.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Octokit } from '@octokit/rest';
import { MAIN_BRANCH, REPOS } from '../constants';
import { getOctokit } from './octokit';
import { MAIN_BRANCH, REPOS } from '../constants.js';
import { getOctokit } from './octokit.js';

const WINDOWS_RUNNER_REGEX = /ARG RUNNER_VERSION=([\d.]+)/;
const WINDOWS_IMAGE_REGEX =
Expand Down
2 changes: 1 addition & 1 deletion src/utils/label-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Octokit } from '@octokit/rest';
import { REPOS } from '../constants';
import { REPOS } from '../constants.js';

export const addLabels = async (
octokit: Octokit,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/pr-text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ROLL_TARGETS, RollTarget } from '../constants';
import { ROLL_TARGETS, RollTarget } from '../constants.js';

interface PRTextDetails {
previousVersion: string;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/roll-build-images.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import debug from 'debug';

import { MAIN_BRANCH, REPOS } from '../constants';
import { getOctokit } from './octokit';
import { PullsListResponseItem } from '../types';
import { MAIN_BRANCH, REPOS } from '../constants.js';
import { getOctokit } from './octokit.js';
import { PullsListResponseItem } from '../types.js';
import { Octokit } from '@octokit/rest';

export async function getFileContentFromBuildImages(
Expand Down
10 changes: 5 additions & 5 deletions src/utils/roll-infra.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import debug from 'debug';

import { MAIN_BRANCH, REPOS } from '../constants';
import { getOctokit } from './octokit';
import { PullsListResponseItem } from '../types';
import { MAIN_BRANCH, REPOS } from '../constants.js';
import { getOctokit } from './octokit.js';
import { PullsListResponseItem } from '../types.js';
import { Octokit } from '@octokit/rest';
import { getInfraPRText } from './pr-text';
import { getFileContent } from './arc-image';
import { getInfraPRText } from './pr-text.js';
import { getFileContent } from './arc-image.js';

export async function rollInfra(
rollKey: string,
Expand Down
12 changes: 6 additions & 6 deletions src/utils/roll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
REPOS,
ROLL_TARGETS,
RollTarget,
} from '../constants';
import { ReposListBranchesResponseItem, PullsListResponseItem } from '../types';
import { getOctokit } from './octokit';
import { getPRText } from './pr-text';
import { updateDepsFile } from './update-deps';
} from '../constants.js';
import { ReposListBranchesResponseItem, PullsListResponseItem } from '../types.js';
import { getOctokit } from './octokit.js';
import { getPRText } from './pr-text.js';
import { updateDepsFile } from './update-deps.js';
import { Octokit } from '@octokit/rest';
import { addLabels, removeLabel } from './label-utils';
import { addLabels, removeLabel } from './label-utils.js';

interface RollParams {
rollTarget: RollTarget;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/update-deps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REPOS } from '../constants';
import { getOctokit } from './octokit';
import { REPOS } from '../constants.js';
import { getOctokit } from './octokit.js';

export interface UpdateDepsParams {
depName: string;
Expand Down
2 changes: 1 addition & 1 deletion src/windows-image-cron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rollWindowsArcImage } from './windows-image-handler';
import { rollWindowsArcImage } from './windows-image-handler.js';

if (require.main === module) {
rollWindowsArcImage().catch((err: Error) => {
Expand Down
8 changes: 4 additions & 4 deletions src/windows-image-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
WINDOWS_DOCKER_IMAGE_NAME,
ARC_RUNNER_ENVIRONMENTS,
MAIN_BRANCH,
} from './constants';
import { getOctokit } from './utils/octokit';
import { currentWindowsImage, didFileChangeBetweenShas } from './utils/arc-image';
import { rollInfra } from './utils/roll-infra';
} from './constants.js';
import { getOctokit } from './utils/octokit.js';
import { currentWindowsImage, didFileChangeBetweenShas } from './utils/arc-image.js';
import { rollInfra } from './utils/roll-infra.js';

async function getLatestVersionOfImage() {
const octokit = await getOctokit();
Expand Down
20 changes: 10 additions & 10 deletions tests/actions-runner-handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import * as arcImage from '../src/utils/arc-image';
import * as getLatestRunnerImagesModule from '../src/utils/get-latest-runner-images';
import * as rollInfraModule from '../src/utils/roll-infra';
import * as constants from '../src/constants';
import { getOctokit } from '../src/utils/octokit';
import * as arcImage from '../src/utils/arc-image.js';
import * as getLatestRunnerImagesModule from '../src/utils/get-latest-runner-images.js';
import * as rollInfraModule from '../src/utils/roll-infra.js';
import * as constants from '../src/constants.js';
import { getOctokit } from '../src/utils/octokit.js';

import { rollActionsRunner } from '../src/actions-runner-handler';
import { rollActionsRunner } from '../src/actions-runner-handler.js';

vi.mock('debug', () => ({ default: vi.fn(() => vi.fn()) }));
vi.mock('../src/utils/get-latest-runner-images');
vi.mock('../src/utils/arc-image');
vi.mock('../src/utils/roll-infra');
vi.mock('../src/utils/octokit');
vi.mock('../src/utils/get-latest-runner-images.js');
vi.mock('../src/utils/arc-image.js');
vi.mock('../src/utils/roll-infra.js');
vi.mock('../src/utils/octokit.js');

const mockOctokit = {};

Expand Down
12 changes: 6 additions & 6 deletions tests/build-images.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import handler from '../src/index';
import handler from '../src/index.js';
import { beforeEach, afterEach, describe, it, vi, expect } from 'vitest';
import * as buildImagesHandler from '../src/build-images-handler';
import { getOctokit } from '../src/utils/octokit';
import * as buildImagesHandler from '../src/build-images-handler.js';
import { getOctokit } from '../src/utils/octokit.js';

import { Probot, ProbotOctokit } from 'probot';
import { MAIN_BRANCH } from '../src/constants';
import { MAIN_BRANCH } from '../src/constants.js';
import { randomBytes } from 'node:crypto';
const nock = require('nock');
import nock from 'nock';

const GH_API = 'https://api.github.com';
const INSTALLATION_ID = 123456;

const payloadJson = await import('./fixtures/publish_payload.json');
const branchName = `roller/build-images/${MAIN_BRANCH}`;

vi.mock('../src/utils/octokit');
vi.mock('../src/utils/octokit.js');

describe('build-images', () => {
let probot: Probot;
Expand Down
26 changes: 13 additions & 13 deletions tests/handlers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';

import { MAIN_BRANCH, REPOS, ROLL_TARGETS } from '../src/constants';
import { getSupportedBranches } from '../src/utils/get-supported-branches';
import { handleNodeCheck } from '../src/node-handler';
import { handleChromiumCheck } from '../src/chromium-handler';
import { getChromiumReleases } from '../src/utils/get-chromium-tags';
import { getOctokit } from '../src/utils/octokit';
import { roll } from '../src/utils/roll';
import { getLatestLTSVersion } from '../src/utils/get-nodejs-lts';

vi.mock('../src/utils/get-chromium-tags');
vi.mock('../src/utils/octokit');
vi.mock('../src/utils/roll');
vi.mock('../src/utils/get-nodejs-lts');
import { MAIN_BRANCH, REPOS, ROLL_TARGETS } from '../src/constants.js';
import { getSupportedBranches } from '../src/utils/get-supported-branches.js';
import { handleNodeCheck } from '../src/node-handler.js';
import { handleChromiumCheck } from '../src/chromium-handler.js';
import { getChromiumReleases } from '../src/utils/get-chromium-tags.js';
import { getOctokit } from '../src/utils/octokit.js';
import { roll } from '../src/utils/roll.js';
import { getLatestLTSVersion } from '../src/utils/get-nodejs-lts.js';

vi.mock('../src/utils/get-chromium-tags.js');
vi.mock('../src/utils/octokit.js');
vi.mock('../src/utils/roll.js');
vi.mock('../src/utils/get-nodejs-lts.js');

describe('handleChromiumCheck()', () => {
let mockOctokit: any;
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/arc-image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
currentWindowsImage,
currentLinuxImages,
getCurrentWindowsRunnerVersion,
} from '../../src/utils/arc-image';
} from '../../src/utils/arc-image.js';

const windowsImageContent =
'${registry_name}.azurecr.io/win-actions-runner:main-abcdef0@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef';
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/chromium-gitiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getChromiumHeadSha,
getChromiumFileContent,
didChromiumFilesChange,
} from '../../src/utils/chromium-gitiles';
} from '../../src/utils/chromium-gitiles.js';

const GITILES_BASE = 'https://chromium.googlesource.com';

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/get-latest-runner-images.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { getLatestRunnerImages } from '../../src/utils/get-latest-runner-images';
import { getLatestRunnerImages } from '../../src/utils/get-latest-runner-images.js';
import { Octokit } from '@octokit/rest';

global.fetch = vi.fn();
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/get-nodejs-lts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import path from 'node:path';
import nock from 'nock';
import { describe, expect, it } from 'vitest';

import { getLatestLTSVersion, NODE_SCHEDULE_URL } from '../../src/utils/get-nodejs-lts';
import { getLatestLTSVersion, NODE_SCHEDULE_URL } from '../../src/utils/get-nodejs-lts.js';

describe('getLatestLTSVersion', () => {
it('returns the latest Node.js LTS version', async () => {
const fixture = fs.readFileSync(
path.join(__dirname, '../fixtures/node-release-schedule.json'),
path.join(import.meta.dirname, '../fixtures/node-release-schedule.json'),
'utf8',
);
const url = new URL(NODE_SCHEDULE_URL);
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/pr-text.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, it, vi } from 'vitest';

import { getPRText } from '../../src/utils/pr-text';
import { ROLL_TARGETS, RollTarget } from '../../src/constants';
import { getPRText } from '../../src/utils/pr-text.js';
import { ROLL_TARGETS, RollTarget } from '../../src/constants.js';

vi.mock('../../src/utils/octokit');
vi.mock('../../src/utils/octokit.js');

describe('getPRText()', () => {
describe('Node.js target', () => {
Expand Down
Loading