Skip to content

Commit daa3f8e

Browse files
committed
Merge branch 'upstreamain'
2 parents 416e095 + 4a740a5 commit daa3f8e

File tree

8 files changed

+391
-6
lines changed

8 files changed

+391
-6
lines changed

.github/dependabot.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Dependabot configuration file
2+
# See: https://docs.github.com/github/administering-a-repository/
3+
# configuration-options-for-dependency-updates
4+
5+
version: 2
6+
updates:
7+
# Maintain dependencies for the root project
8+
- package-ecosystem: "composer"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
open-pull-requests-limit: 10
13+
labels:
14+
- "dependencies"
15+
versioning-strategy: "auto"
16+
allow:
17+
- dependency-type: "direct"
18+
- dependency-type: "indirect"
19+
groups:
20+
dev-dependencies:
21+
patterns:
22+
- "friendsofphp/php-cs-fixer"
23+
- "phan/phan"
24+
- "phpstan/phpstan*"
25+
- "phpunit/phpunit"
26+
- "vimeo/psalm"
27+
- "psalm/plugin-phpunit"
28+
exclude-patterns:
29+
- "open-telemetry/*"
30+
open-telemetry:
31+
patterns:
32+
- "open-telemetry/*"
33+
symfony:
34+
patterns:
35+
- "symfony/*"
36+
ignore:
37+
- dependency-name: "*"
38+
update-types: ["version-update:semver-major"]
39+
commit-message:
40+
prefix: "chore"
41+
prefix-development: "chore"
42+
include: "scope"
43+
44+
# Maintain dependencies for GitHub Actions
45+
- package-ecosystem: "github-actions"
46+
directory: "/"
47+
schedule:
48+
interval: "weekly"
49+
open-pull-requests-limit: 10
50+
labels:
51+
- "dependencies"
52+
commit-message:
53+
prefix: "chore"
54+
prefix-development: "chore"
55+
include: "scope"
56+
57+
# Maintain dependencies for all packages
58+
- package-ecosystem: "composer"
59+
directories:
60+
- "/examples/aws/AwsClientApp"
61+
- "/examples/instrumentation/Wordpress"
62+
- "/src/AutoInstrumentationInstaller"
63+
- "/src/Aws"
64+
- "/src/Context/Swoole"
65+
- "/src/Instrumentation/CakePHP"
66+
- "/src/Instrumentation/CodeIgniter"
67+
- "/src/Instrumentation/Curl"
68+
- "/src/Instrumentation/Doctrine"
69+
- "/src/Instrumentation/ExtAmqp"
70+
- "/src/Instrumentation/ExtRdKafka"
71+
- "/src/Instrumentation/Guzzle"
72+
- "/src/Instrumentation/HttpAsyncClient"
73+
- "/src/Instrumentation/IO"
74+
- "/src/Instrumentation/Laravel"
75+
- "/src/Instrumentation/MongoDB"
76+
- "/src/Instrumentation/MySqli"
77+
- "/src/Instrumentation/OpenAIPHP"
78+
- "/src/Instrumentation/PDO"
79+
- "/src/Instrumentation/Psr14"
80+
- "/src/Instrumentation/Psr15"
81+
- "/src/Instrumentation/Psr16"
82+
- "/src/Instrumentation/Psr18"
83+
- "/src/Instrumentation/Psr3"
84+
- "/src/Instrumentation/Psr6"
85+
- "/src/Instrumentation/Slim"
86+
- "/src/Instrumentation/Symfony"
87+
- "/src/Instrumentation/Wordpress"
88+
- "/src/Instrumentation/Yii"
89+
- "/src/Logs/Monolog"
90+
- "/src/MetaPackages/opentelemetry"
91+
- "/src/Propagation/ServerTiming"
92+
- "/src/Propagation/TraceResponse"
93+
- "/src/ResourceDetectors/Azure"
94+
- "/src/ResourceDetectors/Container"
95+
- "/src/Sampler/RuleBased"
96+
- "/src/Shims/OpenTracing"
97+
- "/src/Symfony"
98+
- "/src/Symfony/src/OtelBundle"
99+
- "/src/Symfony/src/OtelSdkBundle"
100+
- "/src/Utils/Test"
101+
schedule:
102+
interval: "weekly"
103+
labels:
104+
- "dependencies"
105+
groups:
106+
dev-dependencies:
107+
patterns:
108+
- "friendsofphp/php-cs-fixer"
109+
- "phan/phan"
110+
- "phpstan/phpstan*"
111+
- "phpunit/phpunit"
112+
- "vimeo/psalm"
113+
- "psalm/plugin-phpunit"
114+
laravel:
115+
patterns:
116+
- "laravel/*"
117+
- "illuminate/*"
118+
open-telemetry:
119+
patterns:
120+
- "open-telemetry/*"
121+
symfony:
122+
patterns:
123+
- "symfony/*"
124+
ignore:
125+
- dependency-name: "*"
126+
update-types: ["version-update:semver-major"]
127+
commit-message:
128+
prefix: "chore"
129+
prefix-development: "chore"
130+
include: "scope"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Dependabot auto-approve
2+
on: pull_request
3+
4+
permissions:
5+
pull-requests: write
6+
7+
jobs:
8+
dependabot:
9+
runs-on: ubuntu-latest
10+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'open-telemetry/opentelemetry-php-contrib'
11+
steps:
12+
- name: Dependabot metadata
13+
id: metadata
14+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
15+
with:
16+
github-token: "${{ secrets.GITHUB_TOKEN }}"
17+
- name: Approve a PR
18+
run: gh pr review --approve "$PR_URL"
19+
env:
20+
PR_URL: ${{github.event.pull_request.html_url}}
21+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
run: vendor/bin/phpunit --testsuite integration,unit --coverage-text --coverage-clover=coverage.clover
155155

156156
- name: Code Coverage
157-
uses: codecov/codecov-action@v4
157+
uses: codecov/codecov-action@v5
158158
# only generate coverage against the latest PHP version
159159
if: ${{ matrix.php-version == '8.4' }}
160160
with:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Update Dependabot Configuration
2+
3+
on:
4+
schedule:
5+
# Run daily at midnight UTC
6+
- cron: '0 0 * * *'
7+
# Allow manual triggering
8+
workflow_dispatch:
9+
10+
jobs:
11+
update-dependabot-config:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.2'
24+
extensions: json
25+
coverage: none
26+
27+
- name: Generate dependabot configuration
28+
run: php scripts/generate-dependabot-config.php
29+
30+
- name: Check for changes
31+
id: git-check
32+
run: |
33+
git diff --exit-code .github/dependabot.yml || echo "changes=true" >> $GITHUB_OUTPUT
34+
35+
- name: Commit and push if changed
36+
if: steps.git-check.outputs.changes == 'true'
37+
run: |
38+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
39+
git config --local user.name "github-actions[bot]"
40+
git add .github/dependabot.yml
41+
git commit -m "chore: update dependabot configuration [skip ci]"
42+
git push
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/**
5+
* Script to automatically generate dependabot.yml configuration based on directory structure.
6+
*
7+
* This script scans the project for composer.json files and generates a dependabot.yml
8+
* configuration file with appropriate settings for each package.
9+
*
10+
* Usage: php scripts/generate-dependabot-config.php
11+
*/
12+
13+
// Configuration
14+
$rootDir = dirname(__DIR__);
15+
$outputFile = $rootDir . '/.github/dependabot.yml';
16+
$scanDirs = [
17+
$rootDir,
18+
$rootDir . '/src',
19+
$rootDir . '/examples',
20+
];
21+
22+
// Initialize YAML content
23+
$yaml = [
24+
'# Dependabot configuration file',
25+
'# See: https://docs.github.com/github/administering-a-repository/',
26+
'# configuration-options-for-dependency-updates',
27+
'',
28+
'version: 2',
29+
'updates:',
30+
];
31+
32+
// Add root project configuration
33+
$yaml[] = ' # Maintain dependencies for the root project';
34+
$yaml[] = ' - package-ecosystem: "composer"';
35+
$yaml[] = ' directory: "/"';
36+
$yaml[] = ' schedule:';
37+
$yaml[] = ' interval: "weekly"';
38+
$yaml[] = ' open-pull-requests-limit: 10';
39+
$yaml[] = ' labels:';
40+
$yaml[] = ' - "dependencies"';
41+
$yaml[] = ' versioning-strategy: "auto"';
42+
$yaml[] = ' allow:';
43+
$yaml[] = ' - dependency-type: "direct"';
44+
$yaml[] = ' - dependency-type: "indirect"';
45+
$yaml[] = ' groups:';
46+
$yaml[] = ' dev-dependencies:';
47+
$yaml[] = ' patterns:';
48+
$yaml[] = ' - "friendsofphp/php-cs-fixer"';
49+
$yaml[] = ' - "phan/phan"';
50+
$yaml[] = ' - "phpstan/phpstan*"';
51+
$yaml[] = ' - "phpunit/phpunit"';
52+
$yaml[] = ' - "vimeo/psalm"';
53+
$yaml[] = ' - "psalm/plugin-phpunit"';
54+
$yaml[] = ' exclude-patterns:';
55+
$yaml[] = ' - "open-telemetry/*"';
56+
$yaml[] = ' open-telemetry:';
57+
$yaml[] = ' patterns:';
58+
$yaml[] = ' - "open-telemetry/*"';
59+
$yaml[] = ' symfony:';
60+
$yaml[] = ' patterns:';
61+
$yaml[] = ' - "symfony/*"';
62+
$yaml[] = ' ignore:';
63+
$yaml[] = ' - dependency-name: "*"';
64+
$yaml[] = ' update-types: ["version-update:semver-major"]';
65+
$yaml[] = ' commit-message:';
66+
$yaml[] = ' prefix: "chore"';
67+
$yaml[] = ' prefix-development: "chore"';
68+
$yaml[] = ' include: "scope"';
69+
$yaml[] = '';
70+
71+
// Add GitHub Actions configuration
72+
$yaml[] = ' # Maintain dependencies for GitHub Actions';
73+
$yaml[] = ' - package-ecosystem: "github-actions"';
74+
$yaml[] = ' directory: "/"';
75+
$yaml[] = ' schedule:';
76+
$yaml[] = ' interval: "weekly"';
77+
$yaml[] = ' open-pull-requests-limit: 10';
78+
$yaml[] = ' labels:';
79+
$yaml[] = ' - "dependencies"';
80+
$yaml[] = ' commit-message:';
81+
$yaml[] = ' prefix: "chore"';
82+
$yaml[] = ' prefix-development: "chore"';
83+
$yaml[] = ' include: "scope"';
84+
$yaml[] = '';
85+
86+
// Find all composer.json files
87+
$composerFiles = [];
88+
foreach ($scanDirs as $scanDir) {
89+
findComposerFiles($scanDir, $composerFiles, $rootDir);
90+
}
91+
92+
// Filter out the root composer.json as it's already configured
93+
$packageDirectories = [];
94+
foreach ($composerFiles as $composerFile) {
95+
if ($composerFile !== '/') {
96+
$packageDirectories[] = $composerFile;
97+
}
98+
}
99+
100+
// Add a single configuration for all package directories
101+
if (!empty($packageDirectories)) {
102+
$yaml[] = ' # Maintain dependencies for all packages';
103+
$yaml[] = ' - package-ecosystem: "composer"';
104+
$yaml[] = ' directories:';
105+
106+
// Sort directories for consistent output
107+
sort($packageDirectories);
108+
foreach ($packageDirectories as $directory) {
109+
$yaml[] = ' - "' . $directory . '"';
110+
}
111+
112+
$yaml[] = ' schedule:';
113+
$yaml[] = ' interval: "weekly"';
114+
$yaml[] = ' labels:';
115+
$yaml[] = ' - "dependencies"';
116+
$yaml[] = ' groups:';
117+
$yaml[] = ' dev-dependencies:';
118+
$yaml[] = ' patterns:';
119+
$yaml[] = ' - "friendsofphp/php-cs-fixer"';
120+
$yaml[] = ' - "phan/phan"';
121+
$yaml[] = ' - "phpstan/phpstan*"';
122+
$yaml[] = ' - "phpunit/phpunit"';
123+
$yaml[] = ' - "vimeo/psalm"';
124+
$yaml[] = ' - "psalm/plugin-phpunit"';
125+
$yaml[] = ' laravel:';
126+
$yaml[] = ' patterns:';
127+
$yaml[] = ' - "laravel/*"';
128+
$yaml[] = ' - "illuminate/*"';
129+
$yaml[] = ' open-telemetry:';
130+
$yaml[] = ' patterns:';
131+
$yaml[] = ' - "open-telemetry/*"';
132+
$yaml[] = ' symfony:';
133+
$yaml[] = ' patterns:';
134+
$yaml[] = ' - "symfony/*"';
135+
$yaml[] = ' ignore:';
136+
$yaml[] = ' - dependency-name: "*"';
137+
$yaml[] = ' update-types: ["version-update:semver-major"]';
138+
$yaml[] = ' commit-message:';
139+
$yaml[] = ' prefix: "chore"';
140+
$yaml[] = ' prefix-development: "chore"';
141+
$yaml[] = ' include: "scope"';
142+
$yaml[] = '';
143+
}
144+
145+
// Write the YAML file
146+
file_put_contents($outputFile, implode("\n", $yaml));
147+
148+
echo "Dependabot configuration generated at: $outputFile\n";
149+
echo "Found " . count($composerFiles) . " composer.json files.\n";
150+
151+
/**
152+
* Recursively find composer.json files in the given directory.
153+
*
154+
* @param string $dir The directory to scan
155+
* @param array $results Array to store results
156+
* @param string $rootDir The root directory of the project
157+
*/
158+
function findComposerFiles($dir, &$results, $rootDir) {
159+
$files = scandir($dir);
160+
161+
foreach ($files as $file) {
162+
if ($file === '.' || $file === '..' || $file === 'vendor') {
163+
continue;
164+
}
165+
166+
$path = $dir . '/' . $file;
167+
168+
if (is_dir($path)) {
169+
// Skip vendor directories
170+
if (strpos($path, '/vendor/') !== false) {
171+
continue;
172+
}
173+
174+
findComposerFiles($path, $results, $rootDir);
175+
} elseif ($file === 'composer.json') {
176+
// Get relative path from root
177+
$relativePath = str_replace($rootDir, '', dirname($path));
178+
$relativePath = $relativePath ?: '/';
179+
180+
// Add to results if not already present
181+
if (!in_array($relativePath, $results)) {
182+
$results[] = $relativePath;
183+
}
184+
}
185+
}
186+
}

0 commit comments

Comments
 (0)