---
title: "Exakat in Github Action"
url: https://www.exakat.io/exakat-in-github-action/
date: 2020-09-09
modified: 2020-09-09
author: "dams"
description: "Exakat in Github Action Github Actions is way to automate your software development workflow on github. You can execute actions on your repositories at Github, and resolve issues before merging..."
categories:
  - "Company"
tags:
  - "Exakat"
  - "github"
  - "github actions"
  - "ignore_dirs"
  - "ignore_rules"
image: https://www.exakat.io/wp-content/uploads/2020/09/austinmini.320.jpg
word_count: 840
---

# Exakat in Github Action

# Exakat in Github Action

Github Actions is way to automate your software development workflow on [github](https://www.github.com/). You can execute actions on your repositories at Github, and resolve issues before merging new code. Exakat integrates smoothly in the Github ecosystem with a dedicated action and its configuration. Let' install Exakat in Github Action!

## Getting started

Exakat for Github is available on [Github Market place](https://github.com/marketplace?query=exakat) in the [Code Quality](https://github.com/marketplace?category=code-quality) and [Security](https://github.com/marketplace?category=sections) sections.

The installation process is as reduced as adding a new file to the repository.

- Navigate to your repository, as a github user with writing rights.
- Create a new file, with the button `Add file
`

#

- Call this file `.github/workflows/test.yml`. `.github` is a special folder for Github, and `workflows` is the folder dedicated to actions.
[![](https://www.exakat.io/wp-content/uploads/2020/09/GA-new-file-name.png)](https://www.exakat.io/wp-content/uploads/2020/09/GA-new-file-name.png)
- Fill the `test.yml` file with the following YAML code :

```
on: [push, pull_request]
name: Test
jobs:
exakat:
name: Scan with Exakat
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Exakat
- uses: docker://exakat/exakat-ga

```

#

The action is now configured to be automatically activated upon push and pull request actions. If you have a public repository, it will be free to use; if you have a private repository, it will be counted on your plan.

The steps mention a `action/checkout@v2` step, which clones the code into the Action environment, so that `exakat/exakat-ga` can audit it.

- Commit the configuration file to Github
[![](https://www.exakat.io/wp-content/uploads/2020/09/GA-edit-test-2-928x1024.png)](https://www.exakat.io/wp-content/uploads/2020/09/GA-edit-test-2.png)
- In the toolbar, you can find 'Actions' next to 'Pull Request'. There, you'll find the action being run. All run of the action will be listed there. You can click on the current action to see it running.

#

- All results from Exakat will be listed there when it is finished. Note that this page doesn't refresh automatically, so you have to click on `Test` or `Scan with Exakat` to see it being refreshed.[![](https://www.exakat.io/wp-content/uploads/2020/09/GA-run-finished-1024x499.png)](https://www.exakat.io/wp-content/uploads/2020/09/GA-run-finished.png)
- When the audit is done, the results are displayed as a text table : each block is a file, and each line has the line number, the description of the issue, and the rule short names.
- [![](https://www.exakat.io/wp-content/uploads/2020/09/githubActions-1.png)](https://www.exakat.io/wp-content/uploads/2020/09/githubActions-1.png)

 

 

 

```
-----------------------------------------------------------------------------------
line /thinkphp/library/think/controller/Rest.php
-----------------------------------------------------------------------------------
41 Static Methods Called From Object Classes/StaticMethodsCalledFromObject
42 Should Make Ternary Structures/ShouldMakeTernary
42 Uses Default Values Functions/UsesDefaultArguments
42 Wrong Type For Native PHP Function Php/WrongTypeForNativeFunction
50 Wrong Number Of Arguments Functions/WrongNumberOfArguments
77 Drop Else After Return Structures/DropElseAfterReturn
95 Wrong Type For Native PHP Function Php/WrongTypeForNativeFunction
132 Uses Default Values Functions/UsesDefaultArguments
-----------------------------------------------------------------------------------

```

For example, in the file `/thinkphp/library/think/controller/Rest.php`, on line 42, `Wrong Type For Native PHP Function` has been detected. The documentation for this rule is available at [Wrong Type For Native PHP Function](https://exakat.readthedocs.io/en/latest/Rules.html#wrong-type-for-native-php-function).

Congratulations! You have now configured Exakat to run on your repository. It will run immediately, and provide you with insight on the code.

## Configuring Exakat

It is possible to configure the Github Action and ignore rules and ignore directories

### Excluding rules

By default, Exakat on Github Actions runs the [CI-checks](https://exakat.readthedocs.io/en/latest/Rulesets.html#ci-checks) ruleset. This is a pre-defined set of 180 rules. This is only a small subset of the vast reference library of Exakat (over 750 analysis documented). It is nice for a first audit, and it may be too much for a daily usage, until those issues are under control.

Let say that '[Should Make Ternary](https://exakat.readthedocs.io/en/latest/Rules.html#should-make-ternary)' and '[Uses Default Values](https://exakat.readthedocs.io/en/latest/Rules.html#uses-default-values)` are too much for this repository. We can consider these problems later.

To omits those rules, we are going to configure Exakat Github Action with the short code, which are the third column in the results.

- Go to the previously created `.github/workflows/test.yml`
- Edit the test.yml file with the online editor
- Add the following lines at the end of the file, after the `use:' keyword : this is a parameter for this command. Make sure to use the valid YAML syntax

```

with:
ignore_rules: 'Structures/ShouldMakeTernary,Functions/UsesDefaultArguments'

```

- Commit the newly edited `test.yml` file
[![](https://www.exakat.io/wp-content/uploads/2020/09/GA-edit-commit.png)](https://www.exakat.io/wp-content/uploads/2020/09/GA-edit-commit.png)
- Go again in the Actions tab.
- Once the results are in, we now have fewer issues per files.
- [![](https://www.exakat.io/wp-content/uploads/2020/09/GA-run-2-1024x760.png)](https://www.exakat.io/wp-content/uploads/2020/09/GA-run-2.png)

The `ignore_rules` directive allows for fine-tuning the auditing system by choosing the exact rules that fit your workflow. Use it to ignore rules that are not valuable for you, focusing on the important ones.

### Excluding folders

By default, Exakat runs the audit on the whole repository. Yet, some folders may be excluded, such as `cache` or `test` folders. Here, the unit tests are in `/thinkphp/tests`. We'll use it to omit those files.

- Go to the previously created `.github/workflows/test.yml`
- Edit the test.yml file with the online editor
- Add the following lines at the end of the file, after the `ignore_rules:` keyword : this is a parameter for the `uses` command. Make sure to use the valid YAML syntax `ignore_dirs: '/thinkphp/tests'`
- Commit the newly edited `test.yml` file
- Go again in the Actions tab.
- Once the results are in, we now have fewer files

 

The `ignore_dirs` directive allows for fine-tuning the audited files. Use it to ignore files, to keep the audit quick and efficient.

## Good Audits

You are now all set to use Exakat on Github. It runs on every commit and PR, and you can now focus on the important rules to monitor your code. The complete [documentation](https://exakat.readthedocs.org/) for Exakat is available online.