Skip to content

Commit 9a9e20d

Browse files
authored
Merge pull request #80 from appwrite/feat-deprecated-runtimes
Feat: Deprecated runtimes
2 parents 0d1bddb + d9cd6ba commit 9a9e20d

File tree

4 files changed

+86
-24
lines changed

4 files changed

+86
-24
lines changed

src/Runtimes/Runtime.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function getKey(): string
4747
*
4848
* @param string[] $supports
4949
*/
50-
public function addVersion(string $version, string $base, string $image, array $supports): void
50+
public function addVersion(string $version, string $base, string $image, array $supports, bool $deprecated = false): void
5151
{
52-
$this->versions[] = new Version($version, $base, $image, $supports);
52+
$this->versions[] = new Version($version, $base, $image, $supports, $deprecated);
5353
}
5454

5555
/**

src/Runtimes/Runtimes.php

+59-20
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@
55
use Exception;
66
use Utopia\System\System;
77

8+
/**
9+
* Useful resources:
10+
*
11+
* Overall: https://endoflife.date/
12+
*
13+
* Node: https://nodejs.org/en/about/previous-releases
14+
* PHP: https://www.php.net/supported-versions.php
15+
* Ruby: https://www.ruby-lang.org/en/downloads/branches/
16+
* Python: https://devguide.python.org/versions/
17+
* Deno: https://docs.deno.com/runtime/fundamentals/stability_and_releases/
18+
* .NET: https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core
19+
* Java: https://www.oracle.com/java/technologies/java-se-support-roadmap.html
20+
* Dart: https://dart.dev/resources/whats-new
21+
* Swift: https://github.com/swiftlang/swift-evolution
22+
* Kotlin: https://kotlinlang.org/docs/releases.html#update-to-a-new-kotlin-version
23+
*
24+
* Dart: No official document, support last 6 versions (~1.5 years) (plus latest 2.x until 4.x releases)
25+
* Deno: Technically, all 1.x is deprecated. Mark them deprecated overtime, not all at once.
26+
* Swift: No official document, support last 4 versions (~2 years)
27+
*/
28+
829
class Runtimes
930
{
1031
/** @var array<string, Runtime> */
@@ -20,8 +41,8 @@ public function __construct(string $version = '')
2041
$this->version = $version;
2142

2243
$node = new Runtime('node', 'Node.js', 'sh helpers/server.sh');
23-
$node->addVersion('14.5', 'node:14.5.0-alpine3.12', 'openruntimes/node:'.$this->version.'-14.5', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
24-
$node->addVersion('16.0', 'node:16.20.2-alpine3.18', 'openruntimes/node:'.$this->version.'-16.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
44+
$node->addVersion('14.5', 'node:14.5.0-alpine3.12', 'openruntimes/node:'.$this->version.'-14.5', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); # Deprecated since April 30, 2023
45+
$node->addVersion('16.0', 'node:16.20.2-alpine3.18', 'openruntimes/node:'.$this->version.'-16.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); # Deprecated since September 11, 2023
2546
$node->addVersion('18.0', 'node:18.20.4-alpine3.20', 'openruntimes/node:'.$this->version.'-18.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
2647
$node->addVersion('19.0', 'node:19.9.0-alpine3.18', 'openruntimes/node:'.$this->version.'-19.0', [System::X86, System::ARM64]);
2748
$node->addVersion('20.0', 'node:20.17.0-alpine3.20', 'openruntimes/node:'.$this->version.'-20.0', [System::X86, System::ARM64]);
@@ -30,21 +51,21 @@ public function __construct(string $version = '')
3051
$this->runtimes['node'] = $node;
3152

3253
$php = new Runtime('php', 'PHP', 'sh helpers/server.sh');
33-
$php->addVersion('8.0', 'php:8.0.30-cli-alpine3.16', 'openruntimes/php:'.$this->version.'-8.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
54+
$php->addVersion('8.0', 'php:8.0.30-cli-alpine3.16', 'openruntimes/php:'.$this->version.'-8.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); # Deprecated since November 26, 2023
3455
$php->addVersion('8.1', 'php:8.1.30-cli-alpine3.20', 'openruntimes/php:'.$this->version.'-8.1', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
3556
$php->addVersion('8.2', 'php:8.2.24-cli-alpine3.20', 'openruntimes/php:'.$this->version.'-8.2', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
3657
$php->addVersion('8.3', 'php:8.3.12-cli-alpine3.20', 'openruntimes/php:'.$this->version.'-8.3', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
3758
$this->runtimes['php'] = $php;
3859

3960
$ruby = new Runtime('ruby', 'Ruby', 'sh helpers/server.sh');
40-
$ruby->addVersion('3.0', 'ruby:3.0.7-alpine3.16', 'openruntimes/ruby:'.$this->version.'-3.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
61+
$ruby->addVersion('3.0', 'ruby:3.0.7-alpine3.16', 'openruntimes/ruby:'.$this->version.'-3.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); # Deprecated since April 23, 2024
4162
$ruby->addVersion('3.1', 'ruby:3.1.6-alpine3.20', 'openruntimes/ruby:'.$this->version.'-3.1', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
4263
$ruby->addVersion('3.2', 'ruby:3.2.5-alpine3.20', 'openruntimes/ruby:'.$this->version.'-3.2', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
4364
$ruby->addVersion('3.3', 'ruby:3.3.5-alpine3.20', 'openruntimes/ruby:'.$this->version.'-3.3', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
4465
$this->runtimes['ruby'] = $ruby;
4566

4667
$python = new Runtime('python', 'Python', 'sh helpers/server.sh');
47-
$python->addVersion('3.8', 'python:3.8.20-alpine3.20', 'openruntimes/python:'.$this->version.'-3.8', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
68+
$python->addVersion('3.8', 'python:3.8.20-alpine3.20', 'openruntimes/python:'.$this->version.'-3.8', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); // Deprecated since October 7, 2024
4869
$python->addVersion('3.9', 'python:3.9.20-alpine3.20', 'openruntimes/python:'.$this->version.'-3.9', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
4970
$python->addVersion('3.10', 'python:3.10.15-alpine3.20', 'openruntimes/python:'.$this->version.'-3.10', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
5071
$python->addVersion('3.11', 'python:3.11.10-alpine3.20', 'openruntimes/python:'.$this->version.'-3.11', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
@@ -57,49 +78,50 @@ public function __construct(string $version = '')
5778
$this->runtimes['python-ml'] = $pythonML;
5879

5980
$deno = new Runtime('deno', 'Deno', 'sh helpers/server.sh');
60-
$deno->addVersion('1.21', 'denoland/deno:alpine-1.21.3', 'openruntimes/deno:'.$this->version.'-1.21', [System::X86]);
61-
$deno->addVersion('1.24', 'denoland/deno:alpine-1.24.3', 'openruntimes/deno:'.$this->version.'-1.24', [System::X86]);
62-
$deno->addVersion('1.35', 'denoland/deno:alpine-1.35.3', 'openruntimes/deno:'.$this->version.'-1.35', [System::X86]);
81+
$deno->addVersion('1.21', 'denoland/deno:alpine-1.21.3', 'openruntimes/deno:'.$this->version.'-1.21', [System::X86], true);
82+
$deno->addVersion('1.24', 'denoland/deno:alpine-1.24.3', 'openruntimes/deno:'.$this->version.'-1.24', [System::X86], true);
83+
$deno->addVersion('1.35', 'denoland/deno:alpine-1.35.3', 'openruntimes/deno:'.$this->version.'-1.35', [System::X86], true);
6384
$deno->addVersion('1.40', 'denoland/deno:alpine-1.40.5', 'openruntimes/deno:'.$this->version.'-1.40', [System::X86, System::ARM64]);
6485
$deno->addVersion('1.46', 'denoland/deno:alpine-1.46.3', 'openruntimes/deno:'.$this->version.'-1.46', [System::X86, System::ARM64]);
6586
$deno->addVersion('2.0', 'denoland/deno:alpine-2.0.0-rc.5', 'openruntimes/deno:'.$this->version.'-2.0', [System::X86, System::ARM64]);
6687
$this->runtimes['deno'] = $deno;
6788

6889
$dart = new Runtime('dart', 'Dart', 'sh helpers/server.sh');
69-
$dart->addVersion('2.15', 'dart:2.15.1', 'openruntimes/dart:'.$this->version.'-2.15', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
70-
$dart->addVersion('2.16', 'dart:2.16.2', 'openruntimes/dart:'.$this->version.'-2.16', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
71-
$dart->addVersion('2.17', 'dart:2.17.7', 'openruntimes/dart:'.$this->version.'-2.17', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
90+
$dart->addVersion('2.15', 'dart:2.15.1', 'openruntimes/dart:'.$this->version.'-2.15', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true);
91+
$dart->addVersion('2.16', 'dart:2.16.2', 'openruntimes/dart:'.$this->version.'-2.16', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true);
92+
$dart->addVersion('2.17', 'dart:2.17.7', 'openruntimes/dart:'.$this->version.'-2.17', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true);
7293
$dart->addVersion('2.18', 'dart:2.18.7', 'openruntimes/dart:'.$this->version.'-2.18', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
73-
$dart->addVersion('2.18', 'dart:2.19.6', 'openruntimes/dart:'.$this->version.'-2.19', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
94+
$dart->addVersion('2.19', 'dart:2.19.6', 'openruntimes/dart:'.$this->version.'-2.19', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
7495
$dart->addVersion('3.0', 'dart:3.0.7', 'openruntimes/dart:'.$this->version.'-3.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
7596
$dart->addVersion('3.1', 'dart:3.1.5', 'openruntimes/dart:'.$this->version.'-3.1', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
7697
$dart->addVersion('3.3', 'dart:3.3.4', 'openruntimes/dart:'.$this->version.'-3.3', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
7798
$dart->addVersion('3.5', 'dart:3.5.2', 'openruntimes/dart:'.$this->version.'-3.5', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
7899
$this->runtimes['dart'] = $dart;
79100

80101
$dotnet = new Runtime('dotnet', '.NET', 'sh helpers/server.sh');
81-
$dotnet->addVersion('6.0', 'mcr.microsoft.com/dotnet/sdk:6.0.425-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-6.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
82-
$dotnet->addVersion('7.0', 'mcr.microsoft.com/dotnet/sdk:7.0.410-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-7.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
102+
$dotnet->addVersion('6.0', 'mcr.microsoft.com/dotnet/sdk:6.0.425-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-6.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); // Deprecated since November 12, 2024
103+
$dotnet->addVersion('7.0', 'mcr.microsoft.com/dotnet/sdk:7.0.410-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-7.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); // Deprecated since May 14, 2024
83104
$dotnet->addVersion('8.0', 'mcr.microsoft.com/dotnet/sdk:8.0.402-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-8.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
84105
$this->runtimes['dotnet'] = $dotnet;
85106

86107
$java = new Runtime('java', 'Java', 'sh helpers/server.sh');
87108
$java->addVersion('8.0', 'eclipse-temurin:8-jdk-jammy', 'openruntimes/java:'.$this->version.'-8.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
88109
$java->addVersion('11.0', 'eclipse-temurin:11-jdk-jammy', 'openruntimes/java:'.$this->version.'-11.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
89110
$java->addVersion('17.0', 'eclipse-temurin:17-jdk-jammy', 'openruntimes/java:'.$this->version.'-17.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
90-
$java->addVersion('18.0', 'eclipse-temurin:18-jdk-jammy', 'openruntimes/java:'.$this->version.'-18.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
111+
$java->addVersion('18.0', 'eclipse-temurin:18-jdk-jammy', 'openruntimes/java:'.$this->version.'-18.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true); // Deprecated since September 20, 2022
91112
$java->addVersion('21.0', 'eclipse-temurin:21-jdk-jammy', 'openruntimes/java:'.$this->version.'-21.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
92-
$java->addVersion('22', 'eclipse-temurin:22-jdk-jammy', 'openruntimes/java:'.$this->version.'-22', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
113+
$java->addVersion('22', 'eclipse-temurin:22-jdk-jammy', 'openruntimes/java:'.$this->version.'-22', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]); // Technically deprecated, but latest. Keeping active
93114
$this->runtimes['java'] = $java;
94115

95116
$swift = new Runtime('swift', 'Swift', 'sh helpers/server.sh');
117+
$swift->addVersion('5.5', 'swiftarm/swift:5.5.3-ubuntu-jammy', 'openruntimes/swift:'.$this->version.'-5.5', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true);
96118
$swift->addVersion('5.8', 'swiftarm/swift:5.8.1-ubuntu-22.04', 'openruntimes/swift:'.$this->version.'-5.8', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
97119
$swift->addVersion('5.9', 'swiftarm/swift:5.9.2-ubuntu-22.04', 'openruntimes/swift:'.$this->version.'-5.9', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
98120
$swift->addVersion('5.10', 'swiftarm/swift:5.10-ubuntu-22.04', 'openruntimes/swift:'.$this->version.'-5.10', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
99121
$this->runtimes['swift'] = $swift;
100122

101123
$kotlin = new Runtime('kotlin', 'Kotlin', 'sh helpers/server.sh');
102-
$kotlin->addVersion('1.6', 'eclipse-temurin:18-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-1.6', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
124+
$kotlin->addVersion('1.6', 'eclipse-temurin:18-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-1.6', [System::X86, System::ARM64, System::ARMV7, System::ARMV8], true);
103125
$kotlin->addVersion('1.8', 'eclipse-temurin:19-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-1.8', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
104126
$kotlin->addVersion('1.9', 'eclipse-temurin:19-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-1.9', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
105127
$kotlin->addVersion('2.0', 'eclipse-temurin:22-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-2.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
@@ -156,19 +178,36 @@ public function get(string $key): Runtime
156178
* Returns all supported runtimes.
157179
*
158180
* @param bool $supported Pass `false` to also return unsupported CPU architecture.
181+
* @param bool $deprecated Pass `false` to filter out deprecated versions from runtimes
159182
* @param array<mixed> $filter
160183
* @return array<mixed>
161184
*/
162-
public function getAll(bool $supported = true, array $filter = []): array
185+
public function getAll(bool $supported = true, array $filter = [], $deprecated = true): array
163186
{
164187
$supportedRuntimes = [];
165188

166189
foreach ($this->runtimes as $runtime) {
167-
$supportedRuntimes = array_merge(array_reverse(array_filter($runtime->list(), function (array $version, string $key) use ($supported, $filter) {
190+
$supportedRuntimes = array_merge(array_reverse(array_filter($runtime->list(), function (array $version, string $key) use ($supported, $filter, $deprecated) {
168191
$isSupported = in_array(System::getArchEnum(), $version['supports']);
169192
$isFiltered = in_array($key, $filter);
193+
$isDeprecated = $version['deprecated'];
194+
195+
// Apply supported filter
196+
if ($supported && !$isSupported) {
197+
return false;
198+
}
199+
200+
// Apply version filter
201+
if (\count($filter) > 0 && !$isFiltered) {
202+
return false;
203+
}
204+
205+
// Apply deprecation filter
206+
if (!$deprecated && $isDeprecated) {
207+
return false;
208+
}
170209

171-
return $supported ? ($isSupported && ($filter ? $isFiltered : true)) : true;
210+
return true;
172211
}, ARRAY_FILTER_USE_BOTH)), $supportedRuntimes);
173212
}
174213

src/Runtimes/Version.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,26 @@ class Version
1818
*/
1919
public array $supports;
2020

21+
public bool $deprecated;
22+
2123
/**
2224
* Version class that holds metadata about a Runtime Version.
2325
*
2426
* @param array<string> $supports
2527
*/
26-
public function __construct(string $version, string $base, string $image, array $supports)
28+
public function __construct(string $version, string $base, string $image, array $supports, bool $deprecated = false)
2729
{
2830
$this->version = $version;
2931
$this->base = $base;
3032
$this->image = $image;
3133
$this->supports = $supports;
34+
$this->deprecated = $deprecated;
3235
}
3336

3437
/**
3538
* Get parsed Version.
3639
*
37-
* @return (array<mixed>|string)[]
40+
* @return array<string, mixed>
3841
*/
3942
public function get(): array
4043
{
@@ -44,6 +47,7 @@ public function get(): array
4447
'base' => $this->base,
4548
'image' => $this->image,
4649
'supports' => $this->supports,
50+
'deprecated' => $this->deprecated,
4751
];
4852
}
4953
}

tests/Runtimes/RuntimesTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ public function testSupportedRuntimes(): void
167167
$this->assertCount(2, $this->instance->getAll(filter: ['node-14.5', 'node-16.0']));
168168
}
169169

170+
public function testDeprecatedRuntimes(): void
171+
{
172+
$versions = $this->instance->getAll();
173+
$nodeDeprecated = $versions['node-14.5'];
174+
$this->assertArrayHasKey('deprecated', $nodeDeprecated);
175+
$this->assertTrue($nodeDeprecated['deprecated']);
176+
177+
$nodeNonDeprecated = $versions['node-22'];
178+
$this->assertArrayHasKey('deprecated', $nodeNonDeprecated);
179+
$this->assertFalse($nodeNonDeprecated['deprecated']);
180+
181+
$runtime = $this->instance->get('node');
182+
$this->assertArrayHasKey('deprecated', $runtime->list()["node-14.5"]);
183+
$this->assertArrayHasKey('deprecated', $runtime->list()["node-22"]);
184+
185+
$versions = $this->instance->getAll(deprecated: false);
186+
$this->assertArrayNotHasKey('node-14.5', $versions);
187+
}
188+
170189
public function testGetRuntimes(): void
171190
{
172191
foreach ($this->instance->getAll() as $runtime) {

0 commit comments

Comments
 (0)