-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Update to use reusable flutter code quality action (#116)
- Loading branch information
1 parent
d9bfe19
commit b8b4827
Showing
9 changed files
with
6,354 additions
and
122 deletions.
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 |
---|---|---|
|
@@ -7,97 +7,16 @@ jobs: | |
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
- name: Get branch name | ||
id: branch-name | ||
uses: tj-actions/[email protected] | ||
- uses: subosito/flutter-action@v2 | ||
- name: Setup flutter | ||
run: flutter pub get | ||
- name: Format code | ||
id: format | ||
run: dart format . -l 120 | ||
- name: Apply linter auto-fixes | ||
id: lint | ||
run: dart fix --apply | ||
- name: Check for un-fixable issues | ||
id: fix | ||
run: | | ||
# Allows code to run after an error. | ||
set -e | ||
# Runs flutter analyze; saves output and if it fails. | ||
out="$(flutter analyze)" || failed='true' | ||
echo "$out" | ||
# Saves output to either success or failure variables. | ||
if [ "$failed" == "true" ]; then | ||
echo "FAILURE=true" >> $GITHUB_OUTPUT | ||
exit 1 | ||
fi | ||
- name: Run tests | ||
id: test | ||
run: | | ||
# Allows code to run after an error. | ||
set -e | ||
# Runs flutter test; saves output and if it fails. | ||
out=$(flutter test --coverage) || failed='true' | ||
echo "$out" | ||
# Saves output to either success or failure variables. | ||
if [ "$failed" == "true" ]; then | ||
echo "FAILURE=true" >> $GITHUB_OUTPUT | ||
exit 1 | ||
fi | ||
- name: Check for modified files | ||
id: git-check | ||
run: echo "modified=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_ENV | ||
- name: Update changes in GitHub repository | ||
if: env.modified == 'true' | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
git add -A | ||
git commit -m '[automated commit] lint format and import sort' | ||
git push | ||
- name: Print outputs | ||
if: always() | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
template='<h2>PR Checks complete</h2>✅ - Linting</br>' | ||
if [ -n "${{steps.fix.outputs.FAILURE}}" ]; then | ||
template="$template ⛔️ - Problems found in code. To replicate, run <code>dart fix</code></br>" | ||
else | ||
template="$template ✅ - No errors found in code</br>" | ||
fi | ||
if [ -n "${{steps.test.outputs.FAILURE}}" ]; then | ||
template="$template ⛔️ - Tests failed. To replicate, run <code>flutter test</code></br>" | ||
else | ||
template="$template ✅ - All tests passed</br>" | ||
fi | ||
# Add / amend comment on PR. | ||
gh pr comment ${{github.event.pull_request.number}} --body="${template}" --edit-last -R ${{github.repository}} || gh pr comment ${{github.event.pull_request.number}} --body="${template}" -R ${{github.repository}} || echo 'Token not working' | ||
# Concatenates failure outputs. | ||
fail="${{steps.fix.outputs.FAILURE}}${{steps.test.outputs.FAILURE}}" | ||
# Checks if there is any content in the failure variable. | ||
if [[ -z "$fail" ]]; | ||
then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
code-quality: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
ref: ${{ github.head_ref }} | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
cache: true | ||
- uses: ZebraDevs/flutter-code-quality@latest | ||
with: | ||
token: ${{secrets.GITHUB_TOKEN}} |
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
This file was deleted.
Oops, something went wrong.
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.