Skip to content

Commit

Permalink
Merge branch 'main' into dev/brettfo/nuget-space-in-path
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulapopoola authored Feb 22, 2024
2 parents 1236a31 + 4a81d6a commit f630589
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 39 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/images-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ jobs:
contents: read
packages: write
env:
TAG: ${{ github.sha }}
DEPENDABOT_UPDATER_VERSION: ${{ github.sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Prepare tag
run: echo "TAG=${{ github.sha }}" >> $GITHUB_ENV
run: echo "DEPENDABOT_UPDATER_VERSION=${{ github.sha }}" >> $GITHUB_ENV
if: github.event_name == 'pull_request'

- name: Prepare tag (forks)
Expand All @@ -90,7 +90,7 @@ jobs:
git fetch origin main
git merge origin/main --ff-only || exit 1
git submodule update --init --recursive
echo "TAG=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "DEPENDABOT_UPDATER_VERSION=$(git rev-parse HEAD)" >> $GITHUB_ENV
if: github.event_name == 'workflow_dispatch'

- name: Log in to GHCR
Expand All @@ -102,12 +102,12 @@ jobs:

- name: Push branch image
run: |
docker tag "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}" "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}:$TAG"
docker push "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}:$TAG"
docker tag "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}" "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}:$DEPENDABOT_UPDATER_VERSION"
docker push "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}:$DEPENDABOT_UPDATER_VERSION"
- name: Set summary
run: |
echo "updater uploaded with tag \`$TAG\`" >> $GITHUB_STEP_SUMMARY
echo "updater uploaded with tag \`$DEPENDABOT_UPDATER_VERSION\`" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}:$TAG" >> $GITHUB_STEP_SUMMARY
echo "ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }}:$DEPENDABOT_UPDATER_VERSION" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
10 changes: 6 additions & 4 deletions Dockerfile.updater-core
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ RUN for ecosystem in git_submodules terraform github_actions hex elm docker nuge

WORKDIR $DEPENDABOT_HOME/dependabot-updater

# When bumping Bundler, need to also regenerate `updater/Gemfile.lock` via `bundle lock --update --bundler`
# Generally simplest to match the bundler version to the one that comes by default with whatever Ruby version we install.
# This way other projects that import this library don't have to futz around with installing new / unexpected bundler versions.
ARG BUNDLER_V2_VERSION=2.5.3
# When bumping Bundler, need to also:
# * Regenerate `updater/Gemfile.lock` via `BUNDLE_GEMFILE=updater/Gemfile bundle lock --update --bundler`
# * Regenerate `Gemfile.lock` via `bundle lock --update --bundler`.
ARG BUNDLER_V2_VERSION=2.5.5

RUN gem install bundler -v $BUNDLER_V2_VERSION --no-document && \
rm -rf /var/lib/gems/*/cache/* && \
Expand All @@ -128,6 +128,8 @@ RUN gem install bundler -v $BUNDLER_V2_VERSION --no-document && \
ENV PATH="$DEPENDABOT_HOME/bin:$PATH"
ENV DEPENDABOT_NATIVE_HELPERS_PATH="/opt"

ENV DEPENDABOT_UPDATER_VERSION=${DEPENDABOT_UPDATER_VERSION:-development}

USER root

CMD ["bin/run"]
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,4 @@ DEPENDENCIES
webrick (>= 1.7)

BUNDLED WITH
2.5.3
2.5.5
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<h1 align="center">

<picture>
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/7659/174594540-5e29e523-396a-465b-9a6e-6cab5b15a568.svg">
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/7659/174594559-0b3ddaa7-e75b-4f10-9dee-b51431a9fd4c.svg">
Expand Down
8 changes: 7 additions & 1 deletion docker/lib/dependabot/docker/utils/credentials_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
require "aws-sdk-ecr"
require "base64"

require "dependabot/credential"
require "dependabot/errors"

module Dependabot
module Docker
module Utils
class CredentialsFinder
extend T::Sig

AWS_ECR_URL = /dkr\.ecr\.(?<region>[^.]+)\.amazonaws\.com/
DEFAULT_DOCKER_HUB_REGISTRY = "registry.hub.docker.com"

def initialize(credentials)
@credentials = credentials
end

sig { params(registry_hostname: String).returns(T.nilable(Dependabot::Credential)) }
def credentials_for_registry(registry_hostname)
registry_details =
credentials
Expand All @@ -42,8 +46,10 @@ def using_dockerhub?(registry)

private

sig { returns(T::Array[Dependabot::Credential]) }
attr_reader :credentials

sig { params(registry_details: Dependabot::Credential).returns(Dependabot::Credential) }
def build_aws_credentials(registry_details)
# If credentials have been generated from AWS we can just return them
return registry_details if registry_details["username"] == "AWS"
Expand Down Expand Up @@ -75,7 +81,7 @@ def build_aws_credentials(registry_details)
ecr_client.get_authorization_token.authorization_data.first.authorization_token
username, password =
Base64.decode64(@authorization_tokens[registry_hostname]).split(":")
registry_details.merge("username" => username, "password" => password)
registry_details.merge(Dependabot::Credential.new({ "username" => username, "password" => password }))
rescue Aws::Errors::MissingCredentialsError,
Aws::ECR::Errors::UnrecognizedClientException,
Aws::ECR::Errors::InvalidSignatureException
Expand Down
16 changes: 8 additions & 8 deletions docker/spec/dependabot/docker/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
let(:ignored_versions) { [] }
let(:raise_on_ignored) { false }
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}]
})]
end

let(:dependency) do
Expand Down Expand Up @@ -1107,17 +1107,17 @@ def stub_tag_with_no_digest(tag)

context "with authentication credentials" do
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}, {
}), Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "registry-host.io:5000",
"username" => "grey",
"password" => "pa55word"
}]
})]
end

before do
Expand All @@ -1130,15 +1130,15 @@ def stub_tag_with_no_digest(tag)

context "that don't have a username or password" do
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}, {
}), Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "registry-host.io:5000"
}]
})]
end

it { is_expected.to eq("17.10") }
Expand Down
30 changes: 15 additions & 15 deletions docker/spec/dependabot/docker/utils/credentials_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
RSpec.describe Dependabot::Docker::Utils::CredentialsFinder do
subject(:finder) { described_class.new(credentials) }
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com",
"username" => "grey",
"password" => "pa55word"
}]
})]
end

describe "#credentials_for_registry" do
Expand All @@ -30,12 +30,12 @@
context "with a non-AWS registry" do
let(:registry) { "my.registry.com" }
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "my.registry.com",
"username" => "grey",
"password" => "pa55word"
}]
})]
end

it { is_expected.to eq(credentials.first) }
Expand All @@ -46,23 +46,23 @@

context "with 'AWS' as the username" do
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com",
"username" => "AWS",
"password" => "pa55word"
}]
})]
end

it { is_expected.to eq(credentials.first) }
end

context "without a username or password" do
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com"
}]
})]
end

context "and a valid AWS response (via proxying)" do
Expand All @@ -75,7 +75,7 @@
end

it "returns details without credentials" do
expect(found_credentials).to eq(
expect(found_credentials.to_h).to eq(
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com"
)
Expand All @@ -85,12 +85,12 @@

context "with as AKID as the username" do
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com",
"username" => "AKIAIHYCC4QXL4X2OTCQ",
"password" => "pa55word"
}]
})]
end

context "and an invalid secret key as the password" do
Expand Down Expand Up @@ -145,7 +145,7 @@
end

it "returns an updated set of credentials" do
expect(found_credentials).to eq(
expect(found_credentials.to_h).to eq(
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com",
"username" => "AWS",
Expand All @@ -157,10 +157,10 @@

context "using the default credentials provider" do
let(:credentials) do
[{
[Dependabot::Credential.new({
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com"
}]
})]
end

context "and a valid AWS response" do
Expand All @@ -175,7 +175,7 @@
end

it "returns updated, valid credentials" do
expect(found_credentials).to eq(
expect(found_credentials.to_h).to eq(
"type" => "docker_registry",
"registry" => "695729449481.dkr.ecr.eu-west-2.amazonaws.com",
"username" => "foo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
""");
}

[Fact]
public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceInclude_Windows()
{
// update Newtonsoft.Json from 9.0.1 to 13.0.1
await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
// initial
projectContents: $"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>
""",
// expected
expectedProjectContents: $"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
""");
}

[Theory]
[InlineData("$(NewtonsoftJsonVersion")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,17 @@ private static async Task<string> CreateTempProjectAsync(
await File.WriteAllTextAsync(tempProjectPath, projectContents);

// prevent directory crawling
await File.WriteAllTextAsync(Path.Combine(tempDir.FullName, "Directory.Build.props"), "<Project />");
await File.WriteAllTextAsync(
Path.Combine(tempDir.FullName, "Directory.Build.props"),
"""
<Project>
<PropertyGroup>
<!-- For Windows-specific apps -->
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>
</Project>
""");

await File.WriteAllTextAsync(Path.Combine(tempDir.FullName, "Directory.Build.targets"), "<Project />");
await File.WriteAllTextAsync(Path.Combine(tempDir.FullName, "Directory.Packages.props"), "<Project />");

Expand Down
1 change: 1 addition & 0 deletions script/_common
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function docker_build() {
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg USER_UID=$DEPENDABOT_USER_UID \
--build-arg USER_GID=$DEPENDABOT_USER_GID \
--build-arg DEPENDABOT_UPDATER_VERSION=$DEPENDABOT_UPDATER_VERSION \
--cache-from "$UPDATER_CORE_IMAGE" \
-t "$UPDATER_CORE_IMAGE" \
-f Dockerfile.updater-core \
Expand Down
3 changes: 3 additions & 0 deletions sorbet/rbi/shims/sentry-ruby.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module Sentry
end

class Configuration
sig { returns(T.nilable(String)) }
attr_accessor :release

sig { returns(T.nilable(::Logger)) }
attr_accessor :logger

Expand Down
2 changes: 1 addition & 1 deletion updater/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,4 @@ DEPENDENCIES
webrick (>= 1.7)

BUNDLED WITH
2.5.3
2.5.5
1 change: 1 addition & 0 deletions updater/lib/dependabot/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
end

Sentry.init do |config|
config.release = ENV.fetch("DEPENDABOT_UPDATER_VERSION")
config.logger = Dependabot.logger
config.project_root = File.expand_path("../../..", __dir__)

Expand Down

0 comments on commit f630589

Please sign in to comment.