Skip to content

Commit

Permalink
Merge branch 'main' into bundler-tool-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-sandhu committed May 21, 2024
2 parents 8317953 + c390fc2 commit 15c4d57
Show file tree
Hide file tree
Showing 36 changed files with 471 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/add-to-core-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v1.0.1
- uses: actions/add-to-project@9bfe908f2eaa7ba10340b31e314148fcfe6a2458 # v1.0.1
with:
project-url: https://github.com/orgs/dependabot/projects/5
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL (ruby)
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@a12c274149a487a5539a726cb05bc6d1b7e0b5f2 # v3.24.11
with:
languages: ${{ matrix.language }}
config: |
Expand All @@ -63,15 +63,15 @@ jobs:
if: matrix.language == 'ruby'

- name: Initialize CodeQL (others)
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@a12c274149a487a5539a726cb05bc6d1b7e0b5f2 # v3.24.11
with:
languages: ${{ matrix.language }}
if: matrix.language != 'ruby'

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@a12c274149a487a5539a726cb05bc6d1b7e0b5f2 # v3.24.11

# 鈩癸笍 Command-line programs to run using the OS shell.
# 馃摎 https://git.io/JvXDl
Expand All @@ -85,4 +85,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@a12c274149a487a5539a726cb05bc6d1b7e0b5f2 # v3.24.11
4 changes: 2 additions & 2 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Codespell
uses: codespell-project/actions-codespell@v2
uses: codespell-project/actions-codespell@94259cd8be02ad2903ba34a22d9c13de21a74461 # v2.0
4 changes: 2 additions & 2 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Perform Dependency Review
uses: actions/dependency-review-action@v4
uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2
7 changes: 4 additions & 3 deletions .github/workflows/gems-bump-version.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Gems - Bump Version
on: # yamllint disable-line rule:truthy
on: # yamllint disable-line rule:truthy
schedule:
- cron: '25 1 * * THU'
workflow_dispatch:
Expand All @@ -24,13 +24,14 @@ jobs:
app-id: ${{ secrets.DEPENDABOT_CORE_ACTION_AUTOMATION_APP_ID }}
private-key: ${{ secrets.DEPENDABOT_CORE_ACTION_AUTOMATION_PRIVATE_KEY }}

- uses: actions/checkout@v4
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
token: ${{ steps.generate_token.outputs.token }}
# Ensure we start from main in case the workflow is run from a branch
ref: "main"

- uses: ruby/setup-ruby@v1 # bump-version.rb needs bundler
# bump-version.rb needs bundler

Check warning on line 33 in .github/workflows/gems-bump-version.yml

View workflow job for this annotation

GitHub Actions / Lint

33:9 [comments-indentation] comment not indented like content
- uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0
with:
# Use the version of bundler specified in `updater/Gemfile.lock`.
# Otherwise the generated PR will change `BUNDLED WITH` in
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/gems-release-to-rubygems.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Gems - Release to RubyGems
on: # yamllint disable-line rule:truthy
on: # yamllint disable-line rule:truthy
release:
# It's fine to trigger on every release because if we tag a release w/o
# bumping the Gem version, RubyGems will reject it with an error that the
Expand All @@ -15,8 +15,8 @@ jobs:
contents: read

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0
- run: |
[ -d ~/.gem ] || mkdir ~/.gem
echo "---" > ~/.gem/credentials
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/images-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
decision: ${{ steps.decision.outputs.decision }}
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
DEPENDABOT_UPDATER_VERSION: ${{ github.sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/images-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
ECOSYSTEM: ${{ matrix.suite.ecosystem }}
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/images-updater-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.4
- uses: github/issue-labeler@c1b0f9f52a63158c4adc09425e858e87b32e9685 # v3.4
with:
configuration-path: .github/issue-labeler.yml
enable-versioned-regex: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/labeler@v5
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
10 changes: 5 additions & 5 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
outputs:
suites: ${{ steps.suites.outputs.suites }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
if: github.event_name != 'workflow_dispatch'
id: changes
with:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
matrix:
suite: ${{ fromJSON(needs.discover.outputs.suites) }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

Expand All @@ -76,7 +76,7 @@ jobs:
- name: Restore Smoke Test
id: cache-smoke-test
uses: actions/cache/restore@v4
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: smoke.yaml
key: ${{ matrix.suite.sha }}-${{ matrix.suite.name }}
Expand All @@ -89,7 +89,7 @@ jobs:
- name: Cache Smoke Test
if: steps.cache-smoke-test.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: smoke.yaml
key: ${{ steps.cache-smoke-test.outputs.cache-primary-key }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/sorbet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
name: Sorbet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- uses: ruby/setup-ruby@v1
- uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0
with:
bundler-cache: true

Expand All @@ -34,7 +34,7 @@ jobs:
- run: bundle exec spoom coverage timeline --save

- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: spoom_data
path: ./spoom_data/
Expand All @@ -45,7 +45,7 @@ jobs:
GH_TOKEN: ${{ github.token }}

- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: spoom_report
path: ./spoom_report.html
2 changes: 1 addition & 1 deletion .github/workflows/stalebot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9.0.0
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
name: Clean up stale PRs and Issues
with:
stale-pr-message: "馃憢 This pull request has been marked as stale because it has been open for 2 years with no activity. You can comment on the PR to hold stalebot off for a while, or do nothing. If you do nothing, this pull request will be closed eventually by the stalebot. Please see CONTRIBUTING.md for more policy details."
Expand Down
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ RSpec/BeforeAfterAll:
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'cargo/**/*'
- 'common/**/*'
- 'composer/**/*'
- 'devcontainers/**/*'
Expand Down
34 changes: 24 additions & 10 deletions cargo/lib/dependabot/cargo/metadata_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,40 @@ def crates_listing

info = dependency.requirements.filter_map { |r| r[:source] }.first
index = (info && info[:index]) || CRATES_IO_API
hdrs = build_headers(index, info)

# Default request headers
url = metadata_fetch_url(dependency, index)
response = fetch_metadata(url, hdrs)

@crates_listing = parse_response(response, index)
end

def build_headers(index, info)
hdrs = { "User-Agent" => "Dependabot (dependabot.com)" }
return hdrs if index == CRATES_IO_API

if index != CRATES_IO_API
# Add authentication headers if credentials are present for this registry
credentials.find { |cred| cred["type"] == "cargo_registry" && cred["registry"] == info[:name] }&.tap do |cred|
hdrs["Authorization"] = "Token #{cred['token']}"
end
credentials.find { |cred| cred["type"] == "cargo_registry" && cred["registry"] == info[:name] }&.tap do |cred|
hdrs["Authorization"] = "Token #{cred['token']}"
end

url = metadata_fetch_url(dependency, index)
hdrs
end

response = Excon.get(
def fetch_metadata(url, headers)
Excon.get(
url,
idempotent: true,
**SharedHelpers.excon_defaults(headers: hdrs)
**SharedHelpers.excon_defaults(headers: headers)
)
end

@crates_listing = JSON.parse(response.body)
def parse_response(response, index)
if index.start_with?("sparse+")
parsed_response = response.body.lines.map { |line| JSON.parse(line) }
{ "versions" => parsed_response }
else
JSON.parse(response.body)
end
end

def metadata_fetch_url(dependency, index)
Expand Down

0 comments on commit 15c4d57

Please sign in to comment.