Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Push PCPD results as check run annotations

License

Notifications You must be signed in to change notification settings

adore-me/pcpd-github-action

 
 

Repository files navigation

build-test

PCPD GitHub Action

This action pushes results from PCPD as check run annotations. 🚀

The report itself must be generated in a former build step.

example

Input

path

Required. A file, directory or wildcard pattern that describes where to find the reports. Multiple files can be processed through a glob expression, for example: '**/cpd.xml'.

name

Optional. Name for the check run to create. Defaults to CPD.

title

Optional. Title for the check run to create. Defaults to CPD Source Code Analyzer report.

token

Optional. GitHub API access token. Defaults to ${{ github.token }}, which is set by actions/checkout@v2 minimally.

Example usage

name: CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    # ...run copy paste detector
    - uses: mihaisee/pcpd-github-action@master
      with:
        path: '**/cpd.xml'

Please note that by default workflows on pull_request events checkout refs/pull/:prNumber/merge instead of the head of the pull request. Due to this, line numbers for the generated violations may not align with the actual line numbers to which they are displayed on the HEAD. As it is, there is not really a sensible way to run this action on the merge commit of the pull request, because the result would be posted to an unnamed workflow for an otherwise invisible commit. Even for pull_request events there is the possibility to checkout the pull request head instead. In order to do so, change your checkout action accordingly:

- uses: actions/checkout@v2
  with:
    ref: ${{ github.event.pull_request.head.sha }}

Other relevant actions

This is a Github Action in a series of other GitHub Actions. Similar actions include:

Known limitations

Due to GitHub API limitations, we cannot specify to which Workflow Run (or underlying Check Suite) a newly created Check Run should be associated. As a result, workflows that trigger on several types of events, might push results under another event than the action was run in. For more information, see: jwgmeligmeyling#4

Contributing

Install the dependencies:

$ npm install

Build the typescript and package it for distribution

$ npm run build && npm run package

Run the tests ✔️

$ npm test

 PASS  ./index.test.js
  ✓ throws invalid number (3ms)
  ✓ wait 500 ms (504ms)
  ✓ test runs (95ms)

...

About

Push PCPD results as check run annotations

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.1%
  • JavaScript 2.9%