diff --git a/packages/nextcloud/test/dashboard_test.dart b/packages/nextcloud/test/dashboard_test.dart index c1d50e9025a..020fc043dae 100644 --- a/packages/nextcloud/test/dashboard_test.dart +++ b/packages/nextcloud/test/dashboard_test.dart @@ -48,7 +48,7 @@ void main() { final items = response.body.ocs.data['recommendations']!.items; expect(items, hasLength(7)); }, - skip: preset.version.toVersion() < Version(27, 1, 0), + skip: preset.version.getRaw() < Version(27, 1, 0), ); }); }, diff --git a/packages/nextcloud_test/bin/generate_presets.dart b/packages/nextcloud_test/bin/generate_presets.dart index 6ee1df5620f..77be1b41f89 100644 --- a/packages/nextcloud_test/bin/generate_presets.dart +++ b/packages/nextcloud_test/bin/generate_presets.dart @@ -4,8 +4,6 @@ import 'package:nextcloud_test/src/app.dart'; import 'package:nextcloud_test/src/extended_version.dart'; import 'package:universal_io/io.dart'; -final versionPattern = RegExp(r'^[0-9]+\.[0-9]+\.[0-9]+$'); - Future main() async { const appIDs = [ 'news', @@ -38,7 +36,9 @@ Future main() async { if (a == app) { buffer.writeln(release.url); } else { - final release = a.findLatestCompatibleRelease(serverVersion) ?? a.findLatestRelease(); + final release = a.findLatestCompatibleRelease(serverVersion) ?? + a.findLatestCompatibleRelease(serverVersion, allowUnstable: true) ?? + a.findLatestRelease(); buffer.writeln(release.url); } } @@ -57,7 +57,9 @@ Future main() async { final buffer = StringBuffer()..writeln('SERVER_VERSION=$serverVersion'); for (final app in apps) { - final release = app.findLatestCompatibleRelease(serverVersion) ?? app.findLatestRelease(); + final release = app.findLatestCompatibleRelease(serverVersion) ?? + app.findLatestCompatibleRelease(serverVersion, allowUnstable: true) ?? + app.findLatestRelease(); buffer.writeln('${app.id.toUpperCase()}_URL=${release.url}'); } @@ -91,24 +93,26 @@ Future> _getServerVersions(final HttpClient httpClient) as final results = data['results'] as List; for (final result in results) { - final tag = result as Map; + try { + final tag = result as Map; - final name = tag['name'] as String; - if (!versionPattern.hasMatch(name)) { - continue; - } - final version = ExtendedVersion.parse(name); - final normalizedVersion = version.withoutPatch(); + final version = ExtendedVersion.parse(tag['name'] as String); + if (version.minor == null || version.patch == null) { + continue; + } - if (version < coreMinVersion || version.major > core.maxMajor) { - continue; - } + final normalizedVersion = version.withoutPatch(); - if (!versions.containsKey(normalizedVersion)) { - versions[normalizedVersion] = version; - } else if (version > versions[normalizedVersion]) { - versions[normalizedVersion] = version; - } + if (version < coreMinVersion || version.major > core.maxMajor) { + continue; + } + + if (!versions.containsKey(normalizedVersion)) { + versions[normalizedVersion] = version; + } else if (version > versions[normalizedVersion]) { + versions[normalizedVersion] = version; + } + } catch (_) {} } } @@ -140,11 +144,7 @@ Future> _getApps(final List appIDs, final HttpClient httpClien for (final releaseItem in releasesItems) { final release = releaseItem as Map; - final versionString = release['version'] as String; - if (!versionPattern.hasMatch(versionString)) { - continue; - } - final version = ExtendedVersion.parse(versionString); + final version = ExtendedVersion.parse(release['version'] as String); final normalizedVersion = version.withoutPatch(); final rawPlatformVersionSpec = release['rawPlatformVersionSpec'] as String; diff --git a/packages/nextcloud_test/docker/Dockerfile b/packages/nextcloud_test/docker/Dockerfile index fb2b594b7ae..778aa3ee10d 100644 --- a/packages/nextcloud_test/docker/Dockerfile +++ b/packages/nextcloud_test/docker/Dockerfile @@ -45,7 +45,7 @@ RUN curl -L "$SPREED_URL" | tar -xz -C / FROM nextcloud COPY --from=news /news /usr/src/nextcloud/apps/news -RUN ./occ app:enable news --force # TODO remove once news supports server 28 +RUN ./occ app:enable news COPY --from=notes /notes /usr/src/nextcloud/apps/notes RUN ./occ app:enable notes diff --git a/packages/nextcloud_test/docker/presets/news/25.0 b/packages/nextcloud_test/docker/presets/news/25.0 new file mode 100644 index 00000000000..93b066299c6 --- /dev/null +++ b/packages/nextcloud_test/docker/presets/news/25.0 @@ -0,0 +1,5 @@ +SERVER_VERSION=28.0.0 +NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha2/news.tar.gz +NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.1/notes-v4.9.1.tar.gz +SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.1/spreed-v18.0.1.tar.gz +UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz diff --git a/packages/nextcloud_test/docker/presets/notes/4.8 b/packages/nextcloud_test/docker/presets/notes/4.8 index 25eee6bbde2..3a05a354288 100644 --- a/packages/nextcloud_test/docker/presets/notes/4.8 +++ b/packages/nextcloud_test/docker/presets/notes/4.8 @@ -1,5 +1,5 @@ SERVER_VERSION=28.0.0 -NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz +NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha2/news.tar.gz NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.8.1/notes.tar.gz SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.1/spreed-v18.0.1.tar.gz UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz diff --git a/packages/nextcloud_test/docker/presets/notes/4.9 b/packages/nextcloud_test/docker/presets/notes/4.9 index 7c6420f5e54..93b066299c6 100644 --- a/packages/nextcloud_test/docker/presets/notes/4.9 +++ b/packages/nextcloud_test/docker/presets/notes/4.9 @@ -1,5 +1,5 @@ SERVER_VERSION=28.0.0 -NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz +NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha2/news.tar.gz NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.1/notes-v4.9.1.tar.gz SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.1/spreed-v18.0.1.tar.gz UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz diff --git a/packages/nextcloud_test/docker/presets/server/28.0 b/packages/nextcloud_test/docker/presets/server/28.0 index 7c6420f5e54..93b066299c6 100644 --- a/packages/nextcloud_test/docker/presets/server/28.0 +++ b/packages/nextcloud_test/docker/presets/server/28.0 @@ -1,5 +1,5 @@ SERVER_VERSION=28.0.0 -NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz +NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha2/news.tar.gz NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.1/notes-v4.9.1.tar.gz SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.1/spreed-v18.0.1.tar.gz UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz diff --git a/packages/nextcloud_test/docker/presets/spreed/18.0 b/packages/nextcloud_test/docker/presets/spreed/18.0 index 7c6420f5e54..93b066299c6 100644 --- a/packages/nextcloud_test/docker/presets/spreed/18.0 +++ b/packages/nextcloud_test/docker/presets/spreed/18.0 @@ -1,5 +1,5 @@ SERVER_VERSION=28.0.0 -NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz +NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha2/news.tar.gz NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.1/notes-v4.9.1.tar.gz SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.1/spreed-v18.0.1.tar.gz UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz diff --git a/packages/nextcloud_test/docker/presets/uppush/1.4 b/packages/nextcloud_test/docker/presets/uppush/1.4 index 7c6420f5e54..93b066299c6 100644 --- a/packages/nextcloud_test/docker/presets/uppush/1.4 +++ b/packages/nextcloud_test/docker/presets/uppush/1.4 @@ -1,5 +1,5 @@ SERVER_VERSION=28.0.0 -NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz +NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha2/news.tar.gz NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.1/notes-v4.9.1.tar.gz SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.1/spreed-v18.0.1.tar.gz UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz diff --git a/packages/nextcloud_test/lib/src/app.dart b/packages/nextcloud_test/lib/src/app.dart index d9823f153cc..cd7d41f172b 100644 --- a/packages/nextcloud_test/lib/src/app.dart +++ b/packages/nextcloud_test/lib/src/app.dart @@ -19,11 +19,13 @@ typedef App = ({ @internal extension AppFindLatestRelease on App { - AppRelease? findLatestCompatibleRelease(final ExtendedVersion serverVersion) { + AppRelease? findLatestCompatibleRelease(final ExtendedVersion serverVersion, {final bool allowUnstable = false}) { final compatibleReleases = releases .where( (final release) => - serverVersion >= release.minimumServerVersion && serverVersion <= release.maximumServerVersion, + serverVersion >= release.minimumServerVersion && + serverVersion <= release.maximumServerVersion && + (allowUnstable || !release.version.getRaw().isPreRelease), ) .toList() ..sort((final a, final b) => b.version.compareTo(a.version)); diff --git a/packages/nextcloud_test/lib/src/extended_version.dart b/packages/nextcloud_test/lib/src/extended_version.dart index ae3e20d0c17..1a749dfacea 100644 --- a/packages/nextcloud_test/lib/src/extended_version.dart +++ b/packages/nextcloud_test/lib/src/extended_version.dart @@ -11,16 +11,18 @@ final coreMinVersion = ExtendedVersion.fromVersion(core.minVersion); @internal class ExtendedVersion implements Comparable { const ExtendedVersion( + final Version raw, this.major, this.minor, this.patch, - ); + ) : _raw = raw; factory ExtendedVersion.parse(final String versionString) { final version = Version.parse(versionString); final dotCount = versionString.split('').where((final char) => char == '.').length; return ExtendedVersion( + version, version.major, dotCount >= 1 ? version.minor : null, dotCount >= 2 ? version.patch : null, @@ -28,20 +30,28 @@ class ExtendedVersion implements Comparable { } factory ExtendedVersion.fromVersion(final Version version) => ExtendedVersion( + version, version.major, version.minor, version.patch, ); + final Version _raw; + final int major; final int? minor; final int? patch; - ExtendedVersion withoutPatch() => ExtendedVersion(major, minor, null); + ExtendedVersion withoutPatch() => ExtendedVersion( + _raw, + major, + minor, + null, + ); - Version toVersion() => Version(major, minor ?? 0, patch ?? 0); + Version getRaw() => _raw; @override String toString() {