Skip to content

Commit

Permalink
ci: migrate to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Jan 16, 2024
1 parent 56e166d commit f7fa840
Show file tree
Hide file tree
Showing 32 changed files with 9,074 additions and 5,430 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
16 changes: 16 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://unpkg.com/@changesets/config/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "prettier/pretty-quick"
}
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
4 changes: 4 additions & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"node": "18",
"sandboxes": []
}
13 changes: 12 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
github: [azz]
github:
- azz
- JounQin
- 1stG
- rx-ts
- un-ts
patreon: 1stG
open_collective: unts
custom:
- https://opencollective.com/1stG
- https://opencollective.com/rxts
- https://afdian.net/@JounQin
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
- push
- pull_request

jobs:
ci:
name: Lint and Test with Node.js ${{ matrix.node }} on ${{ matrix.os }}
strategy:
matrix:
node:
- 10
- 12
- 14
- 16
- 18
- 20.7
os:
- macos-latest
- windows-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
env:
# https://github.com/actions/setup-node/issues/531#issuecomment-1819151412
SKIP_YARN_COREPACK_CHECK: 1

- name: Enable Corepack
run: corepack enable

- name: Install Dependencies
run: yarn --immutable

- name: lint
run: yarn lint
if: matrix.node == '20.7'
env:
EFF_NO_LINK_RULES: true
PARSER_NO_WATCH: true

- name: Build and Test
run: yarn run-s build test

- name: Codecov
uses: codecov/codecov-action@v3
44 changes: 44 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CodeQL

on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '0 2 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language:
- javascript

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: '/language:${{ matrix.language }}'
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
env:
# https://github.com/actions/setup-node/issues/531#issuecomment-1819151412
SKIP_YARN_COREPACK_CHECK: 1

- name: Enable Corepack
run: corepack enable

- name: Install Dependencies
run: yarn --immutable

- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
with:
commit: 'chore: release pretty-quick'
title: 'chore: release pretty-quick'
version: yarn run version
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/size-limit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Size Limit

on:
pull_request:
branches:
- master

jobs:
size-limit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js LTS
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
env:
# https://github.com/actions/setup-node/issues/531#issuecomment-1819151412
SKIP_YARN_COREPACK_CHECK: 1

- name: Enable Corepack
run: corepack enable

- name: Install Dependencies
run: yarn --immutable

- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_step: install
script: yarn size-limit --json
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist
node_modules
*.log
dist
/.yarn/*
!/.yarn/plugins
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .yarn/plugins/plugin-prepare-lifecycle.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
name: 'plugin-prepare-lifecycle',
factory: e => ({
hooks: {
afterAllInstalled(r) {
if (!r.topLevelWorkspace.manifest.scripts.get('prepare')) return
e('@yarnpkg/shell').execute('yarn prepare')
},
},
}),
}
6 changes: 6 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nodeLinker: node-modules

plugins:
- checksum: 37b2361b1502b2054e6779788c0e9bdd6a90ce49852a8cad2feda79b0614ec94f06fb6e78951f5f95429c610d7934dd077caa47413a0227378a102c55161616d
path: .yarn/plugins/plugin-prepare-lifecycle.cjs
spec: 'https://github.com/un-es/yarn-plugin-prepare-lifecycle/releases/download/v0.0.1/index.js'
69 changes: 30 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# `pretty-quick`

[![Travis](https://img.shields.io/travis/com/azz/pretty-quick.svg?style=flat-square)](https://travis-ci.com/github/azz/pretty-quick)
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![npm](https://img.shields.io/npm/v/pretty-quick.svg?style=flat-square)](https://npmjs.org/pretty-quick)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
[![GitHub Actions](https://github.com/prettier/pretty-quick/workflows/CI/badge.svg)](https://github.com/prettier/pretty-quick/actions/workflows/ci.yml)
[![Codecov](https://img.shields.io/codecov/c/github/prettier/pretty-quick.svg)](https://codecov.io/gh/prettier/pretty-quick)
[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Fun-ts%2Flib-boilerplate%2Fmain%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
[![npm](https://img.shields.io/npm/v/pretty-quick.svg)](https://www.npmjs.com/package/pretty-quick)
[![GitHub Release](https://img.shields.io/github/release/prettier/pretty-quick)](https://github.com/prettier/pretty-quick/releases)

[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)

> Get Pretty Quick
Expand All @@ -19,61 +25,46 @@ Supported source control managers:

## Install

With `yarn`:

```shellsession
yarn add --dev prettier pretty-quick
```sh
# npm
npm install -D prettier pretty-quick
```

With `npm`:

```shellsession
npm install --save-dev prettier pretty-quick
```sh
# yarn
yarn add -D prettier pretty-quick
```

## Usage

With `yarn`:
```sh
# npx
npx pretty-quick

```shellsession
# yarn
yarn pretty-quick
```

With [`npx`](https://npm.im/npx):

```shellsession
npx -p prettier@latest -p pretty-quick pretty-quick
```

> Note: You can (_should_) change `latest` to a specific version of Prettier.
With `npm`:

1. Add `"pretty-quick": "pretty-quick"` to the `"scripts"` section of `package.json`.
2. `npm run pretty-quick`

## Pre-Commit Hook

You can run `pretty-quick` as a pre-commit hook using [`husky`](https://github.com/typicode/husky).
You can run `pretty-quick` as a pre-commit hook using [`simple-git-hooks`](https://github.com/toplenboren/simple-git-hooks).

> For Mercurial have a look at [`husky-hg`](https://github.com/TobiasTimm/husky-hg)
```sh
# npm
npm install -D simple-git-hooks

```shellstream
yarn add --dev husky
# yarn
yarn add -D simple-git-hooks
```

In `package.json`, add:

```json
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
"simple-git-hooks": {
"pre-commit": "pretty-quick --staged"
}
```

![demo](./img/precommit.gif)

## CLI Flags

### `--staged` (only git)
Expand All @@ -97,7 +88,7 @@ For example `pretty-quick --pattern "**/*.*(js|jsx)"` or `pretty-quick --pattern

### `--verbose`

Outputs the name of each file right before it is proccessed. This can be useful if Prettier throws an error and you can't identify which file is causing the problem.
Outputs the name of each file right before it is processed. This can be useful if Prettier throws an error and you can't identify which file is causing the problem.

### `--bail`

Expand Down

0 comments on commit f7fa840

Please sign in to comment.