Skip to content

fix flakey test by mocking clock #25

fix flakey test by mocking clock

fix flakey test by mocking clock #25

Workflow file for this run

# /.github/workflows/ci.yaml
# GitHub actions workflow
name: CI
on: [push, pull_request]
jobs:
lint:
name: Lint
strategy:
matrix:
node-version: [lts/*]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Lint code
run: |
npm ci
npm run lint
test-library:
name: Test (Library)
strategy:
matrix:
node-version: [lts/gallium, lts/*, latest]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Run tests
run: |
npm ci
npm run test:lib
test-examples:
name: Test (Examples)
strategy:
matrix:
node-version: [lts/*]
deno-version: [v1.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Use Deno ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- name: Run tests
run: |
npm ci
cd examples/
npm ci
npm test
publish:
name: Publish
needs: [lint, test-library, test-examples]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Publish to npm
run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build package to upload to GitHub releases
run: |
npm pack
mv ratelimit-header-parser-*.tgz ratelimit-header-parser.tgz
- name: Create a Github release
uses: softprops/action-gh-release@v1
with:
files: ratelimit-header-parser.tgz
body:
You can view the changelog
[here](https://github.com/express-rate-limit/ratelimit-header-parser/blob/main/changelog.md).