Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the github actions and readme #248

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: NPM Publish
name: Publish to npm

on:
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.x'
- run: yarn
- run: yarn test

publish-npm:
needs: test
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn build
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Check out the code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: yarn install

- name: Build the project
run: yarn build

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn publish --access public

- name: Clean up npm token
run: yarn logout
29 changes: 29 additions & 0 deletions .github/workflows/unit-test-case-on-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Tests on Release Branch

on:
push:
branches:
- release/**

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out the code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'

- name: Install dependencies
run: yarn install

- name: Run eslint
run: yarn lint

- name: Run tests
run: yarn test
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,35 @@

## Getting Started 🔮

This package will run linters on committed files while pushing the code to remote.
lint-prepush will run linters on the commited files while pushing the code to remote.

### Prerequisites🔭

* This package requires Node.js `>=10`.
* A package to manage git hooks.
* This package requires Node.js `>=18.18.0`.
* A package to manage git hooks. (a tool like [Husky](https://github.com/typicode/husky))

### Installing

#### npm

```bash
npm install --save-dev husky lint-prepush
npm install --save-dev lint-prepush
```

#### using [`yarn`](https://yarnpkg.com/):

```bash
yarn add --dev husky lint-prepush
yarn add --dev lint-prepush
```

### Usage

Configure the following scripts in package.json to lint your committed files 🔧. You can also follow any of the [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) methods to configure lint-prepush.
* Configure the following scripts in package.json to lint your committed files 🔧. You can also follow any of the [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) methods to configure lint-prepush.

* Here [Husky](https://github.com/typicode/husky) is used for managing git hooks.
* pre-push git hook needs to be configured. [Husky](https://github.com/typicode/husky) is a widely used package for managing git hooks.

```diff
{
+ "husky": {
+ "hooks": {
+ "pre-push": "lint-prepush"
+ }
+ },
+ "lint-prepush": {
+ "base": "master",
+ "tasks": {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lint-prepush",
"version": "3.0.0",
"version": "3.0.1",
"description": "Run linters on committed files in a Branch🔬",
"author": "“Theenadayalan” <“[email protected]”>",
"license": "MIT",
Expand Down Expand Up @@ -64,6 +64,7 @@
"prepush",
"husky",
"linter",
"git"
"git",
"hooks"
]
}