Coder Social home page Coder Social logo

gh-tests-existence-check's Introduction

Tests existence check

Check added to ensure added/modified files have tests

Problem

Sometimes developers forget to write tests, which neglects the code quality.

Solution

It's fine, we only need a gentle reminder. This GitHub Action is checking that every added/modified code file also has a test.

Example: if foo.ts file is added/modified - foo.test.ts is also expected.

That should encourage developers to submit changes along with tests.

No-gos

The GH action is made as simple as possible, so that it may lack some setup flexibility.

For example, if you want to target multiple file extensions, you will need to add separate actions per extension.

Inputs

target-file-path-prefix

Required The code file path prefix to check. Example: src/

target-file-path-suffix

Required The code file path suffix (aka extension) to check. Example: .ts

test-file-path-prefix

Required The test file path prefix to check. Example: tests/

test-file-path-suffix

Required The test file path suffix to check. Example: .test.ts

error-message

The message in case test was not found. Example: :file does not have a corresponding :test test file

repo-token

Access token to authenticate on behalf of the GitHub App

repo-name

Repository name, in case you need to override it.

repo-owner

Repository owner, in case you need to override it.

pull-number

Pull request number to check, in case you need to override it.

Example usage

Option 1: Directory structure when having separate folders for source and tests:

|-- src/
|   |-- item.ts
|   `-- util/
|      `-- helper.ts
`-- test/
    |-- item.test.ts
    `-- util/
       `-- helper.test.ts

Workflow:

uses: mrded/gh-tests-existence-check@main
with:
  target-file-path-prefix: src/
  target-file-path-suffix: .ts
  test-file-path-prefix: test/ 
  test-file-path-suffix: .test.ts

Option 2: Directory structure when having both types of files in the same directory:

`-- src/
    |-- item.ts
    |-- item.test.ts
    `-- util/
        |-- helper.ts
        `-- helper.test.ts

Workflow:

uses: mrded/gh-tests-existence-check@main
with:
  target-file-path-prefix: src/
  target-file-path-suffix: .ts
  test-file-path-prefix: src/ 
  test-file-path-suffix: .test.ts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.