Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
92bb897
Release v1.0.0+14 (#12)
zgosalvez Jan 3, 2021
bce580d
Updates
zgosalvez Jan 3, 2021
790f885
Update README.md
zgosalvez Jan 3, 2021
eeb57b3
Update README.md
zgosalvez Jan 3, 2021
3c0af0b
Update CONTRIBUTING.md
zgosalvez Jan 3, 2021
f0ac0b4
Updates analyze action
zgosalvez Jan 4, 2021
637ed47
Minor updates and dependabot config
zgosalvez Jan 17, 2021
8f67a0b
Removes version comments
zgosalvez Jan 17, 2021
8f37680
Bump actions/download-artifact (#16)
dependabot[bot] Jan 17, 2021
a552e00
Bump release-drafter/release-drafter (#17)
dependabot[bot] Jan 17, 2021
b27cd67
Bump actions/upload-artifact (#18)
dependabot[bot] Jan 17, 2021
513bcbc
Secures PR workflow
zgosalvez Jan 17, 2021
ef1cb91
Bump zgosalvez/github-actions-ensure-sha-pinned-actions (#19)
dependabot[bot] Jan 17, 2021
478d50e
Update README.md
zgosalvez Jan 17, 2021
34c947a
Merge branch 'main' of https://github.com/zgosalvez/github-actions-fl…
zgosalvez Jan 17, 2021
d71d486
Update Lcov reporter (#20)
zgosalvez Jan 25, 2021
527602c
Update Report LCOV Action (#22)
zgosalvez Feb 4, 2021
ffab624
Bump actions/cache (#23)
dependabot[bot] Feb 5, 2021
9d86918
Bump release-drafter/release-drafter (#25)
dependabot[bot] Feb 18, 2021
7327102
Upgrade to flutter v2 (#26)
zgosalvez Mar 12, 2021
eed1a02
Bump release-drafter/release-drafter from e5ccf147077e46b0225a80bbe31…
dependabot[bot] Mar 17, 2021
fcb629b
Bump zgosalvez/github-actions-analyze-dart (#28)
dependabot[bot] Mar 18, 2021
2f69f5a
Bump actions/upload-artifact (#30)
dependabot[bot] Apr 8, 2021
0ac2393
Bump actions/download-artifact (#29)
dependabot[bot] Apr 8, 2021
9485731
Bump actions/cache (#31)
dependabot[bot] Apr 13, 2021
f9704e8
Bump zgosalvez/github-actions-analyze-dart from 1.5.1 to 1.5.2 (#35)
dependabot[bot] May 12, 2021
3a50bed
Bump zgosalvez/github-actions-get-flutter-version-env (#34)
dependabot[bot] May 12, 2021
61f00cd
Bump zgosalvez/github-actions-report-lcov from 1.3.0 to 1.3.1 (#33)
dependabot[bot] May 12, 2021
26b3e25
Bump zgosalvez/github-actions-ensure-sha-pinned-actions (#32)
dependabot[bot] May 12, 2021
09cb053
Bump actions/cache from 2.1.5 to 2.1.6 (#36)
dependabot[bot] Jun 7, 2021
d6c1694
Bump zgosalvez/github-actions-get-flutter-version-env (#41)
dependabot[bot] Jul 10, 2021
9f7cd4c
Bump zgosalvez/github-actions-report-lcov from 1.3.1 to 1.3.2 (#40)
dependabot[bot] Jul 10, 2021
5c11f35
Bump zgosalvez/github-actions-ensure-sha-pinned-actions (#42)
dependabot[bot] Jul 10, 2021
137b9bc
Bump zgosalvez/github-actions-analyze-dart from 1.5.2 to 1.5.3 (#39)
dependabot[bot] Jul 10, 2021
acec97d
Bump actions/upload-artifact from 2.2.3 to 2.2.4 (#38)
dependabot[bot] Jul 10, 2021
e1cabbf
Bump actions/download-artifact from 2.0.9 to 2.0.10 (#37)
dependabot[bot] Jul 10, 2021
97ed7d6
Recreate application (#132)
zgosalvez Apr 18, 2025
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
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners

* @zgosalvez
14 changes: 14 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Contributing

## Welcome
Thank you for contributing to this repository! :bow:

## Process
1. Create a branch with the following [supported](pr-labeler.yml) prefixes:
- `feature/` (i.e., enhancements)
- `hotfix/` (i.e., bug fixes)
2. Make changes
3. Create a PR to the `main` branch

### Release
Whenever a release is published, a PR should be made from `main` to the appropriate `release/v*` branch.
46 changes: 35 additions & 11 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,61 @@
# GitHub Actions: Flutter Workflows

This sample project allows you to leverage GitHub Actions to run common Flutter workflows. These are based on the workflows found in the [Flutter Gallery](https://github.com/flutter/gallery) repository.
This sample project allows you to leverage GitHub Actions to run common Flutter workflows. These are based on the workflows found in the [Flutter Gallery](https://github.com/flutter/gallery) repository. Continue reading to apply these to your Flutter project.

## Disclaimer
This is still in active development, and it currently supports iOS and Android deployments only. Please [open a pull request](CONTRIBUTING.md) to support other platforms.

## Usage

Create a workflow `.yml` file in your `.github/workflows` directory. Example workflows are available in this repository. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
Create workflows in your `.github/workflows` directory. Examples are available in this repository. For more information, see the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).

*Note:* Although this Flutter project works as-is, consider tailoring these workflows to your needs. If you're starting from scratch, copying and pasting will work as long as you follow the [GitHub flow](https://guides.github.com/introduction/flow/) and [release based workflow](https://lab.github.com/githubtraining/create-a-release-based-workflow).

## Workflows
### Protected Branches
Recommended rules for the `main` and `release/v*` branches:
- [x] Require status checks to pass before merging
- [x] Require branches to be up to date before merging
- [x] Check security hardening
- [x] Generate coverage report
- [x] Run static testing
- [x] Run unit testing
- [x] Run widget testing

All workflows use the [Ensure SHA Pinned Actions](https://github.com/marketplace/actions/ensure-sha-pinned-actions) action to ensure security hardening.
### Workflows

_Note:_ The [Get the Flutter Version Environment](https://github.com/marketplace/actions/get-the-flutter-version-environment) action requires that the [`pubspec.yaml`](pubspec.yaml) file contains an `environment:flutter:` key. This is used for installing Flutter in the workflows.
- All of the workflows here use the [Ensure SHA Pinned Actions](https://github.com/marketplace/actions/ensure-sha-pinned-actions) action to ensure security hardening.
- The [Get the Flutter Version Environment](https://github.com/marketplace/actions/get-the-flutter-version-environment) action requires that the [`pubspec.yaml`](../pubspec.yaml#L22) file contains an `environment:flutter:` key, which is used for installing Flutter with the correct version.

### Continuous Integration
#### Continuous Integration
[![CI](https://github.com/zgosalvez/github-actions-flutter-workflow/workflows/CI/badge.svg)](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ACI)

[`.github/workflows/ci.yml`](workflows/ci.yml)

Also known as CI, Continuous Integration runs Flutter static and dynamic tests on every pull request to `main`, then the coverage report is stored as an artifact for reference. Modify the workflow to further process the code coverage file using [code quality](https://github.com/marketplace?type=actions) or [code review](https://github.com/marketplace?category=code-review&type=actions) actions.
Also known as CI, Continuous Integration runs Flutter static and dynamic tests on *every pull request* to `main` and `release/v*`, then the coverage report is stored as an artifact for reference. A comment is added to the pull request on every run as seen here, [#10 (comment)](https://github.com/zgosalvez/github-actions-flutter-workflows/pull/10#issuecomment-753592566). Modify the workflow to further process the code coverage file using [code quality](https://github.com/marketplace?type=actions) or [code review](https://github.com/marketplace?category=code-review&type=actions) actions.

### Continuous Delivery
Testing is split into unit and widget tests. These are found in the `test/units` and `test/widgets` directories, respectively. The CI runs these in parallel to optimize for workflow throughput, especially on a large project with a considerable number of test cases.

#### Continuous Delivery
[![CDelivery](https://github.com/zgosalvez/github-actions-flutter-workflow/workflows/CDelivery/badge.svg)](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ACDelivery)

[`.github/workflows/cdelivery.yml`](workflows/cdelivery.yml)

Also known as CDelivery (not to be mistaken with another CD, Continuous Deployment), Continuous Delivery reruns the same Flutter static and dynamic tests from the CI on every push to `main`, then a pre-release draft is created. Manually, remove the pre-release mark after it has been deployed and released to the app store.
Also known as CDelivery (not to be mistaken with another CD, i.e., Continuous Deployment), Continuous Delivery drafts a pre-release on *every push* to `main`. For the draft to populate with the release notes, pull requests should be `main` based. Manually remove the pre-release mark after it has been deployed and released to the app store.

[`.github/workflows/pull_request-opened.yml`](workflows/pull_request-opened.yml)

### Deployment
To draft the release this workflow uses the [Release Drafter](https://github.com/marketplace/actions/release-drafter) action to compile the pull requests and categorizes it using the [PR Labeler](https://github.com/marketplace/actions/pr-labeler) action. Add the [`.github/release-drafter.yml`](release-drafter.yml) and [`.github/pr-labeler.yml`](pr-labeler.yml) files in your project since these are required configurations for these actions, respectively. Customize the configuration files as needed.

#### Deployment
[![Deployment](https://github.com/zgosalvez/github-actions-flutter-workflow/workflows/Deployment/badge.svg)](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ADeployment)

[`.github/workflows/deployment.yml`](workflows/deployment.yml)

Deployment is triggered when the release draft is published. It reruns the same Flutter static and dynamic tests from the CI before running Flutter's build commands. The app version used is based on the release tag, not the name. Lastly, build artifacts are uploaded as release assets.
Deployment is triggered when the release draft (or any release) is published. It reruns the same Flutter static and dynamic tests from the CI before running Flutter's build commands. The app version used is based on the release tag, not the name. Lastly, build artifacts are uploaded as release assets.

### Dependabot

This includes a [`.github/dependabot.yml`](dependabot.yml) file that allows Dependabot to maintain the GitHub Actions used in these workflows. For more information, see the GitHub Documentation for [Keeping your dependencies updated automatically](https://docs.github.com/en/github/administering-a-repository/keeping-your-dependencies-updated-automatically).

## License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
2 changes: 2 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enhancement: feature/*
bug: hotfix/*
74 changes: 5 additions & 69 deletions .github/workflows/cdelivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,84 +10,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@e70e07ef05f0a3bf1483fde3c50eeab9c1805041 # v1.0.1

testing:
name: Run ${{ matrix.category }} testing
needs: security_hardening
runs-on: ubuntu-latest
strategy:
matrix:
category: [static, unit, widget]
fail-fast: false
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
with:
path: code
- name: Get Flutter version
id: get-flutter-version
uses: zgosalvez/github-actions-get-flutter-version-env@2106839043b63948638cf22ee33718862fdcc57d # v1.1.2
with:
pubspec-file-path: code/pubspec.yaml
- name: Cache Flutter
id: flutter-cache
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a # v2.1.3
with:
path: flutter
key: ${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-${{ hashFiles('code/pubspec.lock') }}
restore-keys: |
${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-
${{ env.cache-name }}-ubuntu-latest-
${{ env.cache-name }}-
env:
cache-name: flutter-cache
- name: Clone the Flutter repository
if: steps.flutter-cache.outputs.cache-hit != 'true'
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
with:
repository: flutter/flutter
ref: ${{ steps.get-flutter-version.outputs.version }}
path: flutter
- name: Add the flutter tool to the path
run: |
echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH
- name: Populate the Flutter tool's cache of binary artifacts
if: steps.flutter-cache.outputs.cache-hit != 'true'
run: |
flutter config --no-analytics
flutter precache
- name: Get Flutter packages
run: flutter pub get
working-directory: code

# static testing
- name: Analyze Flutter
if: matrix.category == 'static'
uses: zgosalvez/github-actions-analyze-flutter@f5a4e9edfc655081eb438cf5901f1d48c9e5d281 # v1.3.2
with:
fail-on-warnings: true
working-directory: code

# unit testing
- name: Run Flutter ${{ matrix.category }} tests
if: matrix.category != 'static'
run: flutter test --no-pub test/${{ matrix.category }}s
working-directory: code
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@8877889a5717dad0b139f1d2925689aa68f88a43

draft_release:
name: Draft a release
needs: testing
needs: security_hardening
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Draft the release
id: release-drafter
uses: release-drafter/release-drafter@3782ccd1a495040818a9e5d0e8bc4ed22d3b1361 # v5.12.1
uses: release-drafter/release-drafter@fe52e97d262833ae07d05efaf1a239df3f1b5cd4
with:
prerelease: true
env:
Expand Down
35 changes: 17 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ name: CI

on:
pull_request:
branches: [ main ]
branches:
- main
- release/v*

jobs:
security_hardening:
name: Check security hardening
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@e70e07ef05f0a3bf1483fde3c50eeab9c1805041 # v1.0.1
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@8877889a5717dad0b139f1d2925689aa68f88a43

testing:
name: Run ${{ matrix.category }} testing
Expand All @@ -24,17 +26,17 @@ jobs:
fail-fast: false
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
path: code
- name: Get Flutter version
id: get-flutter-version
uses: zgosalvez/github-actions-get-flutter-version-env@2106839043b63948638cf22ee33718862fdcc57d # v1.1.2
uses: zgosalvez/github-actions-get-flutter-version-env@b5f12dbe2915d60c827758258d6193df1dacca1d
with:
pubspec-file-path: code/pubspec.yaml
- name: Cache Flutter
id: flutter-cache
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a # v2.1.3
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
with:
path: flutter
key: ${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-${{ hashFiles('code/pubspec.lock') }}
Expand All @@ -46,7 +48,7 @@ jobs:
cache-name: flutter-cache
- name: Clone the Flutter repository
if: steps.flutter-cache.outputs.cache-hit != 'true'
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
repository: flutter/flutter
ref: ${{ steps.get-flutter-version.outputs.version }}
Expand All @@ -63,25 +65,21 @@ jobs:
- name: Get Flutter packages
run: flutter pub get
working-directory: code

# static testing
- name: Analyze Flutter
if: matrix.category == 'static'
uses: zgosalvez/github-actions-analyze-flutter@f5a4e9edfc655081eb438cf5901f1d48c9e5d281 # v1.3.2
uses: zgosalvez/github-actions-analyze-dart@92375956021937d35938504eefb62b18bfebb154
with:
fail-on-warnings: true
working-directory: code

# unit testing
- name: Run Flutter ${{ matrix.category }} tests
if: matrix.category != 'static'
run: flutter test --no-pub --coverage --coverage-path=./coverage/lcov.${{ matrix.category }}.info test/${{ matrix.category }}s
working-directory: code
- name: Upload code coverage to GitHub
if: matrix.category != 'static'
uses: actions/upload-artifact@726a6dcd0199f578459862705eed35cda05af50b # v2.2.1
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: code-coverage
name: code-coverage-${{ matrix.category }}
path: code/coverage/lcov.${{ matrix.category }}.info

coverage_report:
Expand All @@ -90,14 +88,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Download code coverage from GitHub
uses: actions/download-artifact@f144d3c3916a86f4d6b11ff379d17a49d8f85dbc # v2.0.7
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: code-coverage
path: coverage
name: code-coverage-*
merge-multiple: true
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@dbddb87c1dcd9525e7ebb88700278d58ec7b2f9e # v1.1.0
uses: zgosalvez/github-actions-report-lcov@49af65b0586c274a625a41a2dc8aaaae7d00568b
with:
coverage-files: coverage/lcov.*.info
minimum-coverage: 90
Expand Down
Loading
Loading