Code Monkey home page Code Monkey logo

action-check-typescript's Introduction

typescript-action status

action-check-typescript

A Github action that compile ts files and display the errors found in whole codebase and in files changed in PR.

Used in production at Arhia

  • Automatically uses yarn or npm ci when lockfiles are present
  • Builds your PR, then run tsc to detect errors ๐Ÿ”
  • Compare ts errors in base branch and in PR branch to detect new errors (handle automatically line numbers offset) ๐Ÿ’ช
  • Doesn't upload anything or rely on centralized storage ๐Ÿ‘

Usage

action-check-typescript rely on two other actions (big thanks to the authors ! โค๏ธ) to :

  • Equip-Collaboration/diff-line-numbers : retrieve line numbers of added and removed lines in files changed
  • futuratrepadeira/changed-files : list files added, modified and deleted

Add a workflow (eg .github/workflows/check_ts.yml):

name: 'check-ts'
on:
  pull_request:
jobs:
  ts:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Get diff lines
        id: diff
        uses: Equip-Collaboration/[email protected]
        with:
          include: '["\\.ts$"]'
      - name: Detecting files changed
        id: files
        uses: umani/[email protected]
        with:
          repo-token: ${{ github.token }}
          pattern: '^.*\.ts$'
      - name: List files changed (you can remove this step, for monitoring only)
        run: |
          echo 'Files modified: ${{steps.files.outputs.files_updated}}'
          echo 'Files added: ${{steps.files.outputs.files_created}}'
          echo 'Files removed: ${{steps.files.outputs.files_deleted}}'
      - uses: Arhia/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          use-check: true
          check-fail-mode: added
          files-changed: ${{steps.files.outputs.files_updated}}
          files-added: ${{steps.files.outputs.files_created}}
          files-deleted: ${{steps.files.outputs.files_deleted}}
          line-numbers: ${{steps.diff.outputs.lineNumbers}}
          output-behaviour: both
          comment-behaviour: new

Customize the check

By default, this action doesn't perform a status check (aka pass/fail).

You need to set use-check on true to run a status check.

  use-check: true

How the check status is determined depends on the value of check-fail-mode

Value Behaviour
added Check fails if some errors are added in the files added/modified in the PR branch.
errors_in_pr Check fails if any errors are present in the files added/modified in the PR branch (even if already in base branche).
errors_in_code Check fails if any errors are present in the whole branch.

The output behaviour depends on the value of output-behaviour

Value Behaviour
comment Default, comments on the PR with the errors found for this run.
annotate Uses github line annotations with the errors found for this run.
both Does both of the above.

The comment behaviour depends on the value of comment-behaviour

Value Behaviour
new Default, adds a new comment for every run of the action.
edit Updates a previous run's comment, if one exists, otherwise creates a new comment.

Use a specific tsconfig file

By default, this actions uses tsconfig file located at './tsconfig.json'

You may want to use a different file for this action, in order to change tsc behaviour.
For example, if you use watch:true in your regular tsconfig file, you should disable watching mode.

In order to do this, you would create a specific tsconfig file (eg name tsconfig.check.ts) and setting accordingly the parameter ts-config-path :

  ts-config-path: './tsconfig.check.json'

action-check-typescript's People

Contributors

abenhamdine avatar dependabot[bot] avatar eralyne avatar t3chguy avatar bharathvaj-ganesan avatar josephluck avatar prodigysim avatar

Forkers

alchemyeng

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.