Skip to content

Commit

Permalink
Proof of Concept (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Aug 22, 2022
1 parent 50dd769 commit 3a024ad
Show file tree
Hide file tree
Showing 81 changed files with 22,847 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"airbnb-base",
"airbnb-typescript/base"
],
"plugins": [
"@typescript-eslint",
"simple-import-sort"
],

"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module"
},
"ignorePatterns": ["build/**"],

"rules": {
"@typescript-eslint/prefer-readonly": "error",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error"
}
}
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Publish Package to npmjs

on:
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- 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 }}
150 changes: 150 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
# https://hanxiao.io/2021/01/24/Speedup-CI-Workflow-in-Github-Actions-via-Strategy-Matrix/

name: Node.js CI

on:
push:

jobs:
test-lint:
runs-on: ubuntu-latest
steps:
# Setup and install
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: 'npm'
- run: npm ci

# Lint the source files
- run: ./node_modules/.bin/ts-node ./index.ts --help
- run: npm run lint

test-unit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# TODO(cemmer): os.devNull in tests needs v14.18.0+ or v16.3.0+, test-e2e can cover 12.x
node-version: [ lts/*, lts/-1 ]
steps:
# Setup and install
- 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

# Test the source files
- run: npm run test:unit

test-e2e:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ lts/*, lts/-1, lts/-2 ]
steps:
# Setup and install
- 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

# Test the built files
- run: npm run build
- run: ./test/endToEndTest.sh

test-package:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ lts/*, lts/-1, lts/-2 ]
steps:
# Setup and install
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci

# Test the packaging
- run: |
npm pack
tar -xvzf igir-*.tgz
cd package
npm install --ignore-scripts
./build/index.js --help
cd ..
rm -rf package
codecov:
needs:
- test-lint
- test-unit
- test-e2e
- test-package
runs-on: ubuntu-latest
steps:
# Setup and install
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: 'npm'
- run: npm ci

# Run test coverage
- run: npm run test:coverage
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true

status-check:
needs:
- test-lint
- test-unit
- test-e2e
- test-package
- codecov
runs-on: ubuntu-latest
steps:
- run: echo ok

# version-check:
# if: github.ref_name == 'main'
# runs-on: ubuntu-latest
# steps:
# # Setup and install
# - uses: actions/checkout@v3
#
# # Check if version has changed
# - name: Check if version has been updated
# id: check
# uses: EndBug/version-check@v1
# - name: Log when changed
# if: steps.check.outputs.changed == 'true'
# run: 'echo "Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"'
# - run: echo ::set-output changed=${{steps.check.outputs.changed}}
#
# github-release:
# if: github.ref_name == 'main' && jobs.version-check.outputs.changed == 'true'
# needs:
# - status-check
# - version-check
# runs-on: ubuntu-latest
# steps:
# # Setup and install
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# cache: 'npm'
# - run: npm ci
# - run: npm run release:patch -- --ci
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,32 @@ dist

# TernJS port file
.tern-port


# Custom
build/
*.dat
*.dtd

# ROMs
*.7z
*.gb
*.gba
*.gbc
*.rom
*.zip

# ROM pack excess
*.jpg
*.png
*.sqlite
*.torrent
*.txt
*.xml

# Always commit fixtures
!test/fixtures/dats/*
!test/fixtures/dats/*/*
!test/fixtures/roms/*
!test/fixtures/roms/*/*
.DS_Store
35 changes: 35 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Change to the project's root directory
cd "$(dirname -- "$0")/.." || exit 1

# Ensure node is available
if [[ ! -x "$(command -v node)" ]]; then
if [[ ! -x "$(command -v nvm)" && -f ~/.nvm/nvm.sh ]]; then
. ~/.nvm/nvm.sh
fi
if [[ ! -x "$(command -v nvm)" ]]; then
nvm use || exit 1
fi
fi
node --version &> /dev/null || exit 1

# Follow the linter
npm run lint:fix

# Make sure igir is symlinked
npm link --force

# Update the help text in README.md
npm run build
README="README.md"
README_BEFORE=$(cat "${README}")
(awk 'BEGIN {msg=ARGV[1]; delete ARGV[1]; p=1} /^```help/ {print; print msg; p=0} /^```$/ {p=1} p' \
"$(igir --help)" \
"${README}" > "${README}.temp" || exit 1) && mv -f "${README}.temp" "${README}"
README_AFTER=$(cat "${README}")
if [[ "${README_AFTER}" != "${README_BEFORE}" ]]; then
# TODO(cemmer): way to not commit the entire file when the help text changes?
git add "${README}"
fi
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.16.0
18 changes: 18 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"hooks": {
"after:npm:bump": "npm pack",
"after:git:release": "echo After git push, before github release",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
},
"git": {
"requireBranch": "main",
"commit": false,
"tagName": "v${version}"
},
"github": {
"release": true,
"releaseName": "${version}",
"assets": ["igir-${version}.tgz"]
},
"npm": false
}
Loading

0 comments on commit 3a024ad

Please sign in to comment.