-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(github-actions): Support actions/setup-dotnet with:dotnet-version #37369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
martincostello
wants to merge
7
commits into
renovatebot:main
Choose a base branch
from
martincostello:update-dotnet-version-for-setup-dotnet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,492
−16
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6d7c063
feat(github-actions): Support actions/setup-dotnet with:dotnet-version
martincostello 20b0fc8
feat(github-actions): More test cases
martincostello 694cc13
fix(github-actions): Fix typo
martincostello 94d5cda
fix(nuget): Fix typo
martincostello 3b0c0d6
fix: remove radix
martincostello e02a7be
Merge branch 'main' into update-dotnet-version-for-setup-dotnet
martincostello fc988d1
Merge branch 'main' into update-dotnet-version-for-setup-dotnet
martincostello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,14 @@ import { GlobalConfig } from '../../../config/global'; | |
import { logger, withMeta } from '../../../logger'; | ||
import { detectPlatform } from '../../../util/common'; | ||
import { newlineRegex, regEx } from '../../../util/regex'; | ||
import { DotnetVersionDatasource } from '../../datasource/dotnet-version'; | ||
import { ForgejoTagsDatasource } from '../../datasource/forgejo-tags'; | ||
import { GiteaTagsDatasource } from '../../datasource/gitea-tags'; | ||
import { GithubReleasesDatasource } from '../../datasource/github-releases'; | ||
import { GithubRunnersDatasource } from '../../datasource/github-runners'; | ||
import { GithubTagsDatasource } from '../../datasource/github-tags'; | ||
import * as dockerVersioning from '../../versioning/docker'; | ||
import * as dotnetSdkVersioning from '../../versioning/dotnet-sdk'; | ||
import * as nodeVersioning from '../../versioning/node'; | ||
import * as npmVersioning from '../../versioning/npm'; | ||
import { getDep } from '../dockerfile/extract'; | ||
|
@@ -175,12 +177,22 @@ function extractRunner(runner: string): PackageDependency | null { | |
return dependency; | ||
} | ||
|
||
const versionedActions: Record<string, string> = { | ||
go: npmVersioning.id, | ||
node: nodeVersioning.id, | ||
python: npmVersioning.id, | ||
interface VersionedAction { | ||
versioning: string; | ||
datasource?: string; | ||
packageName?: string; | ||
} | ||
|
||
const versionedActions: Record<string, VersionedAction> = { | ||
dotnet: { | ||
versioning: dotnetSdkVersioning.id, | ||
datasource: DotnetVersionDatasource.id, | ||
packageName: 'dotnet-sdk', | ||
}, | ||
go: { versioning: npmVersioning.id }, | ||
node: { versioning: nodeVersioning.id }, | ||
python: { versioning: npmVersioning.id }, | ||
// Not covered yet because they use different datasources/packageNames: | ||
// - dotnet | ||
// - java | ||
}; | ||
|
||
|
@@ -195,20 +207,27 @@ function extractSteps( | |
continue; | ||
} | ||
|
||
for (const [action, versioning] of Object.entries(versionedActions)) { | ||
for (const [ | ||
action, | ||
{ versioning, datasource, packageName }, | ||
] of Object.entries(versionedActions)) { | ||
const actionName = `actions/setup-${action}`; | ||
if (step.uses === actionName || step.uses?.startsWith(`${actionName}@`)) { | ||
const fieldName = `${action}-version`; | ||
const currentValue = step.with?.[fieldName]; | ||
if (currentValue) { | ||
deps.push({ | ||
datasource: GithubReleasesDatasource.id, | ||
depName: action, | ||
packageName: `actions/${action}-versions`, | ||
versioning, | ||
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$', // Actions release tags are like 1.24.1-13667719799 | ||
currentValue, | ||
depType: 'uses-with', | ||
currentValue.split(newlineRegex).forEach((value) => { | ||
if (value) { | ||
deps.push({ | ||
datasource: datasource ?? GithubReleasesDatasource.id, | ||
depName: action, | ||
packageName: packageName ?? `actions/${action}-versions`, | ||
versioning, | ||
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$', // Actions release tags are like 1.24.1-13667719799 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might not be correct, as it doesn't look like it would work for values with an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use for-of loop |
||
currentValue: value, | ||
depType: 'uses-with', | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The nested forEach loop with conditional push could be refactored using filter and map for better readability:
currentValue.split(newlineRegex).filter(Boolean).map(value => ({ ... })).forEach(dep => deps.push(dep))
Copilot uses AI. Check for mistakes.