Skip to content

zensharp/tanuki

Repository files navigation

Tanuki

Use Tanuki in your GitLab CI/CD pipelines to:

GitLab CI/CD

The following is a typical GitLab CI/CD configuration using Tanuki:

Code Quality:
  image: ghcr.io/zensharp/tanuki
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script:
    - |
      # Obtain codequality.json here
      tanuki html codequality.json -o index.html --title "$CI_PROJECT_TITLE"
  artifacts:
    paths:
      - index.html
    expose_as: "Code Quality Report"
    reports:
      codequality: codequality.json

Run Unit Tests:
  image: ghcr.io/zensharp/tanuki
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script:
    - |
      # Obtain results.xml and cobertura.xml here
      tanuki transform results.xml -o junit.xml
      tanuki coverage cobertura.xml --multiplier 100
  coverage: '/Code coverage is: \d+\.\d+/'
  artifacts:
    reports:
      junit: junit.xml

After every merge request pipeline, the merge request will display:

  • Code coverage (i.e. Test coverage)
  • Code Quality HTML report (i.e. Code Quality Report)
  • Code Quality changes
  • Test summary

Merge Request UI

Click "Code Quality Report" to view the HTML report.

CLI

Transform Between Report Formats

# Unity Project Auditor JSON to Code Climate
tanuki transform report.json --codeclimate

# Unity Test Runner XML to JUnit
tanuki transform report.xml --junit

# or let Tanuki automatically determine the format
tanuki transform report.json
tanuki transform report.xml

# By default, Tanuki prints the result to STDOUT
# Use -o|--output to write to a file
tanuki transform report.json -o codeclimate.json
tanuki transform report.xml -o junit.xml

Edit a Code Climate Report

tanuki edit report.json [-o edited.json] [--location-prefix "src/Assets"] [--linter "Project Auditor"]

Combine Code Climate Reports

tanuki merge a.json b.json ... z.json [-o merged.json]

Generate a Static HTML Report

tanuki html report.json [-o index.html] [--base-url "https://docs.example.com"] [--title "My Code Quality Report"]

Print Code Coverage

tanuki coverage cobertura.xml [--multiplier 100.0]

# Output
Code coverage is: 0.897

Experimental Features

Trigger

Add a Tanukifile at .tanuki/Tanukifile. See this example

Then trigger the file with:

tanuki trigger

Delete entries

tanuki delete report.json --where ".path == ^Packages/"

Assert

tanuki assert report.json --none ".severity == Blocker"

Tanuki Query Language

Tanuki offers a simple syntax language for querying issues. For example:

Here are the available patterns (see also IssueFilterer.cs):

  • .body
  • .category
  • .check_name
  • .description
  • .fingerprint
  • .linter
  • .location.path
  • .severity

Advanced Configuration

Tanuki will search for a configuration file in the following order:

  1. ./.tanuki.yml
  2. ./.tanuki/tanuki.yml
  3. ./.config/tanuki.yml
  4. ~/.config/tanuki.yml

Add custom linters to the configuration file. When using tanuki html, the linters will get properly linked in the generated HTML.

linters:
  - name: Project Auditor
    url: https://docs.unity3d.com/Packages/com.unity.project-auditor@1.0/manual/index.html
  - name: Rubocop
    url: https://docs.rubocop.org

Development

Open in Gitpod

Acknowledgements

About

Transform, manipulate, and visualize Unity reports in GitLab CI/CD

Resources

License

Stars

Watchers

Forks

Packages