Skip to content

Commit

Permalink
Initial version (#2)
Browse files Browse the repository at this point in the history
* First parse including tests

* add github actions

* Remove prepare

* unset GITHUB event path so test runs in actions

* unset GITHUB event path so test runs in actions

* Expand readme

* Remove prepare

* Prettier

* command name change and review fixes

* ensure nocks aren't bundled
  • Loading branch information
adcreare authored Sep 23, 2022
1 parent 9f2f24d commit 45179c7
Show file tree
Hide file tree
Showing 20 changed files with 12,244 additions and 94 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
pull_request:
branches:
- 'main'

env:
CI: true

jobs:
pullRequestBuild:
name: Pull Request Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Audit Signatures
run: npm audit signatures
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Compile
run: npm run ci:compile
- name: Check Code Style
run: npm run ci:style
- name: Perform Linting
run: npm run ci:lint
- name: Run Tests
run: npm run ci:test

branchBuild:
runs-on: ubuntu-latest
name: Branch Build
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Audit Signatures
run: npm audit signatures
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Compile
run: npm run ci:compile
- name: Check Code Style
run: npm run ci:style
- name: Perform Linting
run: npm run ci:lint
- name: Run Tests
run: npm run ci:test
46 changes: 46 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Coverage

on:
pull_request:
branches:
- 'main'

env:
CI: true

jobs:
branchBuild:
runs-on: ubuntu-latest
name: Branch Build
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Calculate Code Coverage
run: npm run ci:coverage
- name: Create Coverage Report for base branch
run: |
mv coverage/lcov.info coverage/lcov_head.info
git fetch
git checkout origin/${{ github.event.pull_request.base.ref }}
npm ci --ignore-scripts && npm run ci:coverage
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Post Coverage Report
uses: romeovs/[email protected]
with:
lcov-file: 'coverage/lcov_head.info'
lcov-base: 'coverage/lcov.info'
delete-old-comments: true
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
99 changes: 5 additions & 94 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,15 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

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

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

# Coverage directory used by tools like istanbul
.idea
.code
coverage
*.lcov

# nyc test coverage
.nyc_output

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

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

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
build
node_modules
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
.npmignore
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# github-actions

Tools for use with gitub-actions

## Commands:

### `npx action is-api`

Identifies if a project contains a `src/api` folder structure and returns GitHub action compatible output.

- If TRUE returns `::set-output name=IS_API::true`
- If FALSE returns `::set-output name=IS_API::false`

### `npx action generate-beta-version`

Generates a beta version string for the project and updates the package.json to this.

Reads the current version from the projects.json and appends `-beta.` to it
Then generates a 5 character random string. For example `1.2.3-beta.aBc4d`

Result is then written to the projects package.json file that is located on the GitHub action container.

New version is output in the GitHub action compatible output including the Package name `::set-output name=NEW_VERSION::@checkdigit/[email protected]`

### `npx action publish-comment`

Writes a comment into the Pull Request that contains the new version and the npm command to install it.

Expects an environment variable `NEW_PACKAGE_VERSION` set that contains the `NEW_VERSION` output from `npx action generateBetaVersion`

If any previous comments exist those will be removed so only the most recent beta version is shown on the Pull Request
2 changes: 2 additions & 0 deletions bin/action
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('../dist/index.js');
Loading

0 comments on commit 45179c7

Please sign in to comment.