-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add support for ignore conditions using .github/dependabot.yml file. #582
Conversation
@assi010 the ignore conditions are automatically picked up from the configuration file in the ruby script. See dependabot-azure-devops/updater/bin/update-script.rb Lines 468 to 497 in 8a11e42
and also dependabot-azure-devops/updater/bin/update-script.rb Lines 272 to 292 in 8a11e42
|
Thanks for explaining @mburumaxwell. I used the Azure Devops extension with the following dependabot.yml configuration: version: 2
updates:
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 3
ignore:
- dependency-name: "*"
update-types: [ "version-update:semver-major" ] However, it would still create pull requests for packages updating them from version 6.x.x to 7.x.x. After adding the I'll do another check just to be sure I didn't misconfigure anything on my end. |
I have made a new project in Azure Devops with a sample dotnet Api. .github/dependabot.yml: version: 2
updates:
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 3
ignore:
- dependency-name: "*"
update-types: [ "version-update:semver-major" ] pipeline.yaml: trigger: none # Disable CI trigger
schedules:
- cron: '0 2 * * *' # daily at 2am UTC
always: true # run even when there are no code changes
branches:
include:
- main
batch: true
displayName: Daily
pool:
vmImage: 'ubuntu-latest'
steps:
- task: dependabot@1 TestApi.csproj: <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
</ItemGroup>
</Project> Running the pipeline my expectation is that it will ignore the package upgrade to 7.0.0. In the pipeline logs I can see docker being run with the following environment variables: /usr/bin/docker run --rm -i
-e DEPENDABOT_PACKAGE_MANAGER=nuget
-e DEPENDABOT_OPEN_PULL_REQUESTS_LIMIT=5
-e DEPENDABOT_DIRECTORY=/
-e DEPENDABOT_FAIL_ON_EXCEPTION=true
-e AZURE_ORGANIZATION=***
-e AZURE_PROJECT=Test
-e AZURE_REPOSITORY=Test
-e AZURE_ACCESS_TOKEN=***
-e AZURE_MERGE_STRATEGY=squash
ghcr.io/tinglesoftware/dependabot-updater:0.16 As you can see the values from the dependabot.yml are being set as environment variables, but the ignore conditions are missing. To be clear I have a limited understanding of ruby so I might be missing something, but this is the only place where I saw the dependabot-azure-devops/updater/bin/update-script.rb Lines 239 to 245 in 8a11e42
The extension does set all the other environment variables that it parsed from the dependabot.yml configuration. For example the allow conditions: dependabot-azure-devops/extension/task/index.ts Lines 95 to 99 in 8a11e42
From what I could tell only the ignore conditions are not being set in the extension. Which is why I added them. |
@assi010 I've definitely had semver blocking working before, infact it was the only way I could figure out how to do it until I finally cracked how to do it with versions specifically. This was previously working for me:
I suspect that the The issue i opened on dependabot core is here: dependabot/dependabot-core#6873 |
@DaleMckeown I'll definitely try that, thanks for the suggestion! But isn't it weird that the extension sets all values it parses from Allow conditions and ignore conditions are both optional with a JSON value according to the docs in this repo.
Here the allow value is parsed from the config file by the extension. dependabot-azure-devops/extension/task/index.ts Lines 96 to 99 in 8a11e42
And here it is used to set as environment variable for the docker image. The ignore conditions are never set. However, when I set them as the environment variable everything worked as expected. In the documentation of dependabot it even gives Considering it works with the environment variable and that the example configuration is valid according to the docs, I am a little skeptical that this is really the issue. |
That said, I just pulled a configuration file from one of our projects that uses ignores, wildcards, and I know it works because I wrote it: # To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
time: "00:00"
open-pull-requests-limit: 10
ignore:
# Ignore patch updates for some packages
- dependency-name: "Microsoft.*"
update-types: ["version-update:semver-patch"]
- dependency-name: "System.*"
update-types: ["version-update:semver-patch"]
- dependency-name: "MongoDB.*"
update-types: ["version-update:semver-patch"]
- dependency-name: "Moq"
update-types: ["version-update:semver-patch"] But for clarity sake, I have created a repro from what you provided. The package does not get updated.
Did I miss anything? |
Thanks for the provided repro, it finally led me to the real issue at play here. I looked at your project and tried to reproduce it in my own Azure Devops project once again, however this time it worked perfectly. I thought I was losing my mind.. I compared my previous repro project and the current one. On my Windows machine the Turns out that on the UTF-8 BOM version the ignore conditions are not picked up properly, while it works fine on UTF-8. That is why I started looking into the environment variables, as it worked completely fine when using the environment variables together with UTF-8 BOM. Pipeline with Pipeline with After removing the BOM from my Sorry for insisting on my changes @mburumaxwell @DaleMckeown, turns out my "fix" was just a workaround for a whole other issue 😅. Thanks for the help. |
I doubt these are as related. Maybe if your pipeline has other things going on. |
That makes sense, but I am able to consistently reproduce the issue with your example using Azure hosted agents. I have created a public repro as well in case you're interested.
I imported your example and tested the following scenarios: |
This is a curious case. It could either be the BOM or the comments. |
Possibly related to dependabot/dependabot-core#6714 |
Currently the ignore value (docs) is not being read from the .github/dependabot.yml file.
I updated the extension so that this value will now be used to set the DEPENDABOT_IGNORE_CONDITIONS environment variable.