Skip to content

Commit 0006698

Browse files
denrasegetsentry-botmarandaneto
authored
Add format action (#1405)
Co-authored-by: Sentry Github Bot <[email protected]> Co-authored-by: Manoel Aranda Neto <[email protected]>
1 parent 0a23f98 commit 0006698

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.github/workflows/analyze.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
access_token: ${{ github.token }}
2525

2626
analyze:
27+
name: Format, fix & analyze Code
2728
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
2829
runs-on: ubuntu-latest
2930
timeout-minutes: 20
@@ -36,8 +37,17 @@ jobs:
3637
if: ${{ inputs.sdk == 'dart' }}
3738
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # [email protected]
3839
if: ${{ inputs.sdk == 'flutter' }}
40+
3941
- run: ${{ inputs.sdk }} pub get
40-
- run: ${{ inputs.sdk }} format --set-exit-if-changed ./
42+
43+
- run: dart format .
44+
45+
- run: dart fix --apply
46+
47+
# actions/checkout fetches only a single commit in a detached HEAD state. Therefore
48+
# we need to pass the current branch, otherwise we can't commit the changes.
49+
# GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
50+
- run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF
4151

4252
- name: dart analyze
4353
uses: invertase/github-action-dart-analyzer@cdd8652b05bf7ed08ffce30f425436780f869f13 # pin@v1

flutter/lib/src/binding_wrapper.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// ignore_for_file: invalid_use_of_internal_member
22

3+
import '../sentry_flutter.dart';
34
import 'package:flutter/widgets.dart';
45
import 'package:meta/meta.dart';
56

6-
import '../sentry_flutter.dart';
7-
87
/// The methods and properties are modelled after the the real binding class.
98
@experimental
109
class BindingWrapper {

scripts/commit-formatted-code.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
GITHUB_BRANCH="${1}"
5+
6+
if [[ $(git status) == *"nothing to commit"* ]]; then
7+
echo "Nothing to commit. All code formatted correctly."
8+
else
9+
echo "Formatted some code. Going to push the changes."
10+
git config --global user.name 'Sentry Github Bot'
11+
git config --global user.email '[email protected]'
12+
git fetch
13+
git checkout ${GITHUB_BRANCH}
14+
git commit -am "Format & fix code"
15+
git push --set-upstream origin ${GITHUB_BRANCH}
16+
fi

0 commit comments

Comments
 (0)