Skip to content

Commit

Permalink
Setup TypeScript checking (#2)
Browse files Browse the repository at this point in the history
* initial commit

* Toss in everything

* fix(PeerDependencies): install them correctly

Big changes

1. Use `withCwd` to move around and do things in the right places
2. Stop depending on `yarn list --pattern`, because it's
   unpredictable (prettier made it return hundreds of packages)
3. Install packages warned about in peerDependencies

* Update README.md

* Always finish check run, even if it fails

* npx standard --fix

* Remove withCwd

* Don't install peer dependencies if there are none

* Add explicit loading path for eslint

* Remove note about eslint 6

* Update README.md

* 💅 Attempt to install prettier packages, too (#4)

* 💅 Attempt to intall prettier packages, too

We're seeing some weird prettier errors when linting a project that has eslint configured to run prettier. My theory is that different prettier versions are being installed depending on peer dependencies vs top-level dependencies. 🤞

* Try to nstall babel dependencies, too

The same strategy that was used for eslint, applied to babel. Parsing has
an impact on linting, so I'm curious to see if this makes the remaining
3 errors on my example branch go away.

* Revert "Try to nstall babel dependencies, too"

This reverts commit 2df54b0f0b3470abba93bd379d87bae70358106d.

* Bump node-fetch from 2.6.0 to 2.6.1

Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](node-fetch/node-fetch@v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <[email protected]>

* Output number of issues found

This will be useful for other actions to key off of or use for their own
inputs.

* Pedantic check name change

Matching it up with what the library uses

* Add changelog

* Release v0.4

* Update README.md

* Create CONTRIBUTING.md

* Add caching instructions to sample config in README (#8)

Worked on with @wassimk and @timhooker

* fix: Find peer dependencies that begin with `@`

A flaw in the regex for finding peer dependencies meant that any that
begin with `@` (e.g. `@babel/core`) would not be found, and would thus
not be installed.

* fix: Include empty annotations array on error

If there is an error, we build a default report object, but it doesn't
include an `annotations` property, and so then we get a subsequent error
when the `output` attempts to read the length of it.

* Allow specifying lowest failure level

By default, the check will have passed as long as there are no errors.
This commit adds the ability to specify a `failureLevel` which, when set
to "warning", will also fail if there are any warnings or errors.

* Release v0.5

* Fix github actions typo

* 🆕 Support ESLint's new v7 API

* Make sure were `await`ing when neccesary

* Fix up operators for clairty

* Allow ESLint to be installed before requiring it

* Don't use relative paths

* Setup linter depending on eslint version

* Update README.md

* Small readme tweaks

* Remove redundant bullet point in intro pitch
* Bump action versions in sample config
* Remove caching step from sample config (shouldn't be necessary with
  the minimal package.json that the action creates)

* Add note about permissions in readme

Getting this action working with tools like dependabot that run with
reduced permissions takes a bit more configuration. Let's make that
clear in the readme.

* Restore readme caching suggestion

While this action is selective about installing as few dependencies as
are necessary for running ESLint, ESLint itself has quite a few
dependencies, and if you add more plugins to the mix, even the minimal
install can be sizable. In some (many?) cases it could still be
beneficial to cache what's installed. This is what used to live in the
suggested config, with a note about its optionality.

* transition repo to be for typescript

* Bump node-fetch from 2.6.1 to 2.6.7

Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](node-fetch/node-fetch@v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* allow for push checks

* fix guard

* don't throw for error

* log more outputs

* update reference to bin file

* try to track more down

* add output

* adjust error conclusion

* more logging

* add annotations

* add additional info to annotations

* get tsc-silent working

* clean out prettified language

* yarn everything

types come from everything, so we need to install everything

* clean up the action.yml file

* setup composite runner

* move GITHUB_TOKEN to be an input

* add branch name

* add shell

* update way github token is passed

* make yarn a nested action

* start to allow options for package managing

* update api

* check if jobs works

* remove non-working variables

* clean up naming

* remove composite nature

* reset package versions

* update cache name

* move to ncc

* setup build for main repo

* remove node modules from yarn

* remove unneeded package.json from yarn project

* clean up utils changes

* remove unused

* update contributing copy

* update readme with proper instructions

* upgrade node-fetch

* refactor to clients

* add codeowners

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Daniel Ma <[email protected]>
Co-authored-by: Nick Sheck <[email protected]>
Co-authored-by: Dan Ott <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mo Lawson <[email protected]>
Co-authored-by: Shane Bonham <[email protected]>
Co-authored-by: Alex Valencia <[email protected]>
Co-authored-by: Kevin Thompson <[email protected]>
  • Loading branch information
9 people authored Oct 12, 2022
1 parent 4dd4a4f commit d76adc1
Show file tree
Hide file tree
Showing 17 changed files with 14,982 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @kylemellander @sheck @danielma @molawson
20 changes: 20 additions & 0 deletions .github/workflows/ncc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: ncc
on:
push:
paths:
- 'package-lock.json'
- 'src/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
cache: npm
- run: npm ci
- uses: planningcenter/balto-utils/ncc@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## v0.1 (2022-10-10)

- Initial release
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Contributing to balto-typescript

1. Open a PR with your changes
2. Include a line in CHANGELOG.md under unreleased

## Releasing Updates

1. Update CHANGELOG.md to reflect the new version number and date
2. Update the tag version in the sample config in README.md (`- uses: planningcenter/balto-typescript@[tag version goes here]`)
3. Create the release and have GitHub create the tag for you
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 🐺 Balto-TypeScript

Balto is Smart and Fast:

* Runs your TypeScript compilation with your settings and versions to make sure that everything compiles correctly
* Supports ignoring specific errors using [tsc-silent](https://github.com/evolution-gaming/tsc-silent)

Sample config (place in `.github/workflows/balto.yml`):

```yaml
name: Balto-TypeScript

on: [pull_request]

jobs:
typescript:
runs-on: ubuntu-latest
steps:
- uses: planningcenter/balto-typescript/[email protected]
- uses: planningcenter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
conclusionLevel: "failure"
```
## Inputs
| Name | Description | Required | Default |
|:-:|:-:|:-:|:-:|
| `conclusionLevel` | Which check run conclusion type to use when annotations are created (`"neutral"` or `"failure"` are most common). See [GitHub Checks documentation](https://developer.github.com/v3/checks/runs/#parameters) for all available options. | no | `"neutral"` |
| `failureLevel` | The lowest annotation level to fail on | no | `"error"` |


## Outputs

| Name | Description |
|:-:|:-:|
| `issuesCount` | Number of TypeScript errors found |

## A note about permissions

Because some tools, like [dependabot](https://github.com/dependabot), use tokens for actions that have read-only permissions, you'll need to elevate its permissions for this action to work with those sorts of tools. If you don't use any of those tools, and your workflow will only run when users with permissions in your repo create and update pull requests, you may not need these explicit permissions at all.

When defining any permissions in a workflow or job, you need to explicitly include any permission the action needs. In the sample config above, we explicitly give `write` permissons to the [checks API](https://docs.github.com/en/rest/checks/runs) for the job that includes balto-typescript as a step. Because balto-typescript uses [check runs](https://docs.github.com/en/rest/guides/getting-started-with-the-checks-api), the `GITHUB_TOKEN` used in an action must have permissions to create a `check run`. You'll also need `contents: read` for `actions/checkout` to be able to clone the code.
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Balto - TypeScript Check"
description: "Run TypeScript checks on your repo"
runs:
using: node12
main: dist/index.js
branding:
icon: life-buoy
color: orange
inputs:
conclusionLevel:
description: 'Which check run conclusion type to use when annotations are created ("neutral" or "failure" are most common)'
required: false
default: "neutral"
outputs:
issuesCount:
description: "Number of TypeScript violations found"
Loading

0 comments on commit d76adc1

Please sign in to comment.