Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmost committed Jun 7, 2024
0 parents commit f3897d7
Show file tree
Hide file tree
Showing 16 changed files with 652 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test-raw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test Raw Json
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test Local Action
uses: ./
with:
source-file: test/test.schema.json
out-langs: ts,rs
no-json-schema: true
- name: Upload files
uses: actions/upload-artifact@v4
with:
name: bindings
path: |
./test.ts
./test.rs
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test Local Action
uses: ./
with:
source-file: test/test.schema.json
out-langs: ts,rs
- name: Upload files
uses: actions/upload-artifact@v4
with:
name: bindings
path: |
./test.ts
./test.rs
105 changes: 105 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Dependency directory
node_modules

lib

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# 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
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# 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 output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*

# IDE files
.idea
.vscode
*.code-workspace
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
npx lint-staged
npx lint-staged
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.6.0
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
coverage/
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# quicktype-gha

A GitHub Action for generating type bindings from JSON schema files

## Inputs

### `source-file`

Schema JSON file to generate type bindings from.

### `out-langs`

Comma-separated list of language extensions to generate bindings for

### `out-dir` (optional)

Directory to output generated bindings to

## Example Usage

You can use this action to generate artifacts with the type bindings in your preferred languages.

For example, you might design a workflow to generate bindings for both TypeScript and Rust, e.g.

```yml
name: Build
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: API Schema
uses: thomasmost/[email protected]
with:
source-file: data_objects/api.schema.json
out-langs: ts,rs
- name: Upload files
uses: actions/upload-artifact@v4
with:
name: bindings
path: |
./api.ts
./api.rs
```
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Valjean JSON Schema Validator"
description: "Validate JSON using remote schemas"

branding:
label: "Valjean JSON Schema Validator"
icon: "book"
color: "red"

inputs:
schema-url:
description: "the url to the JSON schema"
required: true
target-dir:
description: "the directory (or directories, comma separated) containing the json files to validate"
required: true

runs:
using: "node20"
main: "dist/index.js"
11 changes: 11 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "gha-valjean",
"version": "0.3.0",
"description": "",
"main": "index.js",
"packageManager": "[email protected]",
"scripts": {
"all": "pnpm run format:write && pnpm run build",
"build": "tsc && ncc build lib/index.js --minify",
"format:check": "pnpm exec prettier --check .",
"format:write": "pnpm exec prettier --write .",
"prepare": "husky install",
"test": "pnpm exec jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@vercel/ncc": "^0.38.1",
"ajv": "^8.16.0"
},
"devDependencies": {
"@types/node": "^20.12.12",
"husky": "^9.0.11",
"prettier": "^3.2.5",
"typescript": "^5.4.5"
},
"lint-staged": {
"*.{js,css,md}": "prettier --write"
}
}
Loading

0 comments on commit f3897d7

Please sign in to comment.