Skip to content

Commit

Permalink
Add cjs support and jest as test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
magraina authored Aug 4, 2024
1 parent 40dc5f2 commit b99079c
Show file tree
Hide file tree
Showing 17 changed files with 4,295 additions and 3,409 deletions.
821 changes: 349 additions & 472 deletions .eslintrc.json

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CI

on:
push:
branches: ["main"]
tags: ["**"]
pull_request:
# Build all pull requests, regardless of what their base branch is.
branches: ["**"]
types:
# Default types (see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
- opened
- synchronize
- reopened
# Extra types (re-run CI when marking PR for "ready for review")
- ready_for_review

# Automatically cancel previous runs for the same ref (i.e. branch)
concurrency:
group: ${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}
node-version-file: "package.json"
cache: "yarn"
cache-dependency-path: "yarn.lock"
registry-url: "https://registry.npmjs.com"
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts --network-concurrency 1 --child-concurrency 1
- name: Lint code (ESLint)
run: yarn run lint:eslint
- name: Lint code (Prettier)
run: yarn run lint:prettier

test:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}
node-version-file: "package.json"
cache: "yarn"
cache-dependency-path: "yarn.lock"
registry-url: "https://registry.npmjs.com"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Unit Tests
run: yarn run test:unit

build:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}
node-version-file: "package.json"
cache: "yarn"
cache-dependency-path: "yarn.lock"
registry-url: "https://registry.npmjs.com"
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts --network-concurrency 1 --child-concurrency 1
- name: Typescript build
run: yarn run build

publish:
needs:
- lint
- test
- build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}
node-version-file: "package.json"
cache: "yarn"
cache-dependency-path: "yarn.lock"
registry-url: "https://registry.npmjs.com"
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts --network-concurrency 1 --child-concurrency 1
- name: Publish to NPM
run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarn lint
git update-index --again
Loading

0 comments on commit b99079c

Please sign in to comment.