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

Add format action #1405

Merged
merged 34 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a2f0917
add format action
denrase Apr 25, 2023
b815694
fix matrix
denrase Apr 25, 2023
b520e13
run correct pub get command
denrase Apr 25, 2023
c038c05
setup flutter
denrase Apr 25, 2023
e78d9df
correct relatice path to commit script
denrase Apr 25, 2023
20e9602
move script to correct folder
denrase Apr 25, 2023
54ffd1e
test flutter format
denrase Apr 25, 2023
30cc41b
Format & fix code
getsentry-bot Apr 25, 2023
b55912f
test fix in flutter package, test format & fix in dart package
denrase Apr 25, 2023
509b678
Format & fix code
getsentry-bot Apr 25, 2023
65b9ccf
Format & fix code
getsentry-bot Apr 25, 2023
a7ec068
Merge branch 'main' into feat/gh-format-action
denrase Apr 25, 2023
7d8f145
remove pub get and introduce format and fix issue in flutter package
denrase May 2, 2023
691cecf
Format & fix code
getsentry-bot May 2, 2023
b2b1f47
Merge branch 'main' into feat/gh-format-action
denrase May 2, 2023
a8e5ff8
Merge branch 'feat/gh-format-action' of github.com:getsentry/sentry-d…
denrase May 2, 2023
2e07839
restore imports
denrase May 2, 2023
23d98b1
run dart/flutter pub get before again
denrase May 2, 2023
b9b7326
introduce issues in file package & run fomat/fix
denrase May 2, 2023
82305c1
Format & fix code
getsentry-bot May 2, 2023
884cd0c
add dio pakcage and introduce issues there
denrase May 2, 2023
25f8282
Format & fix code
getsentry-bot May 2, 2023
fbd1702
introduce issue and run in sqflite
denrase May 2, 2023
21b58ac
run flutter pub get in sqflite
denrase May 2, 2023
cbcaaea
run flutter action
denrase May 2, 2023
03335b0
Format & fix code
getsentry-bot May 2, 2023
6b516f4
run in logging package and introduce issues
denrase May 2, 2023
c265f96
Format & fix code
getsentry-bot May 2, 2023
86c0225
Merge branch 'main' into feat/gh-format-action
denrase May 8, 2023
18a9068
move format fix and commit to analyze step
denrase May 8, 2023
788426f
introduce error
denrase May 8, 2023
6f8e7ba
Format & fix code
getsentry-bot May 8, 2023
3eaea3b
Merge branch 'main' into feat/gh-format-action
marandaneto May 9, 2023
4a24859
Merge branch 'main' into feat/gh-format-action
denrase May 9, 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
35 changes: 35 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: format code
on:
pull_request:

jobs:
format-code:
name: Format Code
runs-on: ubuntu-latest
strategy:
matrix:
package: [flutter, dart]
defaults:
run:
working-directory: ${{ matrix.package }}
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
if: ${{ matrix.package == 'dart' }}
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0
if: ${{ matrix.package == 'flutter' }}
denrase marked this conversation as resolved.
Show resolved Hide resolved

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

- name: format
run: dart format .
marandaneto marked this conversation as resolved.
Show resolved Hide resolved

- name: fix
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.
- name: Commit & Push
run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF
denrase marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 16 additions & 0 deletions scripts/commit-formatted-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail

GITHUB_BRANCH="${1}"

if [[ $(git status) == *"nothing to commit"* ]]; then
echo "Nothing to commit. All code formatted correctly."
else
echo "Formatted some code. Going to push the changes."
git config --global user.name 'Sentry Github Bot'
git config --global user.email 'bot+github-bot@sentry.io'
git fetch
git checkout ${GITHUB_BRANCH}
git commit -am "Format & fix code"
git push --set-upstream origin ${GITHUB_BRANCH}
fi