Skip to content

Commit

Permalink
Add npm project push and testing (#3)
Browse files Browse the repository at this point in the history
* add npm tests

* add github action for publishing

* add eslint + ci testing

* 1.1.0

* add release scripts

* updating dependencies

* test push event

* add test training data

* update tests from ESLINT errors

* fix ESLint... :eye-rolling-eyes:

* update tests and bot

* update Wrangler + deps + tests

* update test cases

* fix workflow tests

* update deps

* update lint rules

* no need to test node 18.x

* allow test tweets.txt
  • Loading branch information
jerdog authored Nov 29, 2024
1 parent 4161b26 commit 90274ed
Show file tree
Hide file tree
Showing 19 changed files with 7,196 additions and 889 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
env:
node: true
es2021: true
extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 'latest'
sourceType: 'module'
rules:
indent:
- error
- 4
- SwitchCase: 1
linebreak-style:
- error
- unix
quotes:
- error
- single
- avoidEscape: true
semi:
- error
- always
no-unused-vars:
- error
- argsIgnorePattern: '^_'
varsIgnorePattern: '^_'
no-console: off
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Continuous Integration

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint --if-present

- name: Run tests
run: npm test

- name: Build
run: npm run build --if-present
57 changes: 57 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish Package

on:
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build
run: npm run build --if-present

publish:
needs: test
if: github.event.release.target_commitish == 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build --if-present

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

- name: Deploy to Cloudflare Workers
run: npm run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5 changes: 5 additions & 0 deletions .github/workflows/push.event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"push": {
"ref": "refs/heads/main"
}
}
123 changes: 104 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,37 +1,122 @@
# Dependencies
node_modules/
jspm_packages/
.pnp
.pnp.js
.npm
package-lock.json
yarn.lock
.yarn/
.yarnrc.yml

# Testing
coverage/
.nyc_output/
*.lcov

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

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

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# dotenv environment variable files
# Environment variables
.env
.env.development.local
.env.test.local
.env.production.local
.env.*
.env.local
.env.*.local
.dev.vars

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
.vscode
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
.history/

# Cloudflare Workers
.wrangler/
.dev.vars
# IDE - JetBrains
.idea/
*.iml
*.ipr
*.iws

# IDE - Sublime Text
*.sublime-workspace
*.sublime-project

# macOS
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Windows
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
[Dd]esktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msix
*.msm
*.msp
*.lnk

# Build output
dist/
build/
.wrangler/
.cloudflare/
worker/
*.tsbuildinfo

# Ignore the following files in the root of this repository:
.DS_Store
tweets.txt
# Local dev
.local/
.cache/
*.swp
*.swo
*~

# Project specific
#tweets.txt
.secrets
.github/workflows/release.event.json

# Test files
__tests__/*.js.snap
__snapshots__/
*.snap

# Cloudflare specific
.dev.vars
wrangler.toml
.wrangler/
.cloudflare/
.requirements.txt

# Misc
*.bak
*.tmp
.temp/
.cache/
34 changes: 34 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Development files
.github/
tests/
babel.config.json
jest.config.js
.env
.env.*

# Editor files
.vscode/
.idea/
*.swp
*.swo

# Logs
logs/
*.log
npm-debug.log*

# Dependencies
node_modules/

# Build artifacts
dist/
build/
coverage/

# Git files
.git/
.gitignore

# Misc
.DS_Store
Thumbs.db
Loading

0 comments on commit 90274ed

Please sign in to comment.