flutter-tizen / engine

The Flutter engine
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
6 stars 19 forks source link

[ci] Add the format step #243

Closed swift-kim closed 2 years ago

swift-kim commented 2 years ago

Currently code formatting check is automatically done by githooks when pushing a commit to a remote repository, but the process often takes too long so I'd like to be able to disable the hook.

This change makes the code verification be performed during CI runs so that a user can safely disable their hook locally. Note that it is not a good idea to add the step as a separate job or workflow because the formatter must be run after gclient sync to ensure its dependencies are properly fetched.

Contributes to https://github.com/flutter-tizen/engine/issues/239.

bbrto21 commented 2 years ago

I am suffering from format check failure when I push to my repository after working locally. Do you know any other way than deactivating the format checker?

swift-kim commented 2 years ago

@bbrto21 I posted a solution in M Chat on December 14, 2021. That will help you.

bbrto21 commented 2 years ago

@bbrto21 I posted a solution in M Chat on December 14, 2021. That will help you.

I think the situation you mentioned is a little different.

Starting clang-tidy checks.
Unhandled exception:
ProcessRunnerException: Running "git fetch origin main" in /home/boram/Work/f-project/engine/src/flutter exited with code 128
fatal: couldn't find remote ref main
:
fatal: couldn't find remote ref main

#0      ProcessRunner.runProcess (package:process_runner/src/process_runner.dart:279:7)
<asynchronous suspension>
#1      GitRepo._getChangedFiles (package:clang_tidy/src/git_repo.dart:38:7)
<asynchronous suspension>
#2      GitRepo.changedFiles (package:clang_tidy/src/git_repo.dart:27:23)
<asynchronous suspension>
#3      ClangTidy.run (package:clang_tidy/clang_tidy.dart:93:40)
<asynchronous suspension>
#4      PrePushCommand._runClangTidy (package:githooks/src/pre_push_command.dart:66:33)
<asynchronous suspension>
#5      PrePushCommand.run (package:githooks/src/pre_push_command.dart:27:7)
<asynchronous suspension>
#6      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#7      run (package:githooks/githooks.dart:50:30)
<asynchronous suspension>
#8      main (file:///home/boram/Work/f-project/engine/src/flutter/tools/githooks/bin/main.dart:12:17)
<asynchronous suspension>
error: failed to push some refs to 'git@github.com:bbrto21/engine.git'
swift-kim commented 2 years ago

@bbrto21 Ah, in that case, you will need to add https://github.com/flutter/engine.git as a remote repository (with name upstream) in your local repository:

git remote add upstream https://github.com/flutter/engine.git

The main branch of the upstream repository is referenced by format.dart when finding the merge-base.

bbrto21 commented 2 years ago
git remote add upstream https://github.com/flutter/engine.git

Great!! that is what I was looking for!

JSUYA commented 2 years ago

@bbrto21 Ah, in that case, you will need to add https://github.com/flutter/engine.git as a remote repository (with name upstream) in your local repository:

git remote add upstream https://github.com/flutter/engine.git

The main branch of the upstream repository is referenced by format.dart when finding the merge-base.

HI~ @swift-kim https://github.com/flutter-tizen/flutter-tizen/wiki/Building-the-engine-from-source#setting-up-the-build-environment This wiki guides the remote name of forked git (user's git) to "upstream".

git remote add upstream https://github.com/flutter/engine.git

It conflicts with this command. I think it would be better to change name

swift-kim commented 2 years ago

@JSUYA I think you missed this part in the guide:

In step 4, use "https://github.com/flutter/engine.git" as the value of "url".

My configuration looks like this (I use the git protocol for administration purpose, you have to use https):

$ git remote -v
origin  git@github.com:flutter-tizen/engine.git (fetch)
origin  git@github.com:flutter-tizen/engine.git (push)
swift   git@github.com:swift-kim/engine.git (fetch)
swift   git@github.com:swift-kim/engine.git (push)
upstream        https://github.com/flutter/engine.git (fetch)
upstream        https://github.com/flutter/engine.git (push)
JSUYA commented 2 years ago

@swift-kim Oh, I missed step 4. It's my mistake. Thank you for answering