Skip to content

Commit

Permalink
Add ci test and release actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Americas committed Apr 5, 2024
1 parent 37668f4 commit 6013f67
Show file tree
Hide file tree
Showing 7 changed files with 2,188 additions and 77 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
workflow_dispatch:
inputs:
VERSION_BUMP:
description: 'The version bump'
type: choice
options:
- major
- minor
- patch
default: minor
required: true

jobs:
release:
runs-on: ubuntu-latest
concurrency: 1
environment: release

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}

- name: Setup Node.js version
uses: actions/setup-node@v4
with:
node-version: 20

- name: Enable yarn
run: corepack enable

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Configure git
run: |
git config user.name "Uphold"
git config user.email "[email protected]"
- name: Generate release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
npm run release -- --increment "${{ github.event.inputs.VERSION_BUMP }}" -V
19 changes: 19 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test

on: [push]

jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['18', '20']

container:
image: node:${{ matrix.node }}-alpine

steps:
- uses: actions/checkout@v4
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn test
22 changes: 22 additions & 0 deletions .release-it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
git: {
changelog: 'echo "## Changelog\\n\\n$(npx @uphold/github-changelog-generator -f unreleased | tail -n +4 -f)"',
commitMessage: 'Release ${version}',
requireBranch: 'master',
requireCommits: true,
tagName: 'v${version}'
},
github: {
release: true,
releaseName: 'v${version}'
},
hooks: {
'after:bump': `
echo "$(npx @uphold/github-changelog-generator -f v\${version})\n$(tail -n +2 CHANGELOG.md)" > CHANGELOG.md &&
git add CHANGELOG.md --all
`
},
npm: {
publish: true
}
};
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# request-logger

A wrapper for the [request](https://github.com/request/request) module that logs all request events.
A wrapper for the [request](https://github.com/cypress-io/request) module that logs all request events.

## Status

Expand All @@ -26,7 +26,7 @@ Wrap the `request` module using `@uphold/request-logger`. By default, all events

```javascript
const logger = require('@uphold/request-logger');
const request = logger(require('request'));
const request = logger(require('@cypress/request'));

request.get('https://www.github.com');

Expand Down Expand Up @@ -56,7 +56,7 @@ You can optionally define a custom logging function which receives the request o

```javascript
const logger = require('@uphold/request-logger');
const request = logger(require('request'), data => console.log(`${data.id} ${data.type}: ${data.uri}${data.statusCode ? ` (${data.statusCode})` : ''} ${(data.body ? `${data.body}` : '').length} bytes`));
const request = logger(require('@cypress/request'), data => console.log(`${data.id} ${data.type}: ${data.uri}${data.statusCode ? ` (${data.statusCode})` : ''} ${(data.body ? `${data.body}` : '').length} bytes`));

request.get('https://www.github.com', () => {});

Expand Down Expand Up @@ -86,11 +86,10 @@ The recommended node.js version is `>= 6` as it ships with native [ES2015 Proxy]

The minimum required `request` version is `2.27.0`, although `2.54.0` is a particularly troubled version which is best avoided.

## Release
## Release process

```shell
❯ npm version [<newversion> | major | minor | patch] -m "Release %s"`
```
The release of a version is automated via the [release](https://github.com/uphold/request-logger/.github/workflows/release.yaml) GitHub workflow.
Run it by clicking the "Run workflow" button.

## License

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
"main": "src",
"repository": "https://github.com/uphold/request-logger.git",
"scripts": {
"changelog": "github_changelog_generator --no-issues --header-label='# Changelog' --future-release=v$npm_config_future_release && sed -i '' -e :a -e '$d;N;2,4ba' -e 'P;D' CHANGELOG.md",
"lint": "eslint src test",
"test": "jest --coverage --verbose",
"version": "npm run changelog --future-release=$npm_package_version && git add -A CHANGELOG.md"
"release": "release-it",
"test": "jest --coverage --verbose"
},
"dependencies": {
"uuid": "^9.0.1"
Expand All @@ -34,7 +33,8 @@
"eslint": "^8.57.0",
"eslint-config-uphold": "^6.0.0",
"jest": "^29.7.0",
"nock": "^13.5.4"
"nock": "^13.5.4",
"release-it": "^17.1.1"
},
"peerDependencies": {
"@cypress/request": ">=3.0.1"
Expand Down
Loading

0 comments on commit 6013f67

Please sign in to comment.