Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a test and github workflows #7

Merged
merged 2 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/release-github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release GitHub

on:
push:
branches: [release/*]

jobs:
create-github-release:
name: Create GitHub Release and Git tag
runs-on: ubuntu-latest
environment: Release
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: cucumber/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/release-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release NPM

on:
push:
branches: [release/*]

jobs:
publish-npm:
name: Publish NPM module
runs-on: ubuntu-latest
environment: Release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: package-lock.json
- run: npm install-test
- uses: cucumber/[email protected]
with:
npm-token: ${{ secrets.NPM_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test

on:
push:
branches:
- main
- renovate/**
pull_request:
branches:
- main
workflow_call:

jobs:
test-javascript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: package-lock.json
- run: npm install-test
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- Add tests and workflows ([#7](https://github.com/cucumber/cucumber-json-schema/pull/7))

## [0.1.0] - 2024-04-18
### Added
- Initial-release
- Initial release

[Unreleased]: https://github.com/cucumber/cucumber-json-schema/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/cucumber/html-formatter/compare/8d0dcd7300b187348157e8ac9e01d45b066dcd1a...v0.1.0
30 changes: 29 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
"license": "MIT",
"files": [
"schemas"
]
],
"devDependencies": {
"@types/node": "^20.12.7",
"jsonschema": "^1.4.1"
},
"scripts": {
"test": "node ./validation.test.mjs"
}
}
25 changes: 25 additions & 0 deletions validation.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {equal} from 'node:assert/strict'
import {readFileSync} from 'node:fs'
import {describe, it} from 'node:test'
import {Validator} from 'jsonschema'

const FILENAMES = [
'behave.json',
'canonical.json',
'cucumber-js.json',
'cucumber-jvm.json',
'cucumber-ruby.json',
]

describe('schema validation', () => {
const validator = new Validator()

FILENAMES.forEach(filename => {
it(filename, async () => {
const schema = JSON.parse(readFileSync('./schemas/' + filename, {encoding: 'utf-8'}))
const metaSchema = await fetch(schema['$schema']).then(response => response.json())
const result = validator.validate(schema, metaSchema)
equal(result.valid, true)
})
})
})