Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Collect flutter code coverage #404

Merged
merged 38 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ec1d111
test: Fix tests after cat-gateway update.
coire1 Apr 8, 2024
e06c98f
docs: Add `CatalystDataGatewayRepository` usage examples.
coire1 Apr 8, 2024
9fcbf68
docs: Move docs from README to code comment.
coire1 Apr 8, 2024
78e9cf6
test: Update `CatalystDataGatewayRepository` tests.
coire1 Apr 9, 2024
50d9bed
test: Use Fake instead of Mock.
coire1 Apr 9, 2024
f8ecf19
chore: Fix Markdown errors.
coire1 Apr 9, 2024
1c158c8
chore: Explicit use of `HttpStatus` codes.
coire1 Apr 9, 2024
4c381ce
Merge branch 'main' into feat/catalyst-data-repository-docs
coire1 Apr 9, 2024
9921f59
chore(deps-dev): bump vite in /utilities/wallet-tester (#397)
dependabot[bot] Apr 10, 2024
b5525c9
feat: Get slot number by provided date-time endpoint (#387)
Mr-Leshiy Apr 10, 2024
19e3714
feat: RBAC Documentation Drafting (#332)
stevenj Apr 10, 2024
4669781
ci: configure static analysis & code formatting check
dtscalac Apr 11, 2024
073e8f1
Merge branch 'feat/m3' into feat/collect-flutter-code-coverage
dtscalac Apr 11, 2024
c0cefde
style: formatting
dtscalac Apr 11, 2024
b528d87
fix: revert browser installation scripts
dtscalac Apr 11, 2024
6c3195a
style: format code
dtscalac Apr 11, 2024
faf975c
ci: optimize directions include in repo-catalyst-voices-all artifact …
dtscalac Apr 11, 2024
e0edfa7
refactor: remove empty tests
dtscalac Apr 11, 2024
34ecc55
ci: add melos script to generate test reports
dtscalac Apr 11, 2024
cb31fbb
ci: melos script to generate test report
dtscalac Apr 11, 2024
8d214b4
style: revert previously generated files formatting
dtscalac Apr 11, 2024
524e379
style: format files
dtscalac Apr 11, 2024
6b582c1
ci: update melos to exclude generated code form code coverage
dtscalac Apr 11, 2024
aeb1aa3
ci: cleanup build script
dtscalac Apr 11, 2024
44a7904
ci: generate multiple junit test reports and save them at /test_reports
dtscalac Apr 11, 2024
fe7bae2
ci: depend on melos analyze instead of custom command
dtscalac Apr 11, 2024
bc1ae88
docs: improve melos docs
dtscalac Apr 11, 2024
e90a0fe
ci: remove unused melos scripts
dtscalac Apr 11, 2024
08d0936
ci: format files in test & integration_test directories
dtscalac Apr 11, 2024
a83112f
ci: break code to make sure CI will report failure for demonstration …
dtscalac Apr 12, 2024
bb6e65e
style: fix lint issues
dtscalac Apr 12, 2024
dd6ce45
ci: change WORKDIR after creating the user to make sure it will be ow…
dtscalac Apr 12, 2024
39ce401
ci: restore root user
dtscalac Apr 12, 2024
d0f66b2
Merge branch 'main' into feat/collect-flutter-code-coverage
dtscalac Apr 12, 2024
9d9bbd1
Revert "Merge branch 'main' into feat/collect-flutter-code-coverage"
dtscalac Apr 12, 2024
52219a2
Merge branch 'feat/m3' into feat/collect-flutter-code-coverage
dtscalac Apr 12, 2024
188b5a2
style: format code
dtscalac Apr 12, 2024
209b94c
ci: revert test-unit target name
dtscalac Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
with:
earthfile: ./catalyst_voices/
flags:
targets: test-unit
targets: test-report
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
Expand Down
10 changes: 10 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ repo-catalyst-voices-packages:
WORKDIR /repo
COPY --dir catalyst_voices_packages .

SAVE ARTIFACT /repo repo

# repo-catalyst-voices-all - Creates artifacts of all configuration files,
# packages and folders related to catalyst_voices frontend.
repo-catalyst-voices-all:
FROM scratch

WORKDIR /repo
COPY --dir catalyst_voices catalyst_voices_packages utilities melos.yaml pubspec.yaml .

SAVE ARTIFACT /repo repo
30 changes: 23 additions & 7 deletions catalyst_voices/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ VERSION --try --global-cache --arg-scope-and-set 0.7
deps:
FROM debian:bookworm-slim
RUN apt-get update
RUN apt-get install -y git curl unzip bzip2 bash jq gpg
RUN apt-get install -y git curl unzip bzip2 bash jq gpg lcov
COPY --dir test_driver/scripts .
RUN chmod +x scripts/install-chrome-linux64.sh && ./scripts/install-chrome-linux64.sh
RUN chmod +x scripts/install-edge-linux64.sh && ./scripts/install-edge-linux64.sh
Expand All @@ -23,7 +23,9 @@ deps:
RUN flutter --version
RUN flutter doctor -v
RUN flutter config --enable-web
RUN dart pub global activate melos
RUN dart pub global activate junitreport
RUN dart pub global activate coverage

src:
FROM +deps
Expand Down Expand Up @@ -60,6 +62,20 @@ check-flutter-code-generator:
# Check diff between local code and earthly artifacts
RUN diff /tmp/repo_generated lib/generated/catalyst_gateway

check-static-analysis:
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos bootstrap
RUN melos analyze --fatal-infos --fatal-warnings

check-code-formatting:
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos bootstrap
RUN melos run format-check

# Build web version of Catalyst Voices
build:
FROM +src
Expand All @@ -72,12 +88,12 @@ build:
SAVE ARTIFACT web /web AS LOCAL web

test-unit:
FROM +build
WORKDIR /frontend
TRY
RUN flutter test --reporter expanded . --machine | tojunit --output flutter.junit-report.xml
FINALLY
SAVE ARTIFACT flutter.junit-report.xml AS LOCAL flutter-unit-tests.junit-report.xml
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos run test-report
WAIT
SAVE ARTIFACT test_reports AS LOCAL test_reports
END

package:
Expand Down
4 changes: 2 additions & 2 deletions catalyst_voices/lib/pages/coming_soon/coming_soon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ final class ComingSoonPage extends StatelessWidget {
decoration: BoxDecoration(
image: DecorationImage(
image: CatalystImage.asset(
VoicesAssets.images.comingSoonBkg.path,
).image,
VoicesAssets.images.comingSoonBkg.path,
).image,
fit: BoxFit.cover,
),
),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;

import 'catalyst_voices_localizations_en.dart' deferred as catalyst_voices_localizations_en;
import 'catalyst_voices_localizations_es.dart' deferred as catalyst_voices_localizations_es;
import 'catalyst_voices_localizations_en.dart'
deferred as catalyst_voices_localizations_en;
import 'catalyst_voices_localizations_es.dart'
deferred as catalyst_voices_localizations_es;

/// Callers can lookup localized strings with an instance of VoicesLocalizations
/// returned by `VoicesLocalizations.of(context)`.
Expand Down Expand Up @@ -59,15 +61,17 @@ import 'catalyst_voices_localizations_es.dart' deferred as catalyst_voices_local
/// be consistent with the languages listed in the VoicesLocalizations.supportedLocales
/// property.
abstract class VoicesLocalizations {
VoicesLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
VoicesLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());

final String localeName;

static VoicesLocalizations? of(BuildContext context) {
return Localizations.of<VoicesLocalizations>(context, VoicesLocalizations);
}

static const LocalizationsDelegate<VoicesLocalizations> delegate = _VoicesLocalizationsDelegate();
static const LocalizationsDelegate<VoicesLocalizations> delegate =
_VoicesLocalizationsDelegate();

/// A list of this localizations delegate along with the default localizations
/// delegates.
Expand All @@ -79,7 +83,8 @@ abstract class VoicesLocalizations {
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
Expand Down Expand Up @@ -177,7 +182,8 @@ abstract class VoicesLocalizations {
String get comingSoonDescription;
}

class _VoicesLocalizationsDelegate extends LocalizationsDelegate<VoicesLocalizations> {
class _VoicesLocalizationsDelegate
extends LocalizationsDelegate<VoicesLocalizations> {
const _VoicesLocalizationsDelegate();

@override
Expand All @@ -186,25 +192,27 @@ class _VoicesLocalizationsDelegate extends LocalizationsDelegate<VoicesLocalizat
}

@override
bool isSupported(Locale locale) => <String>['en', 'es'].contains(locale.languageCode);
bool isSupported(Locale locale) =>
<String>['en', 'es'].contains(locale.languageCode);

@override
bool shouldReload(_VoicesLocalizationsDelegate old) => false;
}

Future<VoicesLocalizations> lookupVoicesLocalizations(Locale locale) {


// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en': return catalyst_voices_localizations_en.loadLibrary().then((dynamic _) => catalyst_voices_localizations_en.VoicesLocalizationsEn());
case 'es': return catalyst_voices_localizations_es.loadLibrary().then((dynamic _) => catalyst_voices_localizations_es.VoicesLocalizationsEs());
case 'en':
return catalyst_voices_localizations_en.loadLibrary().then((dynamic _) =>
catalyst_voices_localizations_en.VoicesLocalizationsEn());
case 'es':
return catalyst_voices_localizations_es.loadLibrary().then((dynamic _) =>
catalyst_voices_localizations_es.VoicesLocalizationsEs());
}

throw FlutterError(
'VoicesLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.'
);
'VoicesLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ class VoicesLocalizationsEn extends VoicesLocalizations {
String get comingSoonTitle2 => 'soon';

@override
String get comingSoonDescription => 'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
String get comingSoonDescription =>
'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class VoicesLocalizationsEs extends VoicesLocalizations {
String get passwordHintText => 'Mi1ContraseñaSecreta';

@override
String get passwordErrorText => 'La contraseña debe tener al menos 8 caracteres';
String get passwordErrorText =>
'La contraseña debe tener al menos 8 caracteres';

@override
String get loginTitleText => 'Acceso';
Expand All @@ -44,5 +45,6 @@ class VoicesLocalizationsEs extends VoicesLocalizations {
String get comingSoonTitle2 => 'soon';

@override
String get comingSoonDescription => 'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
String get comingSoonDescription =>
'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'dart:async';

import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:catalyst_voices_services/generated/catalyst_gateway/cat_gateway_api.enums.swagger.dart' as enums;
import 'package:catalyst_voices_services/generated/catalyst_gateway/cat_gateway_api.enums.swagger.dart'
as enums;
import 'package:catalyst_voices_services/generated/catalyst_gateway/cat_gateway_api.swagger.dart';
import 'package:chopper/chopper.dart';
import 'package:result_type/result_type.dart';
Expand All @@ -15,9 +16,9 @@ import 'package:result_type/result_type.dart';
// The repository uses, under the hood, the [CatGatewayApi] directly generated
// from backend OpenAPI specification.
//
// To use the repository is necessary to initialize it by specifying the API
// To use the repository is necessary to initialize it by specifying the API
// base URL:
//
//
// ```dart
// final repository = CatalystDataGatewayRepository(Uri.parse('https://example.org/api'));
// ```
Expand All @@ -28,7 +29,7 @@ import 'package:result_type/result_type.dart';
// ```dart
// final health_status = await repository.getHealthLive();
// ```
//
//
// fetch staked ADA by stake address:
//
// ```dart
Expand All @@ -48,11 +49,10 @@ final class CatalystDataGatewayRepository {
final CatGatewayApi _catGatewayApi;

CatalystDataGatewayRepository(
Uri baseUrl,
{CatGatewayApi? catGatewayApiInstance,}
)
: _catGatewayApi = catGatewayApiInstance ??
CatGatewayApi.create(baseUrl: baseUrl);
Uri baseUrl, {
CatGatewayApi? catGatewayApiInstance,
}) : _catGatewayApi =
catGatewayApiInstance ?? CatGatewayApi.create(baseUrl: baseUrl);

Future<Result<void, NetworkErrors>> getHealthStarted() async {
try {
Expand Down Expand Up @@ -120,10 +120,10 @@ final class CatalystDataGatewayRepository {
Result<void, NetworkErrors> _emptyBodyOrThrow(Response<dynamic> response) {
// `bodyOrThrow` from chopper can't be used when the body is empty (like in
// case the endpoint replies with 204) because it would throw an exception
// as a false positive.
// as a false positive.
if (response.isSuccessful) {
return Success(null);
}
throw ChopperHttpException(response);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,12 @@ void main() {
});

test('getCardanoSyncState success', () async {
const blockHash =
'0x0000000000000000000000000000000000000000000000000000000000000000';

final syncState = SyncState(
slotNumber: 5,
blockHash:
'0x0000000000000000000000000000000000000000000000000000000000000000',
blockHash: blockHash,
lastUpdated: DateTime.utc(1970),
);
final repository = setupRepository<SyncState>(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ final class CatalystPlatform {
static bool get isWindows => Platform.isWindows;

static Map<PlatformKey, bool> get identifiers => {
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ final class CatalystPlatform {
];
return mobileIdentifiers.any(userAgent.contains);
}

static Map<PlatformKey, bool> get identifiers => {
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};

const CatalystPlatform._();
}
Loading
Loading