Skip to content

An experimental GitHub Action intended to gather static metrics on terraform use in a codebase

License

Notifications You must be signed in to change notification settings

offgriddev/tf-metrics-action

Repository files navigation

Terraform Metric Collector (TMC)

TMC is a GitHub Action that performs static analysis on Terraform Code to do a simple count of several datapoints provided through the library @evops/hcl-terraform-parser. This parser provides the engine for analysis, and this action allows for aggregation of these through snapshots in CI that allow you to analyze your team's development through time.

How to Use

- name: Generate Code Metrics for Commit
  id: metrics
  uses: offgriddev/tf-metrics-action@main
  with:
    github_token: ${{ github.token }}
    event: ${{ toJson(github.event) }}

This action has one export: export_filename. This stores the filename for the report generated by the complexity reporter.

The action will produce a report that looks like this:

{
  "actor": "offgriddev",
  "sha": "b8824d770a1ba20c41329ab92bead39ec85f25ed",
  "ref": "refs/heads/main",
  "repository": {
    "owner": "offgriddev",
    "repo": "tf-metrics-action"
  },
  "files": [
    {
      "file": "./terraform/main.tf",
      "report": {
        "path": 9,
        "variables": 0,
        "outputs": 0,
        "required_providers": 0,
        "managed_resources": 2,
        "data_resources": 0,
        "module_calls": 0
      }
    },
    {
      "file": "./terraform/providers.tf",
      "report": {
        "path": 9,
        "variables": 0,
        "outputs": 0,
        "required_providers": 1,
        "provider_configs": 1,
        "managed_resources": 0,
        "data_resources": 0,
        "module_calls": 0
      }
    },
    {
      "file": "./terraform/variables.tf",
      "report": {
        "path": 9,
        "variables": 1,
        "outputs": 0,
        "required_providers": 0,
        "managed_resources": 0,
        "data_resources": 0,
        "module_calls": 0
      }
    }
  ],
  "dateUtc": "2023-11-08T23:30:03.837Z"
}

About

An experimental GitHub Action intended to gather static metrics on terraform use in a codebase

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published