├── .eslintignore ├── .prettierignore ├── __tests__ ├── test.yml ├── main.test.ts └── resources │ ├── failing.ipynb │ ├── passing.ipynb │ └── sub dir │ └── another passing.ipynb ├── docs └── screen.png ├── .github ├── workflows │ ├── action_npm_test.yml │ ├── action_integration_test.yml │ └── action_unit_test.yml └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── .prettierrc.json ├── jest.config.js ├── tsconfig.json ├── src ├── logging.ts └── main.ts ├── package.json ├── action.yml ├── README.md ├── .eslintrc.json ├── CODE_OF_CONDUCT.md ├── .gitignore └── LICENSE /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /__tests__/test.yml: -------------------------------------------------------------------------------- 1 | notebook-env: | 2 | FOO='bar' 3 | baz=42 4 | blah: true -------------------------------------------------------------------------------- /docs/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/treebeardtech/nbmake-action/HEAD/docs/screen.png -------------------------------------------------------------------------------- /.github/workflows/action_npm_test.yml: -------------------------------------------------------------------------------- 1 | name: Action NPM Test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | npm: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - run: npm install 11 | - run: npm test 12 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": false, 9 | "arrowParens": "avoid", 10 | "parser": "typescript" 11 | } -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | clearMocks: true, 3 | moduleFileExtensions: ['js', 'ts'], 4 | testEnvironment: 'node', 5 | testMatch: ['**/*.test.ts'], 6 | testRunner: 'jest-circus/runner', 7 | transform: { 8 | '^.+\\.ts$': 'ts-jest' 9 | }, 10 | verbose: true 11 | } -------------------------------------------------------------------------------- /__tests__/main.test.ts: -------------------------------------------------------------------------------- 1 | import {Logger} from '../src/logging' 2 | 3 | test('log test event', async () => { 4 | const logger = new Logger() 5 | process.env.GITHUB_REPOSITORY = 'treebeardtech/test' 6 | process.env.GITHUB_RUN_ID = 'test' 7 | process.env.GITHUB_SHA = '' 8 | process.env.GITHUB_REF = '' 9 | 10 | const success = await logger.logUsage('TEST') 11 | // expect(success).toBe(true) 12 | }) 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /__tests__/resources/failing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "source": [ 5 | "# title" 6 | ], 7 | "cell_type": "markdown", 8 | "metadata": {} 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": null, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "raise Exception()" 17 | ] 18 | } 19 | ], 20 | "metadata": { 21 | "language_info": { 22 | "codemirror_mode": { 23 | "name": "ipython", 24 | "version": 3 25 | }, 26 | "file_extension": ".py", 27 | "mimetype": "text/x-python", 28 | "name": "python", 29 | "nbconvert_exporter": "python", 30 | "pygments_lexer": "ipython3", 31 | "version": 3 32 | } 33 | }, 34 | "nbformat": 4, 35 | "nbformat_minor": 2 36 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/workflows/action_integration_test.yml: -------------------------------------------------------------------------------- 1 | name: Action Integration Test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test-elastix: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | with: 11 | repository: InsightSoftwareConsortium/ITKElastix 12 | ref: 9e3402f558f215c0024033c8d63ef9e081df1b45 13 | - uses: actions/checkout@v2 14 | with: 15 | path: nbmake-action 16 | - name: Set Up Python 17 | uses: actions/setup-python@v2 18 | with: 19 | python-version: 3.7 20 | - run: | 21 | cd examples 22 | pip install -r requirements.txt 23 | 24 | pip install pytest-tornasync 25 | python -m ipykernel install --user --name elastixenv 26 | python -m ipykernel install --user --name elastixenv2 27 | python -m ipykernel install --user --name itktestenvdebug 28 | - uses: ./nbmake-action 29 | with: 30 | notebooks: examples/*.ipynb 31 | path-output: . 32 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 5 | "outDir": "./lib", /* Redirect output structure to the directory. */ 6 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 7 | "strict": true, /* Enable all strict type-checking options. */ 8 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 9 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 10 | }, 11 | "exclude": ["node_modules", "**/*.test.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /src/logging.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import * as core from '@actions/core' 3 | 4 | export async function isOpenUsageLoggingEnabled(): Promise { 5 | const loggingFlag = core.getInput('open-usage-logging') 6 | if (loggingFlag !== 'true') { 7 | return false 8 | } 9 | 10 | try { 11 | // Is repo public? 12 | await axios.get(`https://github.com/${process.env.GITHUB_REPOSITORY}`) 13 | return true 14 | } catch { 15 | return false 16 | } 17 | } 18 | 19 | export class Logger { 20 | private startTime: Date = new Date() 21 | 22 | async logUsage(status: string): Promise { 23 | try { 24 | const env = process.env 25 | const url = `https://api.treebeard.io/${env.GITHUB_REPOSITORY}/${env.GITHUB_RUN_ID}/log` 26 | const r = await axios.post(url, { 27 | status, 28 | start_time: this.startTime.toISOString(), 29 | end_time: new Date().toISOString(), 30 | sha: env.GITHUB_SHA, 31 | branch: env.GITHUB_REF 32 | }) 33 | return r.status === 200 && r.data === '' 34 | } catch { 35 | return false 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-action", 3 | "version": "0.0.0", 4 | "private": true, 5 | "description": "TypeScript template action", 6 | "main": "lib/main.js", 7 | "scripts": { 8 | "build": "tsc", 9 | "format": "prettier --write **/*.ts", 10 | "format-check": "prettier --check **/*.ts", 11 | "lint": "eslint src/**/*.ts", 12 | "pack": "ncc build", 13 | "test": "jest", 14 | "all": "npm run build && npm run format && npm run lint && npm run pack && npm test" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/actions/typescript-action.git" 19 | }, 20 | "keywords": [ 21 | "actions", 22 | "node", 23 | "setup" 24 | ], 25 | "author": "YourNameOrOrganization", 26 | "license": "MIT", 27 | "dependencies": { 28 | "@actions/core": "^1.2.0", 29 | "@actions/exec": "^1.0.4", 30 | "axios": "^0.19.2", 31 | "dotenv": "^8.2.0", 32 | "fast-glob": "^3.2.4", 33 | "yaml": "^1.10.0" 34 | }, 35 | "devDependencies": { 36 | "@types/jest": "^24.0.23", 37 | "@types/node": "^12.7.12", 38 | "@typescript-eslint/parser": "^2.8.0", 39 | "@zeit/ncc": "^0.20.5", 40 | "eslint": "^5.16.0", 41 | "eslint-plugin-github": "^2.0.0", 42 | "eslint-plugin-jest": "^22.21.0", 43 | "jest": "^24.9.0", 44 | "jest-circus": "^24.9.0", 45 | "js-yaml": "^3.13.1", 46 | "prettier": "^1.19.1", 47 | "ts-jest": "^24.2.0", 48 | "typescript": "^3.6.4" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /__tests__/resources/passing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "source": [ 5 | "# title" 6 | ], 7 | "cell_type": "markdown", 8 | "metadata": {} 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": null, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "print(\"hello\")" 17 | ] 18 | } 19 | ], 20 | "metadata": { 21 | "kernelspec": { 22 | "display_name": "Python 3", 23 | "language": "python", 24 | "name": "python3" 25 | }, 26 | "language_info": { 27 | "codemirror_mode": { 28 | "name": "ipython", 29 | "version": 3 30 | }, 31 | "file_extension": ".py", 32 | "mimetype": "text/x-python", 33 | "name": "python", 34 | "nbconvert_exporter": "python", 35 | "pygments_lexer": "ipython3", 36 | "version": "3.7.6" 37 | }, 38 | "papermill": { 39 | "duration": 33.463593, 40 | "end_time": "2020-04-01T16:53:11.649912", 41 | "environment_variables": {}, 42 | "exception": null, 43 | "input_path": "main.ipynb", 44 | "output_path": "main.ipynb", 45 | "parameters": {}, 46 | "start_time": "2020-04-01T16:52:38.186319", 47 | "version": "2.1.0" 48 | }, 49 | "toc": { 50 | "base_numbering": 1, 51 | "nav_menu": {}, 52 | "number_sections": true, 53 | "sideBar": true, 54 | "skip_h1_title": false, 55 | "title_cell": "Table of Contents", 56 | "title_sidebar": "Contents", 57 | "toc_cell": false, 58 | "toc_position": {}, 59 | "toc_section_display": true, 60 | "toc_window_display": false 61 | } 62 | }, 63 | "nbformat": 4, 64 | "nbformat_minor": 4 65 | } -------------------------------------------------------------------------------- /__tests__/resources/sub dir/another passing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "source": [ 5 | "# title" 6 | ], 7 | "cell_type": "markdown", 8 | "metadata": {} 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": null, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "print(\"hello\")" 17 | ] 18 | } 19 | ], 20 | "metadata": { 21 | "kernelspec": { 22 | "display_name": "Python 3", 23 | "language": "python", 24 | "name": "python3" 25 | }, 26 | "language_info": { 27 | "codemirror_mode": { 28 | "name": "ipython", 29 | "version": 3 30 | }, 31 | "file_extension": ".py", 32 | "mimetype": "text/x-python", 33 | "name": "python", 34 | "nbconvert_exporter": "python", 35 | "pygments_lexer": "ipython3", 36 | "version": "3.7.6" 37 | }, 38 | "papermill": { 39 | "duration": 33.463593, 40 | "end_time": "2020-04-01T16:53:11.649912", 41 | "environment_variables": {}, 42 | "exception": null, 43 | "input_path": "main.ipynb", 44 | "output_path": "main.ipynb", 45 | "parameters": {}, 46 | "start_time": "2020-04-01T16:52:38.186319", 47 | "version": "2.1.0" 48 | }, 49 | "toc": { 50 | "base_numbering": 1, 51 | "nav_menu": {}, 52 | "number_sections": true, 53 | "sideBar": true, 54 | "skip_h1_title": false, 55 | "title_cell": "Table of Contents", 56 | "title_sidebar": "Contents", 57 | "toc_cell": false, 58 | "toc_position": {}, 59 | "toc_section_display": true, 60 | "toc_window_display": false 61 | } 62 | }, 63 | "nbformat": 4, 64 | "nbformat_minor": 4 65 | } -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "nbmake" 2 | author: "treebeardtech" 3 | description: "Test notebooks" 4 | inputs: 5 | notebooks: 6 | description: "Newline-delimited list of glob patterns of ipynb files to test" 7 | required: false 8 | default: "**/*ipynb" 9 | 10 | ignore: 11 | description: > 12 | Newline-delimited list of glob patterns of ipynb files to ignore. This is not the same as pytest `glob-ignore`. 13 | 14 | Read src/main.ts for details. 15 | required: false 16 | default: "" 17 | 18 | workdir: 19 | description: "workdir that pytest --nbmake is called from" 20 | required: false 21 | default: "." 22 | 23 | path-output: 24 | description: "Create an html report to `{path_output}_build/html`" 25 | required: false 26 | 27 | overwrite: 28 | description: > 29 | Write notebooks back into the repo directory. 30 | This allows you to commit them to the repo or run additional build tools on the outputs e.g. jupyter-book" 31 | required: false 32 | default: "false" 33 | 34 | verbose: 35 | description: "Show debug information" 36 | required: false 37 | default: "false" 38 | 39 | extra-pytest-args: 40 | description: "Newline-delimited list of pytest args" 41 | required: false 42 | default: "" 43 | 44 | open-usage-logging: 45 | description: > 46 | Provide usage metadata to treebeardtech when used in *open source repos*. 47 | 48 | This allows me to fix issues without you reporting them. 49 | required: false 50 | default: "true" 51 | 52 | runs: 53 | using: "node12" 54 | main: "dist/index.js" 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **⚠️ Please use [nbmake](https://github.com/treebeardtech/nbmake) instead** 2 | 3 | # nbmake-action 4 | 5 | (repo renamed from 'treebeard'). 6 | 7 | **What?** A GitHub Action for testing notebooks, runs them from top-to-bottom 8 | 9 | **Why?** To raise the quality of scientific material through better automation 10 | 11 | **Who is this for?** Scientists/Developers who have written docs in notebooks and want to CI test them after every commit 12 | 13 | ## Functionality 14 | 15 | Tests notebooks using [nbmake](https://github.com/treebeardtech/nbmake) via pytest. 16 | 17 | **Note: If you have some experience setting up GitHub actions already you will probably prefer the flexibility of using the `nbmake` pip package directly.** 18 | 19 | ## Quick Start 20 | 21 | ```yaml 22 | - uses: actions/checkout@v2 23 | - uses: actions/setup-python@v2 24 | - uses: "treebeardtech/nbmake-action@v0.2" 25 | with: 26 | path: "./examples" 27 | path-output: . 28 | notebooks: | 29 | nb1.ipynb 30 | 'sub dir/*.ipynb' 31 | ``` 32 | 33 | See [action.yml](action.yml) for the parameters you can pass to this action, and see [unit tests](.github/workflows/action_unit_test.yml) and [integ tests](.github/workflows/action_integration_test.yml) for example invocations. 34 | 35 | ## Developing 36 | 37 | ### Install local package 38 | ``` 39 | npm install 40 | ``` 41 | 42 | ### Run checks and build 43 | ``` 44 | npm run all 45 | ``` 46 | 47 | ## See Also 48 | 49 | - [nbmake](https://github.com/treebeardtech/nbmake) 50 | - [jupyter book](https://github.com/executablebooks/jupyter-book) 51 | - [Guide to python dependency management choices](https://towardsdatascience.com/devops-for-data-science-making-your-python-project-reproducible-f55646e110fa) 52 | -------------------------------------------------------------------------------- /.github/workflows/action_unit_test.yml: -------------------------------------------------------------------------------- 1 | name: Action Unit Test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | unit-test: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | cfg: 11 | - os: ubuntu-latest 12 | python-version: "3.6" 13 | - os: ubuntu-latest 14 | python-version: "3.7" 15 | - os: ubuntu-latest 16 | python-version: "3.8" 17 | - os: ubuntu-latest 18 | python-version: "3.9" 19 | - os: macos-latest 20 | python-version: "3.6" 21 | - os: macos-latest 22 | python-version: "3.7" 23 | - os: macos-latest 24 | python-version: "3.8" 25 | - os: macos-latest 26 | python-version: "3.9" 27 | runs-on: ${{ matrix.cfg.os }} 28 | steps: 29 | - uses: actions/checkout@v2 30 | - uses: actions/setup-python@v2 31 | with: 32 | python-version: ${{ matrix.cfg.python-version }} 33 | - uses: "./" 34 | name: run_passing_nbs 35 | with: 36 | workdir: "./__tests__/resources" 37 | notebooks: | 38 | passing.ipynb 39 | 'sub dir/another passing.ipynb' 40 | path-output: . 41 | extra-pytest-args: | 42 | --capture=tee-sys 43 | -v 44 | - uses: "./" 45 | name: glob_passing_nbs 46 | with: 47 | workdir: "./__tests__/resources" 48 | notebooks: | 49 | sub dir/* 50 | - uses: "./" 51 | name: ignore_failing_nb 52 | with: 53 | workdir: "./__tests__/resources" 54 | ignore: | 55 | failing.ipynb 56 | verbose: true 57 | path-output: . 58 | - uses: "./" 59 | name: glob_ignore_nbs 60 | with: 61 | workdir: "./__tests__/resources" 62 | ignore: | 63 | *.ipynb 64 | verbose: true 65 | - uses: "./" 66 | name: fail_running_all 67 | id: run 68 | with: 69 | workdir: "./__tests__/resources" 70 | verbose: true 71 | continue-on-error: true 72 | - run: '[[ ${{ steps.run.outcome }} == "failure" ]]' 73 | shell: bash 74 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import * as exec from '@actions/exec' 3 | import * as fg from 'fast-glob' 4 | import {isOpenUsageLoggingEnabled, Logger} from './logging' 5 | import * as path from 'path' 6 | const isLoggingEnabled = isOpenUsageLoggingEnabled() 7 | 8 | async function run(): Promise { 9 | const logger = isLoggingEnabled ? new Logger() : null 10 | try { 11 | const notebooks = core.getInput('notebooks') 12 | const ignore = core.getInput('ignore') 13 | const workdir = core.getInput('workdir') 14 | const pathOutput = 15 | core.getInput('path-output') && path.resolve(core.getInput('path-output')) 16 | const verbose = core.getInput('verbose').toLowerCase() === 'true' 17 | const overwrite = core.getInput('overwrite').toLowerCase() === 'true' 18 | const extraPytestArgs = core.getInput('extra-pytest-args') 19 | 20 | process.chdir(workdir) 21 | 22 | if (verbose) { 23 | await exec.exec('bash', ['-c', 'pwd && ls -la']) 24 | } 25 | 26 | core.startGroup('Install test packages') 27 | // const pkg = `git+https://github.com/treebeardtech/nbmake.git@main${ 28 | // pathOutput ? '#egg=nbmake[html]' : '' 29 | // }` 30 | const pkg = `nbmake${pathOutput ? '[html]' : ''}==0.1` 31 | await exec.exec(`pip install ${pkg}`) 32 | core.endGroup() 33 | 34 | const paths = notebooks.split('\n').filter(n => n) 35 | const ignores = ignore.split('\n').filter(i => i) 36 | 37 | const nbs = fg.sync(paths, {ignore: ignores}).map(nb => `'${nb}'`) 38 | const args = ['pytest', '--nbmake'] 39 | 40 | if (pathOutput) { 41 | args.push(`--path-output=${pathOutput}`) 42 | } 43 | 44 | args.push(...nbs) 45 | args.push(...extraPytestArgs.split('\n').filter(i => i)) 46 | 47 | const command = args.join(' ') 48 | if (verbose) { 49 | args.push('-v') 50 | console.log(`cmd: ${command}`) 51 | } 52 | 53 | if (overwrite) { 54 | args.push('--overwrite') 55 | } 56 | 57 | await exec.exec('bash', ['-c', command]) 58 | 59 | if (logger) { 60 | logger.logUsage('SUCCESS') 61 | } 62 | } catch (error) { 63 | if (logger) { 64 | logger.logUsage('FAILURE') 65 | } 66 | core.setFailed(error.message) 67 | } 68 | } 69 | 70 | run() 71 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["jest", "@typescript-eslint"], 3 | "extends": ["plugin:github/es6"], 4 | "parser": "@typescript-eslint/parser", 5 | "parserOptions": { 6 | "ecmaVersion": 9, 7 | "sourceType": "module", 8 | "project": "./tsconfig.json" 9 | }, 10 | "rules": { 11 | "no-console": "off", 12 | "eslint-comments/no-use": "off", 13 | "import/no-namespace": "off", 14 | "no-unused-vars": "off", 15 | "@typescript-eslint/no-unused-vars": "error", 16 | "@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}], 17 | "@typescript-eslint/no-require-imports": "error", 18 | "@typescript-eslint/array-type": "error", 19 | "@typescript-eslint/await-thenable": "error", 20 | "@typescript-eslint/ban-ts-ignore": "error", 21 | "camelcase": "off", 22 | "@typescript-eslint/camelcase": "warn", 23 | "@typescript-eslint/class-name-casing": "error", 24 | "@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}], 25 | "@typescript-eslint/func-call-spacing": ["error", "never"], 26 | "@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"], 27 | "@typescript-eslint/no-array-constructor": "error", 28 | "@typescript-eslint/no-empty-interface": "error", 29 | "@typescript-eslint/no-explicit-any": "error", 30 | "@typescript-eslint/no-extraneous-class": "error", 31 | "@typescript-eslint/no-for-in-array": "error", 32 | "@typescript-eslint/no-inferrable-types": "error", 33 | "@typescript-eslint/no-misused-new": "error", 34 | "@typescript-eslint/no-namespace": "error", 35 | "@typescript-eslint/no-non-null-assertion": "warn", 36 | "@typescript-eslint/no-object-literal-type-assertion": "error", 37 | "@typescript-eslint/no-unnecessary-qualifier": "error", 38 | "@typescript-eslint/no-unnecessary-type-assertion": "error", 39 | "@typescript-eslint/no-useless-constructor": "error", 40 | "@typescript-eslint/no-var-requires": "error", 41 | "@typescript-eslint/prefer-for-of": "warn", 42 | "@typescript-eslint/prefer-function-type": "warn", 43 | "@typescript-eslint/prefer-includes": "error", 44 | "@typescript-eslint/prefer-interface": "error", 45 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 46 | "@typescript-eslint/promise-function-async": "error", 47 | "@typescript-eslint/require-array-sort-compare": "error", 48 | "@typescript-eslint/restrict-plus-operands": "error", 49 | "semi": "off", 50 | "@typescript-eslint/semi": ["error", "never"], 51 | "@typescript-eslint/type-annotation-spacing": "error", 52 | "@typescript-eslint/unbound-method": "error", 53 | "no-inner-declarations": "off" 54 | }, 55 | "env": { 56 | "node": true, 57 | "es6": true, 58 | "jest/globals": true 59 | } 60 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at alex@treebeard.io. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | treebeard-lib/dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | output/* 132 | .vscode 133 | .treebeard 134 | .DS_store 135 | 136 | typeshed 137 | 138 | # Node stuff 139 | # Dependency directory 140 | node_modules 141 | 142 | # Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore 143 | # Logs 144 | logs 145 | *.log 146 | npm-debug.log* 147 | yarn-debug.log* 148 | yarn-error.log* 149 | lerna-debug.log* 150 | 151 | # Diagnostic reports (https://nodejs.org/api/report.html) 152 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 153 | 154 | # Runtime data 155 | pids 156 | *.pid 157 | *.seed 158 | *.pid.lock 159 | 160 | # Directory for instrumented libs generated by jscoverage/JSCover 161 | lib-cov 162 | 163 | # Coverage directory used by tools like istanbul 164 | coverage 165 | *.lcov 166 | 167 | # nyc test coverage 168 | .nyc_output 169 | 170 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 171 | .grunt 172 | 173 | # Bower dependency directory (https://bower.io/) 174 | bower_components 175 | 176 | # node-waf configuration 177 | .lock-wscript 178 | 179 | # Compiled binary addons (https://nodejs.org/api/addons.html) 180 | build/Release 181 | 182 | # Dependency directories 183 | jspm_packages/ 184 | 185 | # TypeScript v1 declaration files 186 | typings/ 187 | 188 | # TypeScript cache 189 | *.tsbuildinfo 190 | 191 | # Optional npm cache directory 192 | .npm 193 | 194 | # Optional eslint cache 195 | .eslintcache 196 | 197 | # Optional REPL history 198 | .node_repl_history 199 | 200 | # Output of 'npm pack' 201 | treebeard-lib/*.tgz 202 | 203 | # Yarn Integrity file 204 | .yarn-integrity 205 | 206 | # dotenv environment variables file 207 | .env 208 | .env.test 209 | 210 | # parcel-bundler cache (https://parceljs.org/) 211 | .cache 212 | 213 | # next.js build output 214 | .next 215 | 216 | # nuxt.js build output 217 | .nuxt 218 | 219 | # vuepress build output 220 | .vuepress/dist 221 | 222 | # Serverless directories 223 | .serverless/ 224 | 225 | # FuseBox cache 226 | .fusebox/ 227 | 228 | # DynamoDB Local files 229 | .dynamodb/ 230 | 231 | # OS metadata 232 | .DS_Store 233 | Thumbs.db 234 | 235 | # Ignore built ts files 236 | __tests__/runner/* 237 | lib/**/* 238 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. --------------------------------------------------------------------------------