├── .github ├── FUNDING.yml ├── dependabot.yml ├── labels.json └── workflows │ ├── depup.yml │ ├── issues_prs_labeler.yml │ ├── labels.yml │ ├── release.yml │ ├── reviewdog.yml │ ├── stale.yml │ ├── test.yml │ └── thread_locker.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── action.yml ├── script.sh └── testdata ├── failing ├── src │ └── index.ts └── tsconfig.json ├── package-lock.json ├── package.json ├── passing ├── src │ └── index.ts └── tsconfig.json └── tsconfig.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # Want to support the project? Donate here! 2 | custom: https://www.buymeacoffee.com/epmatt -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: 'github-actions' 4 | directory: '/' 5 | schedule: 6 | interval: 'daily' 7 | commit-message: 8 | prefix: 'github-actions' 9 | open-pull-requests-limit: 10 10 | - package-ecosystem: 'npm' 11 | directory: '/testdata' 12 | schedule: 13 | interval: 'daily' 14 | commit-message: 15 | prefix: 'npm-testdata' 16 | open-pull-requests-limit: 10 17 | -------------------------------------------------------------------------------- /.github/labels.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "bump:major", 4 | "color": "ef6bb4", 5 | "description": "Attach to PR to automatically bump major version on merge" 6 | }, 7 | { 8 | "name": "bump:minor", 9 | "color": "ef6bb4", 10 | "description": "Attach to PR to automatically bump minor version on merge" 11 | }, 12 | { 13 | "name": "bump:patch", 14 | "color": "ef6bb4", 15 | "description": "Attach to PR to automatically bump patch version on merge" 16 | }, 17 | { 18 | "name": "status - waiting for feedback", 19 | "color": "fbca04", 20 | "description": "Waiting for additional feedback from people involved in the issue / pull request" 21 | }, 22 | { 23 | "name": "stale", 24 | "color": "ededed" 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /.github/workflows/depup.yml: -------------------------------------------------------------------------------- 1 | name: Deps auto update 2 | on: 3 | schedule: 4 | - cron: "14 14 * * *" # Runs at 14:14 UTC every day 5 | repository_dispatch: 6 | types: [depup] 7 | workflow_dispatch: 8 | 9 | jobs: 10 | reviewdog: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - uses: reviewdog/action-depup@v1 15 | id: depup 16 | with: 17 | file: action.yml 18 | version_name: reviewdog_version 19 | repo: reviewdog/reviewdog 20 | 21 | - name: Create Pull Request 22 | uses: peter-evans/create-pull-request@v5.0.2 23 | with: 24 | token: ${{ secrets.GITHUB_TOKEN }} 25 | title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 26 | commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 27 | body: | 28 | Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }}) 29 | Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) 30 | 31 | This PR is auto generated by [Deps auto update workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3ADeps%20auto%20update). 32 | branch: depup/reviewdog 33 | base: main 34 | labels: "bump:minor" 35 | -------------------------------------------------------------------------------- /.github/workflows/issues_prs_labeler.yml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:document-start 2 | # yamllint disable rule:line-length 3 | # Workflows which handle labels for repository issues and PRs 4 | name: Issues & PRs labeler 5 | 6 | 'on': 7 | issues: 8 | types: 9 | - closed 10 | pull_request: 11 | types: 12 | - closed 13 | issue_comment: 14 | types: 15 | - created 16 | - edited 17 | 18 | jobs: 19 | # Remove 'status: waiting for feedback' label once a user comments on an issue 20 | # or PR currently marked as waiting for feedback 21 | # Do not take into account comments posted by the github-actions bot 22 | remove_feedback_label_commented: 23 | runs-on: ubuntu-latest 24 | if: ${{ github.event_name == 'issue_comment' && github.actor != 'github-actions[bot]' }} 25 | steps: 26 | - uses: actions/checkout@v4 27 | - uses: actions-ecosystem/action-remove-labels@v1 28 | if: ${{ contains(github.event.issue.labels.*.name, 'status - waiting for feedback') }} 29 | with: 30 | labels: 'status - waiting for feedback' 31 | 32 | # Remove 'status: waiting for feedback' label once an issue or a PR are closed 33 | remove_feedback_label_closed: 34 | runs-on: ubuntu-latest 35 | if: ${{ github.event_name == 'issues' || github.event_name == 'pull_request' }} 36 | steps: 37 | - uses: actions/checkout@v4 38 | - uses: actions-ecosystem/action-remove-labels@v1 39 | if: ${{ github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'status - waiting for feedback') || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'status - waiting for feedback') }} 40 | with: 41 | labels: 'status - waiting for feedback' 42 | -------------------------------------------------------------------------------- /.github/workflows/labels.yml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:document-start 2 | # yamllint disable rule:line-length 3 | # Workflow handling available labels in the repository. The list of labels is declared in .github/labels.json 4 | name: Label management 5 | on: 6 | push: 7 | paths: 8 | - .github/labels.json 9 | - .github/workflows/labels.yml 10 | branches: 11 | - main 12 | workflow_dispatch: 13 | jobs: 14 | label: 15 | name: Manage GitHub labels 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | - name: Manage labels 21 | uses: lannonbr/issue-label-manager-action@4.0.0 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | push: 4 | branches: 5 | - main 6 | tags: 7 | - "v*.*.*" 8 | pull_request: 9 | types: 10 | - labeled 11 | 12 | jobs: 13 | release: 14 | if: github.event.action != 'labeled' 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | # Bump version on merging Pull Requests with specific labels. 20 | # (bump:major,bump:minor,bump:patch) 21 | - id: bumpr 22 | if: "!startsWith(github.ref, 'refs/tags/')" 23 | uses: haya14busa/action-bumpr@v1 24 | 25 | # Update corresponding major and minor tag. 26 | # e.g. Update v1 and v1.2 when releasing v1.2.3 27 | - uses: haya14busa/action-update-semver@v1 28 | if: "!steps.bumpr.outputs.skip" 29 | with: 30 | tag: ${{ steps.bumpr.outputs.next_version }} 31 | 32 | # Get tag name. 33 | - id: tag 34 | uses: haya14busa/action-cond@v1 35 | with: 36 | cond: "${{ startsWith(github.ref, 'refs/tags/') }}" 37 | if_true: ${{ github.ref }} 38 | if_false: ${{ steps.bumpr.outputs.next_version }} 39 | 40 | - id: stripped-tag 41 | run: echo "::set-output name=value::$(echo "${TAG}" | sed 's/refs\/tags\///')" 42 | env: 43 | TAG: ${{ steps.tag.outputs.value }} 44 | 45 | # Create release. 46 | - uses: shogo82148/actions-create-release@v1 47 | if: "steps.tag.outputs.value != ''" 48 | with: 49 | # This token is provided by Actions, you do not need to create your own token 50 | github_token: ${{ secrets.GITHUB_TOKEN }} 51 | tag_name: ${{ steps.stripped-tag.outputs.value }} 52 | release_name: ${{ steps.stripped-tag.outputs.value }} 53 | body: ${{ steps.bumpr.outputs.message }} 54 | draft: false 55 | prerelease: false 56 | 57 | release-check: 58 | if: github.event.action == 'labeled' 59 | runs-on: ubuntu-latest 60 | steps: 61 | - uses: actions/checkout@v4 62 | - name: Post bumpr status comment 63 | uses: haya14busa/action-bumpr@v1 64 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: Code Quality 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | jobs: 8 | shellcheck: 9 | name: runner / shellcheck 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: reviewdog/action-shellcheck@v1 14 | with: 15 | reporter: github-check 16 | level: error 17 | 18 | shfmt: 19 | name: runner / shfmt 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v4 23 | - uses: reviewdog/action-shfmt@v1 24 | with: 25 | level: error 26 | 27 | actionlint: 28 | name: runner / actionlint 29 | runs-on: ubuntu-latest 30 | steps: 31 | - uses: actions/checkout@v4 32 | - uses: reviewdog/action-actionlint@v1 33 | with: 34 | reporter: github-check 35 | level: error 36 | 37 | misspell: 38 | name: runner / misspell 39 | runs-on: ubuntu-latest 40 | steps: 41 | - uses: actions/checkout@v4 42 | - uses: reviewdog/action-misspell@v1 43 | with: 44 | reporter: github-check 45 | level: error 46 | locale: "US" 47 | 48 | alex: 49 | name: runner / alex 50 | runs-on: ubuntu-latest 51 | steps: 52 | - uses: actions/checkout@v4 53 | - uses: reviewdog/action-alex@v1 54 | with: 55 | reporter: github-check 56 | level: error 57 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:document-start 2 | # yamllint disable rule:line-length 3 | # Automatically stale old issues and PRs which didn't receive any update, following an explicit feedback request 4 | # (marked by the 'status - waiting for feedback' label) 5 | name: Stale 6 | 7 | 'on': 8 | schedule: 9 | - cron: '1 0 * * *' 10 | 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | 15 | jobs: 16 | stale: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: 90 days stale policy for issues & PRs 20 | uses: actions/stale@v9 21 | with: 22 | repo-token: ${{ secrets.GITHUB_TOKEN }} 23 | days-before-stale: 90 24 | days-before-close: 14 25 | only-labels: 'status - waiting for feedback' 26 | remove-stale-when-updated: true 27 | stale-issue-label: 'stale' 28 | exempt-issue-labels: 'no-stale,help-wanted' 29 | stale-issue-message: | 30 | Hi, 31 | 32 | there hasn't been any activity on this issue recently. Due to the high number of incoming tickets, we have to clean some of the old issues which didn't receive any update from the people involved, following a feedback request. 33 | Please make sure to update to the latest version. Let us know if that works for you by adding a comment. 👍 34 | 35 | This issue has now been marked as stale and will be closed if no further activity occurs within 14 days. 36 | 37 | Thank you for your precious contribution. 🚀 38 | stale-pr-label: 'stale' 39 | exempt-pr-labels: 'no-stale, help-wanted' 40 | stale-pr-message: | 41 | Hi, 42 | 43 | There hasn't been any activity on this pull request recently. Due to the high number of incoming tickets, we have to clean some of the old pull requests which didn't receive any update from the people involved, following a feedback request. 44 | 45 | This pull request has been automatically marked as stale and will be closed if no further activity occurs within 14 days. 46 | 47 | Thank you for your precious contribution. 🚀 48 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | jobs: 8 | test-check: 9 | name: runner / tsc (github-check) 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: ./ 14 | with: 15 | github_token: ${{ secrets.github_token }} 16 | reporter: github-check 17 | level: error 18 | filter_mode: nofilter 19 | workdir: ./testdata 20 | tool_name: tsc-github-check 21 | fail_on_error: true 22 | tsc_flags: --project passing 23 | - id: action_failing_test 24 | uses: ./ 25 | with: 26 | github_token: ${{ secrets.github_token }} 27 | reporter: github-check 28 | level: info 29 | filter_mode: nofilter 30 | workdir: ./testdata 31 | tool_name: tsc-github-check 32 | fail_on_error: true 33 | tsc_flags: --project failing 34 | 35 | test-pr-check: 36 | if: github.event_name == 'pull_request' 37 | name: runner / tsc (github-pr-check) 38 | runs-on: ubuntu-latest 39 | steps: 40 | - uses: actions/checkout@v4 41 | - uses: ./ 42 | with: 43 | github_token: ${{ secrets.github_token }} 44 | reporter: github-pr-check 45 | level: error 46 | filter_mode: nofilter 47 | workdir: ./testdata 48 | tool_name: tsc-github-pr-check 49 | fail_on_error: true 50 | tsc_flags: --project passing 51 | - id: action_failing_test 52 | uses: ./ 53 | with: 54 | github_token: ${{ secrets.github_token }} 55 | reporter: github-pr-check 56 | level: info 57 | filter_mode: nofilter 58 | workdir: ./testdata 59 | tool_name: tsc-github-pr-check 60 | fail_on_error: true 61 | tsc_flags: --project failing 62 | 63 | test-pr-review: 64 | if: github.event_name == 'pull_request' 65 | name: runner / tsc (github-pr-review) 66 | runs-on: ubuntu-latest 67 | steps: 68 | - uses: actions/checkout@v4 69 | - uses: ./ 70 | with: 71 | github_token: ${{ secrets.github_token }} 72 | reporter: github-pr-review 73 | level: error 74 | filter_mode: nofilter 75 | workdir: ./testdata 76 | tool_name: tsc-github-pr-review 77 | fail_on_error: true 78 | tsc_flags: --project passing 79 | - id: action_failing_test 80 | uses: ./ 81 | with: 82 | github_token: ${{ secrets.github_token }} 83 | reporter: github-pr-review 84 | level: info 85 | filter_mode: nofilter 86 | workdir: ./testdata 87 | tool_name: tsc-github-pr-review 88 | tsc_flags: --project failing 89 | -------------------------------------------------------------------------------- /.github/workflows/thread_locker.yml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:document-start 2 | # yamllint disable rule:line-length 3 | # Automatically locks old closed issues and PRs which did not receive any update recently 4 | # Take care also of removing any relevant label from threads before locking them 5 | name: 'Thread Locker' 6 | 7 | 'on': 8 | schedule: 9 | - cron: '0 0 * * *' 10 | 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | 15 | concurrency: 16 | group: lock 17 | 18 | jobs: 19 | action: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: dessant/lock-threads@v5 23 | with: 24 | # 30 days of inactivity both for closed issues and PRs 25 | issue-inactive-days: 30 26 | pr-inactive-days: 30 27 | issue-lock-reason: '' 28 | issue-comment: | 29 | Hi there, 30 | 31 | 🔒 This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new ticket for related bugs. 32 | 33 | Thanks! 34 | pr-lock-reason: '' 35 | pr-comment: | 36 | Hi there, 37 | 38 | 🔒 This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. If you want to submit a contribution to the project, you can open a new PR. 39 | 40 | Thanks! 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Folders to ignore 2 | .vscode/ 3 | node_modules/ 4 | dist/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Contribution Guidelines 3 | 4 | ## How to contribute 5 | 6 | If you want to contribute to this project, please read [this wonderful guide from GitHub](https://guides.github.com/activities/forking/) which explains how to fork a repository, make your changes and submit your work by opening a Pull Request. 7 | 8 | Any contribution is welcomed and really appreciated! :rocket: 9 | 10 | ## Tools supporting the development process 11 | 12 | This repository includes several tools supporting the development process, which you should be aware of if you plan to contribute to the project. 13 | 14 | ### Release 15 | 16 | #### [haya14busa/action-bumpr](https://github.com/haya14busa/action-bumpr) 17 | 18 | You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch). 19 | Pushing tag manually by yourself also work. 20 | 21 | #### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver) 22 | 23 | This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3 (as described in https://help.github.com/en/articles/about-actions#versioning-your-action). 24 | 25 | ### Lint & Code Quality checks 26 | 27 | This reviewdog action template itself is integrated with reviewdog to run lint checks which are useful for the action definition. 28 | 29 | ![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png) 30 | 31 | Supported linters: 32 | 33 | - [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck) 34 | - [reviewdog/action-shfmt](https://github.com/reviewdog/action-shfmt) 35 | - [reviewdog/action-actionlint](https://github.com/reviewdog/action-actionlint) 36 | - [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell) 37 | - [reviewdog/action-alex](https://github.com/reviewdog/action-alex) 38 | 39 | ### Dependencies Update Automation 40 | 41 | This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to automatically update 42 | reviewdog version. 43 | 44 | [![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/EPMatt/reviewdog-action-tsc/pull/6) 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Matteo Agnoletto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # reviewdog-action-tsc 2 | 3 | ![Maintained](https://img.shields.io/badge/maintained-yes-brightgreen) 4 | [![Tests](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/test.yml/badge.svg)](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/test.yml) 5 | [![Code Quality](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/reviewdog.yml/badge.svg)](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/reviewdog.yml) 6 | [![Deps auto update](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/depup.yml/badge.svg)](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/depup.yml) 7 | [![Release](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/release.yml/badge.svg)](https://github.com/EPMatt/reviewdog-action-tsc/actions/workflows/release.yml) 8 | [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/EPMatt/reviewdog-action-tsc?logo=github&sort=semver)](https://github.com/EPMatt/reviewdog-action-tsc/releases) 9 | [![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr) 10 | 11 | yellow-button 12 | 13 | ![github-pr-check demo](https://user-images.githubusercontent.com/30753195/133942341-15cd70d7-fb37-44c1-9249-c41580872a2f.png) 14 | 15 | This GitHub Action runs [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) with [reviewdog](https://github.com/reviewdog/reviewdog) to improve code checking and review experience for TypeScript-based modules. :dog: 16 | 17 | The action will first run `tsc`, then passing the compiler's output to reviewdog for further processing. Reviewdog will then provide a GitHub check either with code annotations as displayed above or with a Pull Request review, depending on the action configuration. 18 | 19 | For full documentation regarding reviewdog, its features and configuration options, please visit the [reviewdog repository](https://github.com/reviewdog/reviewdog). 20 | 21 | ## Input 22 | 23 | ```yaml 24 | inputs: 25 | github_token: 26 | description: 'GITHUB_TOKEN' 27 | default: '${{ github.token }}' 28 | required: false 29 | workdir: 30 | description: | 31 | Working directory relative to the root directory. 32 | This is where the action will look for a 33 | package.json which declares typescript as a dependency. 34 | Default is `.`. 35 | default: '.' 36 | required: false 37 | ### Flags for reviewdog ### 38 | level: 39 | description: | 40 | Report level for reviewdog [info,warning,error]. 41 | Default is `error`. 42 | default: 'error' 43 | required: false 44 | reporter: 45 | description: | 46 | Reporter of reviewdog command [github-check,github-pr-check,github-pr-review]. 47 | Default is `github-pr-check`. 48 | default: 'github-pr-check' 49 | required: false 50 | filter_mode: 51 | description: | 52 | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. 53 | Default is `added`. 54 | default: 'added' 55 | required: false 56 | fail_level: 57 | description: | 58 | If set to `none`, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 59 | Possible values: [none,any,info,warning,error] 60 | Default is `none`. 61 | default: 'none' 62 | fail_on_error: 63 | description: | 64 | Deprecated, use `fail_level` instead. 65 | Exit code for reviewdog when errors are found [true,false]. 66 | Default is `false`. 67 | deprecationMessage: Deprecated, use `fail_level` instead. 68 | default: 'false' 69 | required: false 70 | reviewdog_flags: 71 | description: | 72 | Additional reviewdog flags. 73 | Default is ``. 74 | default: '' 75 | required: false 76 | tool_name: 77 | description: 'Tool name to use for reviewdog reporter' 78 | default: 'tsc' 79 | required: false 80 | ### Flags for tsc ### 81 | tsc_flags: 82 | description: | 83 | Flags and args to pass to tsc. 84 | Default is ``. 85 | default: '' 86 | required: false 87 | ``` 88 | 89 | ## Usage 90 | 91 | This example shows how to configure the action to run on any event occurring on a Pull Request. Reviewdog will report tsc output messages as warnings by opening a code review on the Pull Request which triggered the workflow. 92 | 93 | ```yaml 94 | name: reviewdog 95 | on: [pull_request] 96 | jobs: 97 | tsc: 98 | name: runner / tsc 99 | runs-on: ubuntu-latest 100 | steps: 101 | - uses: actions/checkout@v2 102 | - uses: EPMatt/reviewdog-action-tsc@v1 103 | with: 104 | github_token: ${{ secrets.github_token }} 105 | # Change reviewdog reporter if you need 106 | # [github-pr-check,github-check,github-pr-review]. 107 | # More about reviewdog reporters at 108 | # https://github.com/reviewdog/reviewdog#reporters 109 | reporter: github-pr-review 110 | # Change reporter level if you need 111 | # [info,warning,error]. 112 | # More about reviewdog reporter level at 113 | # https://github.com/reviewdog/reviewdog#reporters 114 | level: warning 115 | ``` 116 | 117 | ## FAQs 118 | 119 | ### How do I run the action on a TS module in a subfolder? 120 | 121 | To run the action on a TS module in a subfolder, you can change the path where the action will run with the `workdir` input. 122 | 123 | ```yaml 124 | name: reviewdog 125 | on: [pull_request] 126 | jobs: 127 | tsc: 128 | name: runner / tsc 129 | runs-on: ubuntu-latest 130 | steps: 131 | - uses: actions/checkout@v2 132 | - uses: EPMatt/reviewdog-action-tsc@v1 133 | with: 134 | github_token: ${{ secrets.github_token }} 135 | reporter: github-pr-review 136 | level: warning 137 | # The action will look for a package.json file with typescript 138 | # declared as a dependency located in the "foo" subfolder. 139 | workdir: foo 140 | ``` 141 | 142 | ### How do I run the action on multiple TS modules? 143 | 144 | For more complex setups which require to run the action on multiple TS modules, run the action once for each single module, changing the `workdir` and `tsc_flags` inputs accordingly. 145 | 146 | ```yaml 147 | name: reviewdog 148 | on: [pull_request] 149 | jobs: 150 | tsc: 151 | name: runner / tsc 152 | runs-on: ubuntu-latest 153 | steps: 154 | - uses: actions/checkout@v2 155 | # Run action for the "submodule1" module 156 | - uses: EPMatt/reviewdog-action-tsc@v1 157 | with: 158 | github_token: ${{ secrets.github_token }} 159 | reporter: github-pr-review 160 | level: warning 161 | # The action will look for a package.json file with typescript 162 | # declared as a dependency located in the "submodule1" subfolder. 163 | workdir: submodule1 164 | # Run action for the "submodule2" module 165 | - uses: EPMatt/reviewdog-action-tsc@v1 166 | with: 167 | github_token: ${{ secrets.github_token }} 168 | reporter: github-pr-review 169 | level: warning 170 | # The action will look for a package.json file with typescript 171 | # declared as a dependency located in the "submodule2" subfolder. 172 | workdir: submodule2 173 | ``` 174 | 175 | ### Why can't I see the results? 176 | Try looking into the `filter_mode` options explained [here](https://github.com/reviewdog/reviewdog#filter-mode). TypeScript errors will sometimes appear in lines or files that weren't modified by the commit the workflow run is associated with, which instead get filtered with the default `added` option. 177 | 178 | ## Contributing 179 | 180 | Want to improve this action? Cool! :rocket: Please make sure to read the [Contribution Guidelines](CONTRIBUTING.md) prior submitting your work. 181 | 182 | Any feedback, suggestion or improvement is highly appreciated! 183 | 184 | ## Sponsoring 185 | 186 | If you want to show your appreciation and support maintenance and future development of this action, please consider **making a small donation [here](https://www.buymeacoffee.com/epmatt)**. :coffee: 187 | 188 | Moreover, if you like this project don't forget to **leave a star on [GitHub](https://github.com/EPMatt/reviewdog-action-tsc)**. Such a quick and zero-cost act will allow the action to get more visibility across the community, resulting in more people getting to know and using it. :star: 189 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Run tsc with reviewdog' 2 | description: '🐶 Run tsc with reviewdog to improve code checking and review experience for TypeScript-based modules.' 3 | author: 'EPMatt' 4 | inputs: 5 | github_token: 6 | description: 'GITHUB_TOKEN' 7 | default: '${{ github.token }}' 8 | required: false 9 | workdir: 10 | description: | 11 | Working directory relative to the root directory. 12 | This is where the action will look for a 13 | package.json which declares typescript as a dependency. 14 | Default is `.`. 15 | default: '.' 16 | required: false 17 | ### Flags for reviewdog ### 18 | level: 19 | description: | 20 | Report level for reviewdog [info,warning,error]. 21 | Default is `error`. 22 | default: 'error' 23 | required: false 24 | reporter: 25 | description: | 26 | Reporter of reviewdog command [github-check,github-pr-check,github-pr-review]. 27 | Default is `github-pr-check`. 28 | default: 'github-pr-check' 29 | required: false 30 | filter_mode: 31 | description: | 32 | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. 33 | Default is `added`. 34 | default: 'added' 35 | required: false 36 | fail_level: 37 | description: | 38 | If set to `none`, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 39 | Possible values: [none,any,info,warning,error] 40 | Default is `none`. 41 | default: 'none' 42 | fail_on_error: 43 | description: | 44 | Deprecated, use `fail_level` instead. 45 | Exit code for reviewdog when errors are found [true,false]. 46 | Default is `false`. 47 | deprecationMessage: Deprecated, use `fail_level` instead. 48 | default: 'false' 49 | required: false 50 | reviewdog_flags: 51 | description: | 52 | Additional reviewdog flags. 53 | Default is ``. 54 | default: '' 55 | required: false 56 | tool_name: 57 | description: 'Tool name to use for reviewdog reporter' 58 | default: 'tsc' 59 | required: false 60 | ### Flags for tsc ### 61 | tsc_flags: 62 | description: | 63 | Flags and args to pass to tsc. 64 | Default is ``. 65 | default: '' 66 | required: false 67 | runs: 68 | using: 'composite' 69 | steps: 70 | - uses: reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893 # v1.3.2 71 | with: 72 | reviewdog_version: v0.20.1 73 | - run: $GITHUB_ACTION_PATH/script.sh 74 | shell: bash 75 | env: 76 | INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} 77 | INPUT_WORKDIR: ${{ inputs.workdir }} 78 | INPUT_LEVEL: ${{ inputs.level }} 79 | INPUT_REPORTER: ${{ inputs.reporter }} 80 | INPUT_FILTER_MODE: ${{ inputs.filter_mode }} 81 | INPUT_FAIL_LEVEL: ${{ inputs.fail_level }} 82 | INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} 83 | INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} 84 | INPUT_TOOL_NAME: ${{ inputs.tool_name }} 85 | INPUT_TSC_FLAGS: ${{ inputs.tsc_flags }} 86 | 87 | 88 | branding: 89 | icon: 'settings' 90 | color: 'blue' 91 | -------------------------------------------------------------------------------- /script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1 4 | 5 | export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" 6 | 7 | if [ ! -f "$(npm root)"/.bin/tsc ]; then 8 | echo "::group::🔄 Running npm install to install tsc ..." 9 | npm install 10 | echo "::endgroup::" 11 | fi 12 | 13 | if [ ! -f "$(npm root)"/.bin/tsc ]; then 14 | echo "❌ Unable to locate or install tsc. Did you provide a workdir which contains a valid package.json?" 15 | exit 1 16 | else 17 | 18 | echo ℹ️ tsc version: "$("$(npm root)"/.bin/tsc --version)" 19 | 20 | echo "::group::📝 Running tsc with reviewdog 🐶 ..." 21 | 22 | # shellcheck disable=SC2086 23 | "$(npm root)"/.bin/tsc ${INPUT_TSC_FLAGS} | 24 | reviewdog -f=tsc \ 25 | -name="${INPUT_TOOL_NAME}" \ 26 | -reporter="${INPUT_REPORTER}" \ 27 | -filter-mode="${INPUT_FILTER_MODE}" \ 28 | -fail-level=${INPUT_FAIL_LEVEL} \ 29 | -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ 30 | -level="${INPUT_LEVEL}" \ 31 | ${INPUT_REVIEWDOG_FLAGS} 32 | 33 | reviewdog_rc=$? 34 | echo "::endgroup::" 35 | exit $reviewdog_rc 36 | 37 | fi -------------------------------------------------------------------------------- /testdata/failing/src/index.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | 3 | let a: number = 1; 4 | 5 | // this should generate a compilation error 6 | let b: number = "a string"; 7 | 8 | console.log(a + b); 9 | 10 | assert(a == b); 11 | -------------------------------------------------------------------------------- /testdata/failing/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "include": ["src/index.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /testdata/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testdata", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "testdata", 9 | "version": "1.0.0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@types/node": "^20.10.5" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^5.3.3" 16 | } 17 | }, 18 | "node_modules/@types/node": { 19 | "version": "20.10.5", 20 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", 21 | "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", 22 | "dependencies": { 23 | "undici-types": "~5.26.4" 24 | } 25 | }, 26 | "node_modules/typescript": { 27 | "version": "5.3.3", 28 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", 29 | "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", 30 | "dev": true, 31 | "bin": { 32 | "tsc": "bin/tsc", 33 | "tsserver": "bin/tsserver" 34 | }, 35 | "engines": { 36 | "node": ">=14.17" 37 | } 38 | }, 39 | "node_modules/undici-types": { 40 | "version": "5.26.5", 41 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 42 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 43 | } 44 | }, 45 | "dependencies": { 46 | "@types/node": { 47 | "version": "20.10.5", 48 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", 49 | "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", 50 | "requires": { 51 | "undici-types": "~5.26.4" 52 | } 53 | }, 54 | "typescript": { 55 | "version": "5.3.3", 56 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", 57 | "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", 58 | "dev": true 59 | }, 60 | "undici-types": { 61 | "version": "5.26.5", 62 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 63 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /testdata/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testdata", 3 | "version": "1.0.0", 4 | "description": "Test data for the reviewdog-action-tsc GitHub Action.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Matteo Agnoletto", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "typescript": "^5.3.3" 13 | }, 14 | "dependencies": { 15 | "@types/node": "^20.10.5" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/passing/src/index.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | 3 | const a: number = 1; 4 | const b = 1; 5 | 6 | console.log(a + b); 7 | 8 | assert(a == b); 9 | -------------------------------------------------------------------------------- /testdata/passing/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "include": ["src/index.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /testdata/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, 7 | "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, 8 | "outDir": "dist" /* Redirect output structure to the directory. */, 9 | "rootDir": "." /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, 10 | 11 | /* Strict Type-Checking Options */ 12 | "strict": true /* Enable all strict type-checking options. */, 13 | 14 | /* Module Resolution Options */ 15 | "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, 16 | "baseUrl": "." /* Base directory to resolve non-absolute module names. */, 17 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, 18 | 19 | /* Advanced Options */ 20 | "skipLibCheck": true /* Skip type checking of declaration files. */, 21 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, 22 | "resolveJsonModule": true 23 | }, 24 | "exclude": ["dist"] 25 | } 26 | --------------------------------------------------------------------------------