Skip to content

Commit

Permalink
Merge pull request #7448 from mook-as/go-dependabot
Browse files Browse the repository at this point in the history
Dependabot: Add missing /src/go directories
  • Loading branch information
jandubois committed Sep 10, 2024
2 parents d728e83 + bf5e15b commit 0f68745
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ updates:
labels: ["component/dependencies"]
reviewers: [ "mook-as" ]

- package-ecosystem: "gomod"
directory: "/src/go/guestagent"
schedule:
interval: "daily"
open-pull-requests-limit: 1
labels: ["component/dependencies"]
reviewers: [ "Nino-K" ]

- package-ecosystem: "gomod"
directory: "/src/go/mock-wsl"
schedule:
Expand All @@ -98,6 +106,22 @@ updates:
labels: ["component/dependencies"]
reviewers: [ "Nino-K" ]

- package-ecosystem: "gomod"
directory: "/src/go/nerdctl-stub/generate"
schedule:
interval: "daily"
open-pull-requests-limit: 1
labels: ["component/dependencies"]
reviewers: [ "Nino-K" ]

- package-ecosystem: "gomod"
directory: "/src/go/networking"
schedule:
interval: "daily"
open-pull-requests-limit: 1
labels: ["component/dependencies"]
reviewers: [ "Nino-K" ]

- package-ecosystem: "gomod"
directory: "/src/go/rdctl"
schedule:
Expand Down
35 changes: 34 additions & 1 deletion scripts/lint-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
*
* If any argument is `--fix`, then changes are automatically applied.
*/
import fs from 'fs';
import path from 'path';

import yaml from 'yaml';

import { readDependencyVersions } from './lib/dependencies';

import { spawnFile } from '@pkg/utils/childProcess';
Expand Down Expand Up @@ -109,7 +112,37 @@ async function goLangCILint(fix: boolean): Promise<boolean> {
return success;
}

Promise.all([format(fix), syncModules(fix), goLangCILint(fix)]).then((successes) => {
type dependabotConfig = {
version: 2,
updates: {
'package-ecosystem': string;
directory: string;
schedule: { interval: 'daily' };
'open-pull-requests-limit': number;
labels: string[];
ignore?: {'dependency-name': string; 'update-types'?: string[]; version?: string[] }[];
reviewers?: string[];
}[];
};

async function checkDependabot(fix: boolean): Promise<boolean> {
const configs: dependabotConfig = yaml.parse(await fs.promises.readFile('.github/dependabot.yml', 'utf8'));
const modules = (await getModules()).map(module => `/${ module }`);
const dependabotDirs = configs.updates.filter(x => x['package-ecosystem'] === 'gomod').map(x => x.directory);
const missing = modules.filter(x => !dependabotDirs.includes(x));

if (missing.length > 0) {
const message = ['\x1B[0;1;31m Go modules not listed in dependabot:\x1B[0m'].concat(missing);

console.error(message.join('\n '));

return false;
}

return true;
}

Promise.all([format, syncModules, goLangCILint, checkDependabot].map(fn => fn(fix))).then((successes) => {
if (!successes.every(x => x)) {
process.exit(1);
}
Expand Down

0 comments on commit 0f68745

Please sign in to comment.