Skip to content

Commit

Permalink
Merge pull request #323 from Automattic/update/eslint-wpvip-0.5.8
Browse files Browse the repository at this point in the history
Update eslint-plugin-wpvip to 0.5.8, WP Prettier, GitHub Action improvements
  • Loading branch information
chriszarate committed Jul 26, 2023
2 parents 422abfe + 504431f commit c7fee29
Show file tree
Hide file tree
Showing 28 changed files with 7,362 additions and 9,929 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.json,*.yaml,*.yml]
indent_style = space
5 changes: 5 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,5 @@
require( '@automattic/eslint-plugin-wpvip/init' );

module.exports = {
extends: [ 'plugin:@automattic/wpvip/recommended' ],
};
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -26,4 +26,3 @@ Example:
1. Run `npm run build`.
1. Add a script with `require( './dist/cookies' ).nom();`.
1. Verify cookies are delicious.

35 changes: 0 additions & 35 deletions .github/workflows/build.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/ci.yaml
@@ -0,0 +1,47 @@
---
name: CI

on:
pull_request:
push:
branches:
- trunk
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Setup and install
uses: Automattic/vip-actions/nodejs-setup@trunk
with:
node-version-file: .nvmrc

- name: Run linter
run: npm run lint

- name: Check formatting
run: npm run format:check

jest:
name: Run unit tests
needs: [lint]
runs-on: ubuntu-latest

steps:
- name: Setup and install
uses: Automattic/vip-actions/nodejs-setup@trunk
with:
node-version-file: .nvmrc

- name: Run tests
run: npm run jest
35 changes: 0 additions & 35 deletions .github/workflows/lint.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/prepare-release.yml
@@ -0,0 +1,33 @@
---
name: Prepare a new npm release
on:
workflow_dispatch:
inputs:
# This is copied from npm-publish/action.yml
npm-version-type:
description: 'The npm version type we are publishing.'
required: true
type: choice
default: 'patch'
options:
- patch
- minor
- major

jobs:
publish:
name: Prepare a new npm release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Check out the source code
uses: actions/checkout@v3

- name: Run npm-prepare-release
uses: Automattic/vip-actions/npm-prepare-release@v0.1.2
with:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm-version-type: ${{ inputs.npm-version-type }}
release-branch: trunk
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,16 @@
---
name: Publish to npm (if applicable)
on:
pull_request:
types: [closed]

jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
if: contains( github.event.pull_request.labels.*.name, '[ Type ] NPM version update' ) && startsWith( github.head_ref, 'release/') && github.event.pull_request.merged == true
steps:
- uses: Automattic/vip-actions/npm-publish@v0.1.2
with:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
35 changes: 0 additions & 35 deletions .github/workflows/test.yml

This file was deleted.

63 changes: 2 additions & 61 deletions .gitignore
@@ -1,61 +1,2 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# dist folder, only for npm
dist
/dist/
/node_modules/
1 change: 1 addition & 0 deletions .nvmrc
@@ -0,0 +1 @@
18.13.0
1 change: 1 addition & 0 deletions .prettierrc
@@ -0,0 +1 @@
"@automattic/eslint-plugin-wpvip/prettierrc"
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -3,6 +3,7 @@
## Releasing / Publishing

### New release

Publishing a new version can be done using the following checklist:

1. Set the version (via `npm version minor` or `npm version major` or `npm version patch`)
Expand All @@ -12,4 +13,4 @@ Publishing a new version can be done using the following checklist:
5. Edit the release on Github to include a description of the changes and publish
6. Bump the version to the next preminor: `npm --no-git-tag-version version preminor`. This will bump the version in `package.json` and `package-lock.json` to the next minor and add a `-0` to it (ex: `0.1.0 => 0.2.0-0`)
7. Create a new branch, commit your changes and push them (`git checkout -b [name_of_your_new_branch]` + `git add -u` + `git commit` + `git push origin [name_of_your_new_branch]`)
8. Create a new PR once your branch is pushed
8. Create a new PR once your branch is pushed
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -12,14 +12,14 @@ npm install --save @automattic/vip-go

The following is a list of modules included in this package:

+ [server](https://github.com/Automattic/vip-go-node/tree/trunk/src/server): a server that wraps your request handler or `express` app behind an easy to use interface
+ [logger](https://github.com/Automattic/vip-go-node/tree/trunk/src/logger): a ready to use logger for your node applications with Kibana integration out of the box
+ [newrelic](https://github.com/Automattic/vip-go-node/tree/trunk/src/newrelic): New Relic integration for applications on VIP Go
+ [redis](https://github.com/Automattic/vip-go-node/tree/trunk/src/redis): a helper library to instantiate a Redis client compatible with VIP Go
- [server](https://github.com/Automattic/vip-go-node/tree/trunk/src/server): a server that wraps your request handler or `express` app behind an easy to use interface
- [logger](https://github.com/Automattic/vip-go-node/tree/trunk/src/logger): a ready to use logger for your node applications with Kibana integration out of the box
- [newrelic](https://github.com/Automattic/vip-go-node/tree/trunk/src/newrelic): New Relic integration for applications on VIP Go
- [redis](https://github.com/Automattic/vip-go-node/tree/trunk/src/redis): a helper library to instantiate a Redis client compatible with VIP Go

## Usage

``` js
```js
const { server, logger, newrelic, redis } = require( '@automattic/vip-go' );
```

Expand Down
22 changes: 15 additions & 7 deletions __tests__/logger.tests.js
Expand Up @@ -58,15 +58,19 @@ describe( 'src/logger', () => {

const message = firstLog[ symbolForMessage ];
// eslint-disable-next-line max-len
expect( message ).toEqual( expect.stringMatching( /^\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT go:app \[info\] my message$/ ) );
expect( message ).toEqual(
expect.stringMatching(
/^\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT go:app \[info\] my message$/
)
);
} );
} );

describe( 'production logging', () => {
const ORIGINAL_VIP_GO_APP_ID = process.env.VIP_GO_APP_ID;

beforeEach( () => process.env.VIP_GO_APP_ID = true );
afterEach( () => process.env.VIP_GO_APP_ID = ORIGINAL_VIP_GO_APP_ID );
beforeEach( () => ( process.env.VIP_GO_APP_ID = true ) );
afterEach( () => ( process.env.VIP_GO_APP_ID = ORIGINAL_VIP_GO_APP_ID ) );

it( 'should format output correctly', () => {
const transport = new TestTransport();
Expand All @@ -78,7 +82,11 @@ describe( 'src/logger', () => {

const message = firstLog[ symbolForMessage ];
// eslint-disable-next-line max-len
expect( message ).toEqual( expect.stringMatching( /^\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT go:app {"message":"my message","level":"info","app":"go","app_type":"app","message_type":"info","app_process":"master","app_worker":"master"}$/ ) );
expect( message ).toEqual(
expect.stringMatching(
/^\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT go:app {"message":"my message","level":"info","app":"go","app_type":"app","message_type":"info","app_process":"master","app_worker":"master"}$/
)
);
} );
} );
} );
Expand All @@ -99,9 +107,9 @@ describe( 'src/logger', () => {
const transport = new TestTransport();
const log = goLogger( 'go:application:test', { transport } );

log.error( 'Should format %s, and add my custom label', 'this',
{ customLabel: 'custom value' }
);
log.error( 'Should format %s, and add my custom label', 'this', {
customLabel: 'custom value',
} );

const firstLog = transport.logs[ 0 ];
const expectedMessage = 'Should format this, and add my custom label';
Expand Down

0 comments on commit c7fee29

Please sign in to comment.