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

Introduce workflow dispatch action forformat & fix --apply #1575

Merged
merged 28 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
616aa76
Revert to check & fail only approach for format & analyze
denrase Jul 31, 2023
72e9520
seperate job to run fomrat and fix
denrase Aug 14, 2023
76cee35
Merge branch 'main' into chore/format-and-analyze-check-only
denrase Aug 14, 2023
93ae771
rename file
denrase Aug 14, 2023
046e029
run workflow file once
denrase Aug 14, 2023
3782d61
update how workflow is run
denrase Aug 14, 2023
7bfeb23
run fix/apply in all packages
denrase Aug 14, 2023
d1e4030
fix workflow
denrase Aug 14, 2023
4859923
run in root dir
denrase Aug 14, 2023
9558cfb
update path
denrase Aug 14, 2023
cb0a512
extract branch name
denrase Aug 14, 2023
7aef82c
Format & fix code
getsentry-bot Aug 14, 2023
fc0be25
revert changes
denrase Aug 14, 2023
1c6f8aa
setup flutter
denrase Aug 14, 2023
9b8d4f4
don’t commit
denrase Aug 14, 2023
777880f
run pin package directories
denrase Aug 14, 2023
85f656b
add strategy
denrase Aug 14, 2023
5ca84a6
only run on workflow dispatch
denrase Aug 14, 2023
149a2e9
Merge branch 'main' into chore/format-and-analyze-check-only
denrase Aug 22, 2023
8ac5c4d
Merge branch 'main' into chore/format-and-analyze-check-only
denrase Aug 29, 2023
43b2ba7
run `dart fix --apply`
denrase Aug 29, 2023
09cc913
Merge branch 'main' into chore/format-and-analyze-check-only
denrase Sep 4, 2023
1872854
run fix & format
denrase Sep 4, 2023
2b40bb6
Merge branch 'main' into chore/format-and-analyze-check-only
denrase Sep 4, 2023
3686698
Use ios sim 16.4
denrase Sep 5, 2023
7e5ba02
Merge branch 'main' into chore/format-and-analyze-check-only
denrase Sep 5, 2023
2b3c979
Merge branch 'main' into chore/format-and-analyze-check-only
denrase Sep 11, 2023
1087024
format & fix
denrase Sep 11, 2023
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
14 changes: 2 additions & 12 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
access_token: ${{ github.token }}

analyze:
name: Format, fix & analyze Code
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
runs-on: ubuntu-latest
timeout-minutes: 20
Expand All @@ -39,17 +38,8 @@ jobs:
if: ${{ inputs.sdk == 'flutter' }}

- run: ${{ inputs.sdk }} pub get

- run: dart format .

- run: dart fix --apply

# actions/checkout fetches only a single commit in a detached HEAD state. Therefore
# we need to pass the current branch, otherwise we can't commit the changes.
# GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
- run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF
if: env.GITHUB_HEAD_REF != null

- run: dart format --set-exit-if-changed ./
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand why this is needed if the formatting workflow is now separated

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail the workflow of there are formatting issues. If that happens, we can trigger the formatting workflow to resolve the issues.


- name: dart analyze
uses: invertase/github-action-dart-analyzer@1cda5922c6369263b1c7e2fbe281f69704f4d63e # pin@v2.0.0
with:
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/format-and-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
on:
workflow_dispatch:

jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # pin@0.11.0
with:
access_token: ${{ github.token }}

format-and-fix:
name: Format & fix code
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
package: [
{name: dart, sdk: dart},
{name: dio, sdk: dart},
{name: file, sdk: dart},
{name: flutter, sdk: flutter},
{name: logging, sdk: dart},
{name: sqflite, sdk: flutter},
]
defaults:
run:
working-directory: ${{ matrix.package.name }}
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
if: ${{ matrix.package.sdk == 'dart' }}
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0
if: ${{ matrix.package.sdk == 'flutter' }}

- run: ${{ matrix.package.sdk }} pub get

- run: dart format .

- run: dart fix --apply

# Source: https://stackoverflow.com/a/58035262
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

# actions/checkout fetches only a single commit in a detached HEAD state. Therefore
# we need to pass the current branch, otherwise we can't commit the changes.
# GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
- name: Commit & push
run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }}
Comment on lines +50 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be replaced by @denrase https://github.com/stefanzweifel/git-auto-commit-action
maybe it also solves that issue we had before

24 changes: 12 additions & 12 deletions dio/test/dio_event_processor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -96,7 +96,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -125,7 +125,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -177,7 +177,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -207,7 +207,7 @@ void main() {
data: 'foobar',
headers: Headers.fromMap(<String, List<String>>{
'foo': ['bar'],
'set-cookie': ['foo=bar']
'set-cookie': ['foo=bar'],
}),
requestOptions: request,
isRedirect: true,
Expand All @@ -219,7 +219,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -248,7 +248,7 @@ void main() {
response: Response<dynamic>(
data: 'foobar',
headers: Headers.fromMap(<String, List<String>>{
'foo': ['bar']
'foo': ['bar'],
}),
requestOptions: request,
isRedirect: true,
Expand All @@ -260,7 +260,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -320,7 +320,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand All @@ -338,7 +338,7 @@ void main() {
final dataByType = {
ResponseType.plain: ['plain'],
ResponseType.bytes: [
[1337]
[1337],
],
ResponseType.json: [
9001,
Expand All @@ -347,7 +347,7 @@ void main() {
true,
['list'],
{'map-key': 'map-value'},
]
],
};

for (final entry in dataByType.entries) {
Expand Down Expand Up @@ -375,7 +375,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down
2 changes: 1 addition & 1 deletion dio/test/failed_request_interceptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Fixture {

FailedRequestInterceptor getSut({
List<SentryStatusCode> failedRequestStatusCodes = const [
SentryStatusCode.defaultRange()
SentryStatusCode.defaultRange(),
],
List<String> failedRequestTargets = const ['.*'],
}) {
Expand Down
2 changes: 1 addition & 1 deletion dio/test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final fakeEvent = SentryEvent(
type: 'navigation',
data: <String, dynamic>{'screen': 'MainActivity', 'state': 'created'},
level: SentryLevel.info,
)
),
],
contexts: Contexts(
operatingSystem: const SentryOperatingSystem(
Expand Down
1 change: 1 addition & 0 deletions flutter/test/sentry_navigator_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ class _MockHub extends MockHub {
@override
final options = SentryOptions(dsn: fakeDsn);

@override
late final scope = Scope(options);

@override
Expand Down
15 changes: 11 additions & 4 deletions sqflite/lib/src/sentry_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ class SentryDatabase extends SentryDatabaseExecutor implements Database {
@internal Hub? hub,
}) : _hub = hub ?? HubAdapter(),
dbName = p.basenameWithoutExtension(_database.path),
super(_database,
hub: hub, dbName: p.basenameWithoutExtension(_database.path)) {
super(
_database,
hub: hub,
dbName: p.basenameWithoutExtension(_database.path),
) {
// ignore: invalid_use_of_internal_member
final options = _hub.options;
options.sdk.addIntegration('SentrySqfliteTracing');
Expand Down Expand Up @@ -132,8 +135,12 @@ class SentryDatabase extends SentryDatabaseExecutor implements Database {
setDatabaseAttributeData(span, dbName);

Future<T> newAction(Transaction txn) async {
final executor = SentryDatabaseExecutor(txn,
parentSpan: span, hub: _hub, dbName: dbName);
final executor = SentryDatabaseExecutor(
txn,
parentSpan: span,
hub: _hub,
dbName: dbName,
);
final sentrySqfliteTransaction =
SentrySqfliteTransaction(executor, hub: _hub, dbName: dbName);

Expand Down
3 changes: 2 additions & 1 deletion sqflite/test/mocks/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ISentrySpan startTransactionShim(
],
customMocks: [
MockSpec<Hub>(
fallbackGenerators: {#startTransaction: startTransactionShim}),
fallbackGenerators: {#startTransaction: startTransactionShim},
),
],
)
void main() {}
8 changes: 6 additions & 2 deletions sqflite/test/sentry_batch_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ SELECT * FROM Product''';
final span = fixture.tracer.children.last;
expect(span.data[SentryDatabase.dbSystemKey], SentryDatabase.dbSystem);
expect(
span.data[SentryDatabase.dbNameKey], (db as SentryDatabase).dbName);
span.data[SentryDatabase.dbNameKey],
(db as SentryDatabase).dbName,
);

await db.close();
});
Expand All @@ -313,7 +315,9 @@ SELECT * FROM Product''';
final span = fixture.tracer.children.last;
expect(span.data[SentryDatabase.dbSystemKey], SentryDatabase.dbSystem);
expect(
span.data[SentryDatabase.dbNameKey], (db as SentryDatabase).dbName);
span.data[SentryDatabase.dbNameKey],
(db as SentryDatabase).dbName,
);

await db.close();
});
Expand Down
4 changes: 3 additions & 1 deletion sqflite/test/sentry_database_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ void main() {
expect(insertSpan.context.parentSpanId, trSpan.context.spanId);
expect(insertSpan.status, SpanStatus.ok());
expect(
insertSpan.data[SentryDatabase.dbSystemKey], SentryDatabase.dbSystem);
insertSpan.data[SentryDatabase.dbSystemKey],
SentryDatabase.dbSystem,
);
expect(insertSpan.data[SentryDatabase.dbNameKey], inMemoryDatabasePath);

expect(
Expand Down