Skip to content

Commit

Permalink
Initial repo code (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
code-ape authored May 16, 2022
1 parent d5d50f7 commit 9b3172d
Show file tree
Hide file tree
Showing 24 changed files with 1,353 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.21.2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
63 changes: 63 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: PR CI

on:
pull_request:
branches: ['**']

jobs:
node_ci:
name: Node.js CI
runs-on: ${{ matrix.os }}
timeout-minutes: 5
defaults:
run:
shell: bash

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node_version: ['12.22.12', '14.19.2', '16.15.0']

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'
- run: npm ci
- run: npm run build
- run: npm pack

deno_ci:
name: Deno CI
runs-on: ${{ matrix.os }}
timeout-minutes: 5
defaults:
run: { shell: bash }

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
deno_version: ['v1.17.0', 'v1.21.1', 'vx.x.x']

steps:
- uses: actions/checkout@v3
- name: Use Deno ${{ matrix.deno_version }}
uses: denoland/setup-deno@v1
with:
deno-version: '${{ matrix.deno_version }}'
- run: deno fmt --check
if: matrix.deno_version == 'vx.x.x'
- run: deno lint
if: matrix.deno_version == 'vx.x.x'
- run: deno test --allow-all
- name: deno coverage cov_profile/
if: matrix.deno_version == 'vx.x.x'
run: |
rm -rf cov_profile/ || true
deno test --allow-all --coverage=cov_profile/ > /dev/null 2>&1
deno coverage cov_profile/
- name: Check coverage 100%
if: matrix.deno_version == 'vx.x.x'
run: ./scripts/check-coverage 100
140 changes: 140 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Package Release CI
on:
push:
branches: [main]
# Ignore all markdown files, all files in the .github directory (but not its
# workflows/ directory), and test files.
paths-ignore: ['**.md', '.github/*']


jobs:

# job: create_version
create_version:
name: Create build version
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
build_version: ${{ steps.gen_version.outputs.new_version }}
prod_build: ${{ steps.gen_version.outputs.prod_build }}
npm_tag: ${{ steps.gen_version.outputs.npm_tag }}
steps:
- uses: actions/checkout@v3
with: { fetch-depth: '2' }
- uses: actions/setup-node@v3
with: { node-version-file: '.nvmrc' }
- uses: salsify/action-detect-and-tag-new-version@v2
id: detect_version
with: { create-tag: false }

- name: Version pre-release
id: gen_version
run: |
set -ex
previous_version="${{steps.detect_version.outputs.previous-version}}"
current_version="${{steps.detect_version.outputs.current-version}}"
if [ "$previous_version" = "$current_version" ]; then
echo "Version has NOT changed. This is a dev build."
export CURRENT_COMMIT="$(git rev-parse --short HEAD)"
export NEW_PACKAGE_VERSION="$(npx semver --increment minor "$current_version")-dev.$CURRENT_COMMIT"
echo "::set-output name=new_version::$NEW_PACKAGE_VERSION"
echo "::set-output name=prod_build::false"
echo "::set-output name=npm_tag::dev"
else
echo "Version has changed. This is a prod build!"
echo "::set-output name=new_version::$current_version"
echo "::set-output name=prod_build::true"
echo "::set-output name=npm_tag::latest"
fi
# job: publish_github_package
publish_github_package:
name: Publish NPM package to Github
runs-on: ubuntu-latest
timeout-minutes: 5
needs: ['create_version']

steps:
- uses: actions/checkout@v3
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
registry-url: 'https://npm.pkg.github.com/'
scope: '@urbdyn'
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{secrets.GH_RD_PKG_TOKEN}}
- name: Set Version
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
npm version --allow-same-version ${{needs.create_version.outputs.build_version}}
- run: npm publish --tag ${{needs.create_version.outputs.npm_tag}}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# job: publish_npm_package
publish_npm_package:
name: Publish repo release and NPM package
runs-on: ubuntu-latest
timeout-minutes: 5
needs: ['create_version']
if: needs.create_version.outputs.prod_build == 'true'

steps:
- uses: actions/checkout@v3
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create_version.outputs.build_version }}
release_name: Release ${{ needs.create_version.outputs.build_version }}
body: >
This release contains the repo source code and a tar.gz of the NPM package.
It has been created for proper archiving practices.
However, please use the NPM registry to install and use the NPM package!
draft: false
prerelease: ${{ needs.create_version.outputs.prod_build != 'true' }}

- run: npm ci
- name: Set Version
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
npm version --allow-same-version ${{needs.create_version.outputs.build_version}}
- name: npm pack
id: npm_pack
run: |
export NPM_TGZ_FILE=$(npm pack)
export NPM_TGZ_FILE=$(echo "$NPM_TGZ_FILE" | tail -n 1)
echo "NPM_TGZ_FILE=$NPM_TGZ_FILE"
echo "::set-output name=npm_tgz_file::$NPM_TGZ_FILE"
# Upload NPM tar.gz, linux only
- name: Upload Release Asset - tgz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ steps.npm_pack.outputs.npm_tgz_file }}
asset_name: ${{ steps.npm_pack.outputs.npm_tgz_file }}
asset_content_type: application/gzip

- run: npm publish
if: needs.create_version.outputs.npm_tag == 'latest'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_CI_TOKEN }}
108 changes: 108 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Repo specific
dist/
cov_profile/

# 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
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
.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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.15.0
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deno.enable": true,
"deno.unstable": true,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"cSpell.words": [
"datetimes",
"Deno",
"urbdyn"
]
}
Loading

0 comments on commit 9b3172d

Please sign in to comment.