jdecool/scaleway-runtimepublic Fork
⑂ 37de7fd
Commits
⬇ Clone ▾
git clone https://git.rickub.com/jdecool/scaleway-runtime.git
git clone ssh://git@rickub.com/jdecool/scaleway-runtime.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

ci: measure the Function Runtimes weekly and propose catalogue updatesUnverified

Jérémy DECOOL committed 2026-11-22T12:55:19+01:00 Browse files
37de7fd parent: 4e340ed
added .github/workflows/function-runtimes.yml +82 -0
new file mode 100644
@@ -0,0 +1,82 @@
1+name: Function Runtime Catalogue
2+
3+# Scaleway updates its Function Runtimes without notice: measure them again every week, and propose the changes.
4+on:
5+ schedule:
6+ - cron: '0 5 * * 1'
7+ workflow_dispatch:
8+
9+permissions:
10+ contents: write
11+ pull-requests: write
12+
13+concurrency:
14+ # The probe's namespace and function names are fixed: two runs would deploy over each other.
15+ group: function-runtime-catalogue
16+
17+jobs:
18+ measure:
19+ name: Measure the Function Runtimes
20+ runs-on: ubuntu-latest
21+ env:
22+ # A key limited to Serverless Functions, in a project dedicated to the probe.
23+ SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
24+ SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
25+ SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
26+ steps:
27+ - uses: actions/checkout@v7
28+
29+ - uses: shivammathur/setup-php@v2
30+ with:
31+ php-version: '8.5'
32+ coverage: none
33+
34+ - uses: ramsey/composer-install@v4
35+
36+ - uses: hashicorp/setup-terraform@v3
37+ with:
38+ terraform_wrapper: false
39+
40+ - name: Measure each Function Runtime with the probe
41+ run: |
42+ terraform -chdir=probe/terraform init -input=false
43+ for runtime in php84 php85; do
44+ terraform -chdir=probe/terraform apply -auto-approve -input=false -var "runtime=$runtime"
45+ endpoint=$(terraform -chdir=probe/terraform output -raw endpoint)
46+ fixture="tests/Fixtures/FunctionRuntimes/$runtime.json"
47+ # A replaced function keeps answering with the previous Function Runtime for a while.
48+ timeout 300 bash -c "until curl -sSf '$endpoint/?mode=runtime' -o '$fixture' && grep -q '\"phpVersion\": \"${runtime:3:1}\.${runtime:4:1}\.' '$fixture'; do sleep 5; done"
49+ done
50+
51+ - name: Destroy the probe
52+ if: always()
53+ run: terraform -chdir=probe/terraform destroy -auto-approve -input=false
54+
55+ - name: Regenerate the catalogue
56+ id: catalogue
57+ run: |
58+ changes=$(php probe/catalogue.php)
59+ echo "$changes"
60+ { echo 'changes<<EOF'; echo "$changes"; echo 'EOF'; } >> "$GITHUB_OUTPUT"
61+
62+ # Nothing but new measurement dates leaves the catalogue as it is.
63+ - name: Open or update the pull request
64+ if: steps.catalogue.outputs.changes != ''
65+ uses: peter-evans/create-pull-request@v7
66+ with:
67+ # Pull requests opened with the default token do not trigger the CI that checks the catalogue.
68+ token: ${{ secrets.CATALOGUE_PR_TOKEN || github.token }}
69+ branch: catalogue-update
70+ add-paths: |
71+ resources/function-runtimes.php
72+ tests/Fixtures/FunctionRuntimes
73+ commit-message: 'feat: update the Function Runtime Catalogue to the latest measurement'
74+ title: Update the Function Runtime Catalogue
75+ body: |
76+ The weekly measurement of the Function Runtimes found changes on Scaleway:
77+
78+ ```text
79+ ${{ steps.catalogue.outputs.changes }}
80+ ```
81+
82+ Merging does not release: users get the new catalogue with the next version of `jdecool/scaleway-runtime`.
new file mode 100644
@@ -0,0 +1,82 @@
1+name: Function Runtime Catalogue
2+
3+# Scaleway updates its Function Runtimes without notice: measure them again every week, and propose the changes.
4+on:
5+ schedule:
6+ - cron: '0 5 * * 1'
7+ workflow_dispatch:
8+
9+permissions:
10+ contents: write
11+ pull-requests: write
12+
13+concurrency:
14+ # The probe's namespace and function names are fixed: two runs would deploy over each other.
15+ group: function-runtime-catalogue
16+
17+jobs:
18+ measure:
19+ name: Measure the Function Runtimes
20+ runs-on: ubuntu-latest
21+ env:
22+ # A key limited to Serverless Functions, in a project dedicated to the probe.
23+ SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
24+ SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
25+ SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
26+ steps:
27+ - uses: actions/checkout@v7
28+
29+ - uses: shivammathur/setup-php@v2
30+ with:
31+ php-version: '8.5'
32+ coverage: none
33+
34+ - uses: ramsey/composer-install@v4
35+
36+ - uses: hashicorp/setup-terraform@v3
37+ with:
38+ terraform_wrapper: false
39+
40+ - name: Measure each Function Runtime with the probe
41+ run: |
42+ terraform -chdir=probe/terraform init -input=false
43+ for runtime in php84 php85; do
44+ terraform -chdir=probe/terraform apply -auto-approve -input=false -var "runtime=$runtime"
45+ endpoint=$(terraform -chdir=probe/terraform output -raw endpoint)
46+ fixture="tests/Fixtures/FunctionRuntimes/$runtime.json"
47+ # A replaced function keeps answering with the previous Function Runtime for a while.
48+ timeout 300 bash -c "until curl -sSf '$endpoint/?mode=runtime' -o '$fixture' && grep -q '\"phpVersion\": \"${runtime:3:1}\.${runtime:4:1}\.' '$fixture'; do sleep 5; done"
49+ done
50+
51+ - name: Destroy the probe
52+ if: always()
53+ run: terraform -chdir=probe/terraform destroy -auto-approve -input=false
54+
55+ - name: Regenerate the catalogue
56+ id: catalogue
57+ run: |
58+ changes=$(php probe/catalogue.php)
59+ echo "$changes"
60+ { echo 'changes<<EOF'; echo "$changes"; echo 'EOF'; } >> "$GITHUB_OUTPUT"
61+
62+ # Nothing but new measurement dates leaves the catalogue as it is.
63+ - name: Open or update the pull request
64+ if: steps.catalogue.outputs.changes != ''
65+ uses: peter-evans/create-pull-request@v7
66+ with:
67+ # Pull requests opened with the default token do not trigger the CI that checks the catalogue.
68+ token: ${{ secrets.CATALOGUE_PR_TOKEN || github.token }}
69+ branch: catalogue-update
70+ add-paths: |
71+ resources/function-runtimes.php
72+ tests/Fixtures/FunctionRuntimes
73+ commit-message: 'feat: update the Function Runtime Catalogue to the latest measurement'
74+ title: Update the Function Runtime Catalogue
75+ body: |
76+ The weekly measurement of the Function Runtimes found changes on Scaleway:
77+
78+ ```text
79+ ${{ steps.catalogue.outputs.changes }}
80+ ```
81+
82+ Merging does not release: users get the new catalogue with the next version of `jdecool/scaleway-runtime`.
modified probe/catalogue.php +7 -1
@@ -4,12 +4,18 @@ declare(strict_types=1);
44
55 /*
66 * Regenerates resources/function-runtimes.php from the probe outputs in tests/Fixtures/FunctionRuntimes,
7- * saved with the probe's "runtime" mode: see docs/probe-results.md#function-runtime-catalogue.
7+ * saved with the probe's "runtime" mode, and prints what changed: see docs/probe-results.md#function-runtime-catalogue.
88 */
99
1010 use JDecool\ScalewayRuntime\FunctionRuntimeCatalogue;
1111
1212 require __DIR__.'/../vendor/autoload.php';
1313
14+$old = FunctionRuntimeCatalogue::load();
1415 $files = glob(__DIR__.'/../tests/Fixtures/FunctionRuntimes/*.json') ?: [];
1516 file_put_contents(FunctionRuntimeCatalogue::FILE, FunctionRuntimeCatalogue::generate(array_map(static fn (string $file): string => (string) file_get_contents($file), $files)));
17+
18+// Prints what changed, nothing when only the measurement dates did: the freshness workflow opens a pull request on output.
19+foreach (FunctionRuntimeCatalogue::load()->changes($old) as $change) {
20+ echo $change, \PHP_EOL;
21+}
@@ -4,12 +4,18 @@ declare(strict_types=1);
4 4
5 /*5 /*
6 * Regenerates resources/function-runtimes.php from the probe outputs in tests/Fixtures/FunctionRuntimes,6 * Regenerates resources/function-runtimes.php from the probe outputs in tests/Fixtures/FunctionRuntimes,
7- * saved with the probe's "runtime" mode: see docs/probe-results.md#function-runtime-catalogue.7+ * saved with the probe's "runtime" mode, and prints what changed: see docs/probe-results.md#function-runtime-catalogue.
8 */8 */
9 9
10 use JDecool\ScalewayRuntime\FunctionRuntimeCatalogue;10 use JDecool\ScalewayRuntime\FunctionRuntimeCatalogue;
11 11
12 require __DIR__.'/../vendor/autoload.php';12 require __DIR__.'/../vendor/autoload.php';
13 13
14+$old = FunctionRuntimeCatalogue::load();
14 $files = glob(__DIR__.'/../tests/Fixtures/FunctionRuntimes/*.json') ?: [];15 $files = glob(__DIR__.'/../tests/Fixtures/FunctionRuntimes/*.json') ?: [];
15 file_put_contents(FunctionRuntimeCatalogue::FILE, FunctionRuntimeCatalogue::generate(array_map(static fn (string $file): string => (string) file_get_contents($file), $files)));16 file_put_contents(FunctionRuntimeCatalogue::FILE, FunctionRuntimeCatalogue::generate(array_map(static fn (string $file): string => (string) file_get_contents($file), $files)));
17+
18+// Prints what changed, nothing when only the measurement dates did: the freshness workflow opens a pull request on output.
19+foreach (FunctionRuntimeCatalogue::load()->changes($old) as $change) {
20+ echo $change, \PHP_EOL;
21+}
modified src/FunctionRuntimeCatalogue.php +38 -0
@@ -85,6 +85,44 @@ final readonly class FunctionRuntimeCatalogue
8585 return "<?php\n\ndeclare(strict_types=1);\n\n// Generated by probe/catalogue.php from tests/Fixtures/FunctionRuntimes: do not edit by hand.\n\nreturn ".self::export($functionRuntimes, '').";\n";
8686 }
8787
88+ /**
89+ * What changed since an older catalogue, one line each, for the pull request a new measurement opens.
90+ * Empty when only the measurement dates changed: the Function Runtimes still are as recorded.
91+ *
92+ * @return list<string>
93+ */
94+ public function changes(self $old): array
95+ {
96+ $changes = [];
97+ foreach (array_diff_key($old->functionRuntimes, $this->functionRuntimes) as $name => $_) {
98+ $changes[] = $name.': no longer measured';
99+ }
100+ foreach ($this->functionRuntimes as $name => $new) {
101+ $previous = $old->functionRuntimes[$name] ?? null;
102+ if (null === $previous) {
103+ $changes[] = \sprintf('%s: new Function Runtime, PHP %s with %d extensions', $name, $new['php'], \count($new['extensions']));
104+ continue;
105+ }
106+ $lines = $previous['php'] === $new['php'] ? [] : [\sprintf('%s: PHP %s -> %s', $name, $previous['php'], $new['php'])];
107+ foreach ($new['extensions'] + $previous['extensions'] as $extension => $_) {
108+ $before = $previous['extensions'][$extension] ?? null;
109+ $after = $new['extensions'][$extension] ?? null;
110+ $lines[] = match (true) {
111+ null === $before => \sprintf('%s: + %s %s', $name, $extension, $after),
112+ null === $after => \sprintf('%s: - %s', $name, $extension),
113+ $before !== $after => \sprintf('%s: %s %s -> %s', $name, $extension, $before, $after),
114+ default => null,
115+ };
116+ }
117+ $lines = array_values(array_filter($lines));
118+ if ([] !== $lines) {
119+ $changes = [...$changes, ...$lines, \sprintf('%s: measured %s -> %s', $name, $previous['measuredAt'], $new['measuredAt'])];
120+ }
121+ }
122+
123+ return $changes;
124+ }
125+
88126 /**
89127 * Composer keeps a parseable PHP_VERSION whole, so that "8.5.0-RC1" stays a pre-release, and cuts the others, as
90128 * "8.4.28-1+deb12", before their first "~", "+" or "-".
@@ -85,6 +85,44 @@ final readonly class FunctionRuntimeCatalogue
85 return "<?php\n\ndeclare(strict_types=1);\n\n// Generated by probe/catalogue.php from tests/Fixtures/FunctionRuntimes: do not edit by hand.\n\nreturn ".self::export($functionRuntimes, '').";\n";85 return "<?php\n\ndeclare(strict_types=1);\n\n// Generated by probe/catalogue.php from tests/Fixtures/FunctionRuntimes: do not edit by hand.\n\nreturn ".self::export($functionRuntimes, '').";\n";
86 }86 }
87 87
88+ /**
89+ * What changed since an older catalogue, one line each, for the pull request a new measurement opens.
90+ * Empty when only the measurement dates changed: the Function Runtimes still are as recorded.
91+ *
92+ * @return list<string>
93+ */
94+ public function changes(self $old): array
95+ {
96+ $changes = [];
97+ foreach (array_diff_key($old->functionRuntimes, $this->functionRuntimes) as $name => $_) {
98+ $changes[] = $name.': no longer measured';
99+ }
100+ foreach ($this->functionRuntimes as $name => $new) {
101+ $previous = $old->functionRuntimes[$name] ?? null;
102+ if (null === $previous) {
103+ $changes[] = \sprintf('%s: new Function Runtime, PHP %s with %d extensions', $name, $new['php'], \count($new['extensions']));
104+ continue;
105+ }
106+ $lines = $previous['php'] === $new['php'] ? [] : [\sprintf('%s: PHP %s -> %s', $name, $previous['php'], $new['php'])];
107+ foreach ($new['extensions'] + $previous['extensions'] as $extension => $_) {
108+ $before = $previous['extensions'][$extension] ?? null;
109+ $after = $new['extensions'][$extension] ?? null;
110+ $lines[] = match (true) {
111+ null === $before => \sprintf('%s: + %s %s', $name, $extension, $after),
112+ null === $after => \sprintf('%s: - %s', $name, $extension),
113+ $before !== $after => \sprintf('%s: %s %s -> %s', $name, $extension, $before, $after),
114+ default => null,
115+ };
116+ }
117+ $lines = array_values(array_filter($lines));
118+ if ([] !== $lines) {
119+ $changes = [...$changes, ...$lines, \sprintf('%s: measured %s -> %s', $name, $previous['measuredAt'], $new['measuredAt'])];
120+ }
121+ }
122+
123+ return $changes;
124+ }
125+
88 /**126 /**
89 * Composer keeps a parseable PHP_VERSION whole, so that "8.5.0-RC1" stays a pre-release, and cuts the others, as127 * Composer keeps a parseable PHP_VERSION whole, so that "8.5.0-RC1" stays a pre-release, and cuts the others, as
90 * "8.4.28-1+deb12", before their first "~", "+" or "-".128 * "8.4.28-1+deb12", before their first "~", "+" or "-".
modified tests/FunctionRuntimeCatalogueTest.php +32 -0
@@ -92,6 +92,38 @@ final class FunctionRuntimeCatalogueTest extends TestCase
9292 FunctionRuntimeCatalogue::load()->get('php83');
9393 }
9494
95+ public function testChangesListWhatANewMeasurementChanged(): void
96+ {
97+ $old = new FunctionRuntimeCatalogue([
98+ 'php83' => ['measuredAt' => '2026-11-14T10:00:00Z', 'php' => '8.3.30', 'extensions' => []],
99+ 'php84' => ['measuredAt' => '2026-11-14T10:00:00Z', 'php' => '8.4.27', 'extensions' => ['ext-amqp' => '2.2.0', 'ext-ctype' => '8.4.27', 'ext-redis' => '6.3.0']],
100+ 'php85' => ['measuredAt' => '2026-11-14T10:00:00Z', 'php' => '8.5.13', 'extensions' => ['ext-redis' => '6.3.0']],
101+ ]);
102+ $new = new FunctionRuntimeCatalogue([
103+ 'php84' => ['measuredAt' => '2026-11-29T10:00:00Z', 'php' => '8.4.29', 'extensions' => ['ext-ctype' => '8.4.29', 'ext-foo' => '1.2.0', 'ext-redis' => '6.3.0']],
104+ 'php85' => ['measuredAt' => '2026-11-29T10:00:00Z', 'php' => '8.5.13', 'extensions' => ['ext-redis' => '6.3.0']],
105+ 'php86' => ['measuredAt' => '2026-11-29T10:00:00Z', 'php' => '8.6.0', 'extensions' => ['ext-redis' => '6.3.0']],
106+ ]);
107+
108+ self::assertSame([
109+ 'php83: no longer measured',
110+ 'php84: PHP 8.4.27 -> 8.4.29',
111+ 'php84: ext-ctype 8.4.27 -> 8.4.29',
112+ 'php84: + ext-foo 1.2.0',
113+ 'php84: - ext-amqp',
114+ 'php84: measured 2026-11-14T10:00:00Z -> 2026-11-29T10:00:00Z',
115+ 'php86: new Function Runtime, PHP 8.6.0 with 1 extensions',
116+ ], $new->changes($old));
117+ }
118+
119+ public function testNewMeasurementDatesAloneAreNoChange(): void
120+ {
121+ $catalogue = FunctionRuntimeCatalogue::load();
122+ $remeasured = new FunctionRuntimeCatalogue(array_map(static fn (array $functionRuntime): array => ['measuredAt' => '2099-01-01T00:00:00Z'] + $functionRuntime, $catalogue->functionRuntimes));
123+
124+ self::assertSame([], $remeasured->changes($catalogue));
125+ }
126+
95127 /**
96128 * @param array<string, mixed> $measurement
97129 */
@@ -92,6 +92,38 @@ final class FunctionRuntimeCatalogueTest extends TestCase
92 FunctionRuntimeCatalogue::load()->get('php83');92 FunctionRuntimeCatalogue::load()->get('php83');
93 }93 }
94 94
95+ public function testChangesListWhatANewMeasurementChanged(): void
96+ {
97+ $old = new FunctionRuntimeCatalogue([
98+ 'php83' => ['measuredAt' => '2026-11-14T10:00:00Z', 'php' => '8.3.30', 'extensions' => []],
99+ 'php84' => ['measuredAt' => '2026-11-14T10:00:00Z', 'php' => '8.4.27', 'extensions' => ['ext-amqp' => '2.2.0', 'ext-ctype' => '8.4.27', 'ext-redis' => '6.3.0']],
100+ 'php85' => ['measuredAt' => '2026-11-14T10:00:00Z', 'php' => '8.5.13', 'extensions' => ['ext-redis' => '6.3.0']],
101+ ]);
102+ $new = new FunctionRuntimeCatalogue([
103+ 'php84' => ['measuredAt' => '2026-11-29T10:00:00Z', 'php' => '8.4.29', 'extensions' => ['ext-ctype' => '8.4.29', 'ext-foo' => '1.2.0', 'ext-redis' => '6.3.0']],
104+ 'php85' => ['measuredAt' => '2026-11-29T10:00:00Z', 'php' => '8.5.13', 'extensions' => ['ext-redis' => '6.3.0']],
105+ 'php86' => ['measuredAt' => '2026-11-29T10:00:00Z', 'php' => '8.6.0', 'extensions' => ['ext-redis' => '6.3.0']],
106+ ]);
107+
108+ self::assertSame([
109+ 'php83: no longer measured',
110+ 'php84: PHP 8.4.27 -> 8.4.29',
111+ 'php84: ext-ctype 8.4.27 -> 8.4.29',
112+ 'php84: + ext-foo 1.2.0',
113+ 'php84: - ext-amqp',
114+ 'php84: measured 2026-11-14T10:00:00Z -> 2026-11-29T10:00:00Z',
115+ 'php86: new Function Runtime, PHP 8.6.0 with 1 extensions',
116+ ], $new->changes($old));
117+ }
118+
119+ public function testNewMeasurementDatesAloneAreNoChange(): void
120+ {
121+ $catalogue = FunctionRuntimeCatalogue::load();
122+ $remeasured = new FunctionRuntimeCatalogue(array_map(static fn (array $functionRuntime): array => ['measuredAt' => '2099-01-01T00:00:00Z'] + $functionRuntime, $catalogue->functionRuntimes));
123+
124+ self::assertSame([], $remeasured->changes($catalogue));
125+ }
126+
95 /**127 /**
96 * @param array<string, mixed> $measurement128 * @param array<string, mixed> $measurement
97 */129 */