Skip to content

Commit

Permalink
ci: migrate to GitHub Actions (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Jan 16, 2024
1 parent 56e166d commit 5985301
Show file tree
Hide file tree
Showing 34 changed files with 10,402 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
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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
os:
- 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

- name: Install Dependencies
run: yarn --immutable

- name: Lint
run: yarn lint
if: matrix.node == 18
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 }}'
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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

- 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 }}
27 changes: 27 additions & 0 deletions .github/workflows/size-limit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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

- 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
dist
node_modules
*.log
dist
/.yarn/*
!/.yarn/plugins
!/.yarn/releases
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
/.yarn
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions .yarn/plugins/plugin-prepare-lifecycle.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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")}}})};
55 changes: 55 additions & 0 deletions .yarn/releases/yarn-2.4.3.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
enableGlobalCache: true

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/plugin-prepare-lifecycle.cjs
spec: 'https://github.com/un-es/yarn-plugin-prepare-lifecycle/releases/download/v0.0.1/index.js'

yarnPath: .yarn/releases/yarn-2.4.3.cjs
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
10 changes: 5 additions & 5 deletions __mocks__/execa.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ const mockStream = () => ({
on: jest.fn(),
removeListener: jest.fn(),
pipe: jest.fn(),
});
})

const mockExeca = jest.fn().mockReturnValue({
stdout: mockStream(),
stderr: mockStream(),
kill: () => {},
});
})

const mockExecaSync = jest.fn().mockReturnValue({
stdout: '',
stderr: '',
kill: () => {},
});
})

module.exports = mockExeca;
module.exports.sync = mockExecaSync;
module.exports = mockExeca
module.exports.sync = mockExecaSync
Loading

0 comments on commit 5985301

Please sign in to comment.