Skip to content

Commit

Permalink
ci: check secrets (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Jun 18, 2024
1 parent 6394ef6 commit 638fe8f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 8 deletions.
70 changes: 67 additions & 3 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,54 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
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
run: flutter analyze
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
fi
- name: Run tests
run: cd example && flutter test
id: test
run: |
cd example
# Allows code to run after an error.
set -e
# Runs flutter test; saves output and if it fails.
out=$(flutter test) || failed='true'
echo "$out"
# Saves output to either success or failure variables.
if [ "$failed" == "true" ]; then
echo "FAILURE=true" >> $GITHUB_OUTPUT
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
Expand All @@ -36,3 +68,35 @@ jobs:
git add -A
git commit -m '[automated commit] lint format and import sort'
git push
- name: Print outputs
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_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
9 changes: 5 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CI - Pull Request
on:
pull_request:
pull_request_target:

jobs:
up-to-date:
Expand All @@ -17,9 +18,8 @@ jobs:
- name: Check PR can access secrets
id: check
run: |
if [ "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZETA_DS }}" != '' ]; then
echo "defined=true" >> $GITHUB_OUTPUT;
else
echo "defined=true" >> $GITHUB_OUTPUT;
if [ "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZETA_DS }}" == '' ]; then
echo "defined=false" >> $GITHUB_OUTPUT;
fi
Expand All @@ -31,6 +31,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
- uses: subosito/flutter-action@v2
- name: Setup flutter
Expand All @@ -42,5 +43,5 @@ jobs:
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ env.key }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZETA_DS }}"
channelId: "pr-${{ github.event.number }}-${{ github.event.pull_request.head.ref }}"
1 change: 1 addition & 0 deletions .github/workflows/up-to-date.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Check branch is up to date
id: check
run: exit $(gh api /repos/${{github.event.pull_request.head.repo.full_name}}/compare/${{github.event.pull_request.base.sha}}...${{github.event.pull_request.head.sha}} | jq .behind_by)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/progress/progress_circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ZetaProgressCircle extends ZetaProgress {
const ZetaProgressCircle({
super.key,
super.progress = 0,
super.rounded,
this.size = ZetaCircleSizes.xl,
super.rounded,
this.onCancel,
});

Expand Down

0 comments on commit 638fe8f

Please sign in to comment.