-
Notifications
You must be signed in to change notification settings - Fork 37
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: break out smoke test goldens into directories based on flutter version #126
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
ac32272
feat: break smoke test goldens into dirs for each flutter version
btrautmann 93a0a75
add failures/**/*.png files to .gitignore
btrautmann 04c9d7e
update workflows
btrautmann 6bcefde
Disable fail-fast
btrautmann 3ca757b
correct fail-fast spec
btrautmann 96d7c0e
formatter
btrautmann 0ebd209
run pub get
btrautmann e02234e
fix input for update goldens workflow
btrautmann b05e713
chore: Updating Goldens
btrautmann 75dacfc
Re-run CI after updating goldens
btrautmann bce22e5
chore: Updating Goldens
btrautmann 65aa116
fix logic in test config
btrautmann 77a1ea8
Revert "chore: Updating Goldens"
btrautmann d0293b6
chore: Updating Goldens
btrautmann d1c6c37
Re-run CI after updating goldens
btrautmann 3d1543a
debug logging
btrautmann b9bcf5d
remove scaffold from test
btrautmann ac1d7cb
use Scaffold with white background
btrautmann 50d9edb
delete 3.22.3 goldens for now
btrautmann 3dfc88d
chore: Updating Goldens
btrautmann 1e3f231
Merge branch 'bt/flutter-version-dirs' of https://github.com/Betterme…
btrautmann 748a889
chore: Updating Goldens
btrautmann a69fd05
Re-run CI after updating goldens
btrautmann 6ae9b0b
delete old goldens dirs
btrautmann e8eedc8
update interactions smoke test colors
btrautmann b8ba873
chore: Updating Goldens
btrautmann f12c9c4
Re-run CI after updating goldens
btrautmann e3be414
more colors
btrautmann 32f33be
chore: Updating Goldens
btrautmann 6fd9a3c
Re-run CI after updating goldens
btrautmann 574506b
formatter
btrautmann 1d0fa87
clean up logic
btrautmann d6fe44c
use Jays process.run logic
btrautmann 2d6dd9f
one last change, do not run directories code on every file path resol…
btrautmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,19 @@ name: alchemist | |
|
||
on: [pull_request] | ||
|
||
env: | ||
FLUTTER_VERSION: 3.16.0 | ||
|
||
jobs: | ||
build: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: '3.16.0' | ||
flutter-version: ${{ env.FLUTTER_VERSION }} | ||
channel: 'stable' | ||
cache: true | ||
|
||
|
@@ -24,20 +27,40 @@ jobs: | |
- name: Analyze project source | ||
uses: invertase/github-action-dart-analyzer@v1 | ||
|
||
- uses: codecov/codecov-action@v2 | ||
with: | ||
files: coverage/lcov.info | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
flutter-version: ['3.16.9', '3.19.6', '3.22.3', '3.24.3'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test against all supported versions of flutter, up to latest stable version. This will take some manual work to keep this up to date; I'll noodle on how to make this more dynamic as a follow-up. |
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ matrix.flutter-version }} | ||
channel: 'stable' | ||
cache: true | ||
|
||
- name: Install Dependencies | ||
run: flutter packages get | ||
|
||
- name: Run tests | ||
run: flutter test --no-pub --coverage --test-randomize-ordering-seed=random | ||
|
||
- name: Upload failures | ||
if: failure() | ||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | ||
with: | ||
name: "golden_failures" | ||
name: "golden_failures_${{ matrix.flutter-version }}" | ||
path: | | ||
**/failures/**/*.png | ||
|
||
|
||
- uses: codecov/codecov-action@v2 | ||
with: | ||
files: coverage/lcov.info | ||
|
||
pana: | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Alchemist | ||
|
||
**/failures/**/*.png | ||
|
||
# Miscellaneous | ||
*.class | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,140 @@ | ||
import 'dart:async'; | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:alchemist/alchemist.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:path/path.dart' as path; | ||
import 'package:version/version.dart'; | ||
|
||
Future<void> testExecutable(FutureOr<void> Function() testMain) async { | ||
final enablePlatformTests = | ||
!Platform.environment.containsKey('GITHUB_ACTIONS'); | ||
final runningOnCi = Platform.environment.containsKey('GITHUB_ACTIONS'); | ||
|
||
// Grab the flutter version from the current environment. | ||
final versionResult = await Process.run( | ||
'flutter', | ||
['--version', '--machine'], | ||
); | ||
|
||
if (versionResult.exitCode != 0) { | ||
throw const ProcessException( | ||
'flutter', | ||
['--version', '--machine'], | ||
'Failed to get flutter version', | ||
); | ||
} | ||
|
||
final versionJson = versionResult.stdout.toString().trim(); | ||
final flutterData = json.decode(versionJson) as Map<String, dynamic>; | ||
final version = flutterData['flutterVersion'] as String; | ||
|
||
if (!version.isValidVersion()) { | ||
throw ProcessException( | ||
'flutter', | ||
['--version', '--machine'], | ||
'Invalid flutter version returned by `flutter version`: $version', | ||
); | ||
} | ||
|
||
final parsedVersion = Version.parse(version); | ||
final subDirectories = Directory( | ||
path.join( | ||
Directory.current.path, | ||
'test', | ||
'smoke_tests', | ||
'goldens', | ||
), | ||
).listSync().whereType<Directory>().toList(); | ||
|
||
final candidates = subDirectories.where((dir) { | ||
try { | ||
final dirVersion = Version.parse(path.basename(dir.path)); | ||
return dirVersion <= parsedVersion; | ||
} on FormatException { | ||
return false; | ||
} | ||
}); | ||
|
||
/// Returns the goldens directory for the provided flutter version. | ||
/// | ||
/// In order, this attempts to find: | ||
/// - A directory that matches the provided flutter version exactly. | ||
/// - If no exact match is found, the highest version directory that is less | ||
/// than or equal to the provided flutter version. | ||
/// - If no directories are found, an error is thrown. | ||
/// | ||
/// If `autoUpdateGoldenFiles` is true (meaning we've passed | ||
/// --update-goldens), a directory matching the provided flutter version will | ||
/// be created if it does not already exist. | ||
/// | ||
/// Doing this supports running our smoke tests against specific versions of | ||
/// Flutter, allowing us to maintain goldens for each version when necessary. | ||
Directory goldensDirectory() { | ||
// If we're updating golden files, always return the associated directory. | ||
if (autoUpdateGoldenFiles) { | ||
return Directory(path.join('goldens', parsedVersion.toString())); | ||
} | ||
|
||
if (candidates.isEmpty) { | ||
throw ArgumentError( | ||
'No valid directories found in `goldens` for the current ' | ||
'flutter version: $parsedVersion', | ||
); | ||
} | ||
|
||
// If we have multiple candidates, we want to find the highest version | ||
// directory that is less than or equal to the provided flutter version. | ||
return candidates.reduce((a, b) { | ||
final aVersion = Version.parse(path.basename(a.path)); | ||
final bVersion = Version.parse(path.basename(b.path)); | ||
return aVersion > bVersion ? a : b; | ||
}); | ||
} | ||
|
||
final directory = goldensDirectory(); | ||
|
||
Future<String> filePathResolver( | ||
String fileName, | ||
String environmentName, | ||
) async { | ||
return path.join( | ||
directory.path, | ||
environmentName.toLowerCase(), | ||
'$fileName.png', | ||
); | ||
} | ||
|
||
return AlchemistConfig.runWithConfig( | ||
config: AlchemistConfig( | ||
theme: ThemeData( | ||
useMaterial3: false, | ||
textTheme: const TextTheme().apply(fontFamily: 'Roboto'), | ||
), | ||
platformGoldensConfig: | ||
AlchemistConfig.current().platformGoldensConfig.copyWith( | ||
enabled: enablePlatformTests, | ||
), | ||
ciGoldensConfig: AlchemistConfig.current() | ||
.ciGoldensConfig // | ||
.copyWith( | ||
filePathResolver: filePathResolver, | ||
enabled: runningOnCi, | ||
), | ||
platformGoldensConfig: AlchemistConfig.current() | ||
.platformGoldensConfig // | ||
.copyWith( | ||
filePathResolver: filePathResolver, | ||
enabled: !runningOnCi, | ||
), | ||
), | ||
run: testMain, | ||
); | ||
} | ||
|
||
extension on String { | ||
bool isValidVersion() { | ||
try { | ||
Version.parse(this); | ||
return true; | ||
} on FormatException { | ||
return false; | ||
} | ||
} | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+1.23 KB
test/smoke_tests/goldens/3.16.0/ci/interactions_smoke_test_long_pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.54 KB
test/smoke_tests/goldens/3.16.0/ci/interactions_smoke_test_pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.23 KB
test/smoke_tests/goldens/3.16.0/ci/interactions_smoke_test_regular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed
BIN
-1.19 KB
test/smoke_tests/goldens/ci/interactions_smoke_test_long_pressed.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll analyze against the lowest version we support. This means that contributors should be using that version (
fvm
is helpful here). We can/should probably add something that details that in our CONTRIBUTING.md.