Dart/Flutter package analyzer
This action uses the pana (Package ANAlysis) package to compute the score that your Dart or Flutter package will have on the Pub site.
This package, amongst other things:
- validates the code by performing static analysis with dartanalyzer,
- checks code formatting with
dartfmt
orflutter format
(detected automatically), - checks for outdated dependencies,
- validates the
pubspec.yaml
file (dependencies, description’s length…), - checks for required files (
CHANGELOG
,README
,example
folder…) - …
The pana package gives scores in five categories and sum them up to get your total score.
Usage
You must include the actions/checkout
step in your workflow. You don’t need to run pub get
or build a Dart container before.
This action uses its own Dart container. I recommend you to run it in a separate job, as jobs run in parallel.
Inputs
githubToken
Required to post a report on GitHub. Note: the secretGITHUB_TOKEN
is already provided by GitHub and you don’t have to set it up yourself.relativePath
If your package isn’t at the root of the repository, set this input to indicate its location.
Example:
name: Example workflow on: [push, pull_request] jobs: package-analysis: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 # required - uses: axel-op/dart-package-analyzer@v3 with: # Required: githubToken: ${{ secrets.GITHUB_TOKEN }} # Optional: relativePath: packages/mypackage/
Outputs
There is an output for each of the six categories that are evaluated by the pana package, whose value is the score obtained by your package, plus an output for the total score of your package.
For each of these outputs, there is also a ..._max
output corresponding to the maximum score that a package can have in the category.
There is also an output containing the full pana
output in JSON format if you need to parse it yourself.
You can use the outputs in the next steps of your workfow by associating an id to this action. In the following steps, you can retrieve an output with ${{ steps.the_id.outputs.name_of_output }}
(see the example below).
total
&total_max
The total score of your package, and the maximum score that it can get.conventions
&conventions_max
Score for the category Follow Dart file conventions.documentation
&documentation_max
Score for the category Provide documentation.platforms
&platforms_max
Score for the category Support multiple platforms.analysis
&analysis_max
Score for the category Pass static analysis.dependencies
&dependencies_max
Score for the category Support up-to-date dependencies.null_safety
&null_safety_max
Score for the category Support null-safety.json_output
Thepana
output in JSON format.
Usage example
name: Example workflow on: [push, pull_request] jobs: package-analysis: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: axel-op/dart-package-analyzer@v3 # set an id for the current step id: analysis with: githubToken: ${{ secrets.GITHUB_TOKEN }} # You can then use this id to retrieve the outputs in the next steps. # The following step shows how to exit the workflow with an error if the total score in percentage is below 50: - name: Check scores env: # NB: "analysis" is the id set above. Replace it with the one you used if different. TOTAL: ${{ steps.analysis.outputs.total }} TOTAL_MAX: ${{ steps.analysis.outputs.total_max }} run: | PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX )) if (( $PERCENTAGE < 50 )) then echo Score too low! exit 1 fi
Example
Dart/Flutter package analyzer source code on GitHub
Provides the list of the opensource Flutter apps collection with GitHub repository.