Skip to content

CQLabs/dcm-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

DCM Action

dcm-action runs DCM checks in GitHub Actions.

Note

This action requires write permissions for checks and pull-requests. For more information, refer to GitHub docs here and here.

Usage Example

name: DCM

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Dart and Flutter
        uses: subosito/flutter-action@v2

      - name: Install dependencies
        run: flutter pub get

      - name: Install DCM
        uses: CQLabs/setup-dcm@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Run DCM
        uses: CQLabs/dcm-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          ci-key: ${{ secrets.DCM_CI_KEY }}
          email: ${{ secrets.DCM_EMAIL }}
          analyze: true
          folders: lib

Warning

GitHub's working-directory option works only for run steps and has no effect when used with an action. You can find more info in GitHub docs.

Migrating from v1

If you are migrating from dcm-action@v1, replace all _ in the configuration option names with - (for example, github_token -> github-token). This change was made to make the github action options consistent with the CLI options.

Inputs

Note

If you have a DCM Open Source license, pass oss to both CI key and email inputs.

Name Required Description Default
github-token ☑️ Required to post a report on GitHub. Note: the secret GITHUB_TOKEN is already provided by GitHub and you don't have to set it up yourself.
github-pat 1 Personal access token. Must have access to repo and read:user scopes.
ci-key ☑️ The license CI/CD key.
email ☑️ The license email.
pull-request-comment Add a comment with a report overview to your pull requests. true
pull-request-comment-on-fail Add a comment with a report overview to your pull requests, but only when any DCM check fails. Note, when this option is enabled, pull-request-comment must be explicitly set to false. false
package-name Package name to differentiate the report. Set when running several DCM runs at once.
### General:
folders List of folders and files (comma separated) to scan. [lib]
exclude List of files to exclude (in Glob syntax). If passing more than 1 glob pattern, wrap the list of patters into {}. {**/*.g.dart, **/*.freezed.dart}
exclude-public-api Exclude publicly exported code from the analysis output. false
fatal-found Treat any found issue as fatal. true
fatal-level Treat equal or higher lint issues severity as fatal (unset by default).
### Commands:
analyze Run dcm analyze (docs). true
analyze-assets Run dcm analyze-assets (docs). Supports additional options listed below. false
analyze-widgets Run dcm analyze-widgets (docs). Supports additional options listed below. false
calculate-metrics Run dcm calculate-metrics (docs). false
check-code-duplication Run dcm check-code-duplication (docs). Supports additional options listed below. false
check-dependencies Run dcm check-dependencies (docs). Supports additional options listed below. false
check-exports-completeness Run dcm check-exports-completeness (docs). false
check-parameters Run dcm check-parameters (docs). Supports additional options listed below. false
check-unused-code Run dcm check-unused-code (docs). Supports additional options listed below. false
check-unused-files Run dcm check-unused-files (docs). false
check-unused-l10n Run dcm check-unused-l10n (docs). Supports additional options listed below. false
### Analyze Assets:
size Size limit for image assets (docs). Supported formats: 10KB, 1MB, 100B, etc. 500KB
webp Require converting .jpg and .png images to .webp (docs). false
naming Required naming convention for image assets (pascal, kebab or snake) (docs).
resolution Find missing or incorrect resolution-aware image assets (docs). true
allowed-formats List of allowed formats for particular folders (e.g. icons:svg,img:jpg) (docs).
### Analyze Widgets:
show-similarity Include similar widgets into the report (docs). false
similarity-threshold Set a minimum threshold after which widgets are considered similar. 0.2
### Check Code Duplication:
per-package Compare code for duplications only within one package (docs). false
exclude-overrides Exclude methods marked with @override (docs). false
statements-threshold Minimum number of lines for a duplication entry (docs). 3
entries-threshold Minimum number of duplication entries to report (since DCM 1.30.0). 1
### Check Dependencies:
ignored-packages Package names that should be ignored (docs).
### Check Parameters:
show-same-value Include parameters that always get the same constant argument (docs). false
show-unused-default-value Include parameters with default values that always get an argument (docs). false
show-redundant Include parameters whose values are always passed with another parameter (docs). false
show-unused-vft Include @visibleForTesting parameters that are never used in tests (docs). false
show-broad-types Include parameters whose types can be made more specific (docs). false
### Check Unused Code:
no-exclude-overridden Do not treat overridden members as always used (docs). false
### Check Unused L10n:
class-pattern Regular expression for class names to detect classes that provide localization (for example, ^AppLocalizations$). ^AppLocalizations$

License

See the LICENSE file.

Version History

Please see our CHANGELOG.md file.

Footnotes

  1. Required if you have a private GitHub repository in the package dependencies.

About

GitHub Action to run DCM checks

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •