# Robots: GitHub Actions

GitHub Action support is available in two different ways. There are some settings common to both:

- Annotations will be used to mark problems in the files for those plug-ins that support this feature and
  if `--linecomments` has `github` as a configured bug system (the default).
- Statuses will be added if the GitHub Token gives permission.

## Workflow Action

The Apache Yetus community makes available a built-in action that may be executed as part of a
standard GitHub Action workflow. The basic workflow file should look like this, changing [VERSION] to
either be a released version (or `main` to use the bleeding edge, untested, and potentially unstable release):

    ---
    name: Apache Yetus

    on: [push, pull_request]  # yamllint disable-line rule:truthy

    jobs:
      build:

        runs-on: ubuntu-latest

        steps:
          - name: checkout
            uses: actions/checkout@v2
            with:
              path: src
              fetch-depth: 0
          - name: Apache Yetus test-patch
            uses: apache/yetus-test-patch-action@[VERSION]
            with:
              basedir: ./src
              patchdir: ./out
              buildtool: nobuild
              githubtoken: ${{ secrets.GITHUB_TOKEN }}
          - name: Artifact output
            if: ${{ always() }}
            uses: actions/upload-artifact@v2
            with:
              name: apacheyetuspatchdir
              path: ${{ github.workspace }}/out

Currently, not all arguments and parameters that can be set on the `test-patch` command line are available to set via the workflow action.
Options currently supported are:

Option | Notes | Default | More Information
--- | --- | --- | ---
basedir | same as `--basedir` | NONE | Usage Introduction
blankseolignorefile | same as `--blanks-eol-ignore-file` | `.yetus/blanks-eol.txt` | blanks plug-in
blankstabsignorefile | same as `--blanks-tabs-ignore-file` | `.yetus/blanks-tabs.txt` | blanks plug-in
bufbasedir | same as `--buf-basedir` | `.` | buf plug-in
buildtool | same as `--build-tool` | `nobuild` | Build Tools
continuousimprovement | same as `--continuous-improvement` | true | Robots
excludes | same as `--excludes` | `.yetus/excludes.txt` | Usage Introduction
githubtoken | same as `--github-token` | NONE | GitHub plug-in
javahome | same as `--java-home` | `/usr/lib/jvm/java-11-openjdk-amd64` | Java-related plug-ins
patchdir | same as `--patch-dir` | NONE | Usage Introduction
pip | same as `--pylint-pip` | pip3 | pylint plug-in
plugins | same as `--plugins` | all,-asflicense,-author,-findbugs,-gitlabcilint,-shelldocs | Usage Introduction
project | same as `--project` | Auto-set based upon the repository name | Usage Introduction
pylint | same as `--pylint` | pylint3 | pylint plug-in
reapermode | same as `--reapermode` | kill | Advanced Usage
reviveconfig | same as `--revive-config` | `.revive.toml` | revive plug-in
testsfilter | same as `--tests-filter` | '' | Usage Introduction

Items marked NONE MUST be provided in the workflow yaml file.

Some options are hard-coded to make `test-patch` easier to use:

Argument | Value | More Information
--- | --- | ---
`--brief-report-file` | patchdir/brief.txt | briefreport plug-in
`--console-report-file` | patchdir/console.txt | QBT
`--html-report-file` | patchdir/report.html | htmlout plug-in
`--ignore-unknown-options` | true | Usage Introduction
`--junit-report-xml` | patchdir/junit-report.xml | junit plug-in
`--pylint-requirements` | true | pylint plug-in
`--report-unknown-options` | true | Usage Introduction

## Manual Configuration

Manual configuration is recommended if one needs significant customization over the test environment and `test-patch` flags.

TRIGGER: ${GITHUB_ACTIONS}=True

GitHub Actions support has only been tested on the ubuntu-latest image. It automatically configures `--patch-dir` to be `${GITHUB_WORKSAPCE}/yetus` if not previously set.

See also:

- Apache Yetus' workflow action source for lower level details on the workflow action implementation.
- Apache Yetus' source tree yetus.yaml for some tips and tricks.