Skip to content

Commit

Permalink
Merge pull request #7159 from mook-as/ci/rddepman/golangci-lint
Browse files Browse the repository at this point in the history
rddepman: Support golangci-lint
  • Loading branch information
mook-as authored Jul 9, 2024
2 parents 07a83c5 + fca30d9 commit 9b4a5ce
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/rancher-desktop/assets/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ helm: 3.15.2
dockerCLI: 27.0.3
dockerBuildx: 0.15.1
dockerCompose: 2.28.1
golangci-lint: 1.59.1
trivy: 0.53.0
steve: 0.1.0-beta9
rancherDashboard: desktop-v2.7.0.beta.1
Expand Down
24 changes: 24 additions & 0 deletions scripts/dependencies/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,30 @@ export class DockerCompose implements Dependency, GitHubDependency {
}
}

export class GoLangCILint implements Dependency, GitHubDependency {
name = 'golangci-lint';
githubOwner = 'golangci';
githubRepo = 'golangci-lint';

download(context: DownloadContext): Promise<void> {
// We don't actually download anything; when we invoke the linter, we just
// use `go run` with the appropriate package.
return Promise.resolve();
}

async getAvailableVersions(includePrerelease = false): Promise<string[]> {
return await getPublishedVersions(this.githubOwner, this.githubRepo, includePrerelease);
}

versionToTagName(version: string): string {
return `v${ version }`;
}

rcompareVersions(version1: string, version2: string): -1 | 0 | 1 {
return semver.rcompare(version1, version2);
}
}

export class Trivy implements Dependency, GitHubDependency {
name = 'trivy';
githubOwner = 'aquasecurity';
Expand Down
1 change: 1 addition & 0 deletions scripts/lib/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type DependencyVersions = {
dockerCLI: string;
dockerBuildx: string;
dockerCompose: string;
'golangci-lint': string;
trivy: string;
steve: string;
guestAgent: string;
Expand Down
7 changes: 5 additions & 2 deletions scripts/lint-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
import path from 'path';

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

import { spawnFile } from '@pkg/utils/childProcess';

const fix = process.argv.includes('--fix');
Expand Down Expand Up @@ -77,10 +79,11 @@ async function syncModules(fix: boolean): Promise<boolean> {
}

async function goLangCILint(fix: boolean): Promise<boolean> {
const version = '1.59.1';
const depVersionsPath = path.join('pkg', 'rancher-desktop', 'assets', 'dependencies.yaml');
const dependencyVersions = await readDependencyVersions(depVersionsPath);

const args = [
'run', `github.com/golangci/golangci-lint/cmd/golangci-lint@v${ version }`,
'run', `github.com/golangci/golangci-lint/cmd/golangci-lint@v${ dependencyVersions['golangci-lint'] }`,
'run', '--config=.github/workflows/config/.golangci.yaml',
'--timeout=10m', '--verbose',
];
Expand Down
10 changes: 10 additions & 0 deletions scripts/rddepman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const dependencies: Dependency[] = [
new tools.DockerBuildx(),
new tools.DockerCompose(),
new tools.DockerProvidedCredHelpers(),
new tools.GoLangCILint(),
new tools.Trivy(),
new tools.Steve(),
new tools.RancherDashboard(),
Expand Down Expand Up @@ -178,6 +179,15 @@ async function checkDependencies(): Promise<void> {

const updatesAvailable = await determineUpdatesAvailable();

if (!process.env.CI) {
// When not running in CI, don't try to make pull requests.
if (updatesAvailable.length) {
console.log(`Not running in CI, skipping creation of ${ updatesAvailable.length } pull requests.`);
}

return;
}

// reconcile dependencies that need an update with state of repo's PRs
const needToCreatePR: VersionComparison[] = [];

Expand Down

0 comments on commit 9b4a5ce

Please sign in to comment.