Skip to content

Commit

Permalink
Merge branch 'master' into consistent-schedule-reps
Browse files Browse the repository at this point in the history
  • Loading branch information
nickevansuk authored Aug 6, 2024
2 parents 9fe086a + 89d924d commit f0b6d32
Show file tree
Hide file tree
Showing 105 changed files with 2,919 additions and 831 deletions.
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
open-pull-requests-limit: 20
schedule:
interval: "daily"
time: "09:00"
timezone: "Europe/London"
ignore:
- dependency-name: "@openactive/*"
groups:
eslint:
dependency-type: "development"
patterns:
- "eslint*"
jasmine:
dependency-type: "development"
patterns:
- "jasmine*"
92 changes: 92 additions & 0 deletions .github/workflows/eslint-auto-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: ESLint Fix
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
# Has dependabot created this PR?
dependabot-metadata:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
outputs:
dependency-group: ${{ steps.metadata.outputs.dependency-group }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Is this PR an eslint upgrade?
lint-test:
runs-on: ubuntu-latest
needs: dependabot-metadata
if: ${{ needs.dependabot-metadata.outputs.dependency-group == 'eslint' }}
outputs:
outcome: ${{ steps.lint-test.outcome }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
run: npm ci
- name: Lint test
id: lint-test
run: npm run lint
# Has the eslint upgrade resulted in lint errors? If so, create a PR to attempt a lint --fix, in case they can be automatically resolved
create-pr:
runs-on: ubuntu-latest
needs: lint-test
if: ${{ always() && needs.lint-test.outputs.outcome == 'failure' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
run: npm ci
- name: Lint Fix
run: npm run lint-fix
- name: git reset to include the version bumps in the PR
run: git reset HEAD~1
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
path: ./
token: ${{ secrets.DEPENDABOT_PUBLIC_REPO_ACCESS_TOKEN }}
commit-message: ESLint --fix
committer: openactive-bot <[email protected]>
author: openactive-bot <[email protected]>
signoff: false
branch: ci/eslint
base: master
delete-branch: true
title: 'ESLint fix'
body: |
Lint fixes based on the latest version of ESLint.
labels: |
automated pr
draft: false
- name: Auto-approve PR
uses: hmarr/auto-approve-action@v3
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge "$PR_URL" --auto --body "" --squash
env:
PR_URL: ${{ steps.cpr.outputs.pull-request-url }}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
20 changes: 20 additions & 0 deletions .github/workflows/npm-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test

on:
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
run: npm install
- name: Test
run: npm test
51 changes: 51 additions & 0 deletions .github/workflows/publish-to-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish to npm

on:
push:
branches: [ master ]

jobs:
publish:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.author.email, '[email protected]')"

steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
- name: Identify
run: |
git config user.name OpenActive Bot
git config user.email [email protected]
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- name: Install
run: npm install
- name: Test
run: npm test
- name: Increment Version
run: npm version patch
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Push version update
run: git push

dispatch:
needs: publish
strategy:
matrix:
repo: ['data-model-validator-site', 'openactive-test-suite']
runs-on: ubuntu-latest
steps:
- name: Trigger tooling update
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
repository: openactive/${{ matrix.repo }}
event-type: data-model-validator-update
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ typings/

# IDE
.vscode

# Validator cache
tmp
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12.16.3
v14.16.0
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ The rule name you create should:

**OR**

* Set `this.targetFields` to an object map of the fields you are targeting in each model, or a string `'*''` wildcard. Setting the property to `null` means that the rule will be applied once to the whole model. If you target a model, you **MUST** implement `validateField`.

* Set `this.targetFields` to an object map of the fields you are targeting in each model, or a string `'*''` wildcard. Setting the property to `null` means that the rule will be applied once to the whole model. If you target a field, you **MUST** implement `validateField`.
field
Generally speaking, you **SHOULD NOT** implement both `validateModel` and `validateField` in the same rule.

Independently, a rule can also target particular modes of use. It is used to restrict rules which should only apply during a particular usage of the models (e.g. an Order used during one of the booking phases - C1Request, C2Response or PatchOrder). By default, a rule will target all modes.
Expand Down Expand Up @@ -129,7 +129,7 @@ this.targetValidationModes = ['C1Request', 'C2Response'];

Set `this.meta` to explain what the rule is testing for.

Defining this detail here makes it easier for libaries scrape all of the rules that the validator will run.
Defining this detail here makes it easier for libaries to scrape all of the rules that the validator will run.

This meta object should include:

Expand Down Expand Up @@ -195,7 +195,7 @@ this.meta = {
};
```

### validateModel and validateField
### `validateModel` and `validateField`

Only one of these methods is expected to be implemented on each rule.

Expand Down Expand Up @@ -247,6 +247,7 @@ this.createError(
#### Adding to the core library

* You should write a test for your rule.
* Add the rule's file, as well as its test file to tsconfig.json's `include` array, so that TypeScript can check for errors.
* Add the rule to the list in `rules/index`, so that it is processed.

#### Adding to your own application
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The OpenActive data model validator library.

[![Build Status](https://travis-ci.com/openactive/data-model-validator.svg?branch=master)](https://travis-ci.org/openactive/data-model-validator)
[![Tests](https://github.com/openactive/data-model-validator/actions/workflows/npm-test.yml/badge.svg?branch=master)](https://github.com/openactive/data-model-validator/actions/workflows/npm-test.yml)
[![Known Vulnerabilities](https://snyk.io/test/github/openactive/data-model-validator/badge.svg)](https://snyk.io/test/github/openactive/data-model-validator)

## Introduction
Expand All @@ -26,16 +26,16 @@ const { validate } = require('@openactive/data-model-validator');

const data = {
'@context': 'https://openactive.io/',
type: 'Event',
'@type': 'Event',
name: 'Tai chi Class',
url: 'http://www.example.org/events/1',
startDate: '2017-03-22T20:00:00',
activity: 'Tai Chi',
location: {
type: 'Place',
'@type': 'Place',
name: 'ExampleCo Gym',
address: {
type: 'PostalAddress',
'@type': 'PostalAddress',
streetAddress: '1 High Street',
addressLocality: 'Bristol',
postalCode: 'BS1 4SD'
Expand Down Expand Up @@ -146,7 +146,7 @@ const result = await validate(feed, options);

#### type

The validator will detect the type of the model being validated from the `type` property. You can override this by providing a type option.
The validator will detect the type of the model being validated from the `@type` property. You can override this by providing a `type` option.

e.g.

Expand Down Expand Up @@ -229,10 +229,10 @@ To run tests locally, run:
$ npm test
```

The test run will also include a run of [eslint](https://eslint.org/). To run the tests without these, use:
The test run will also include a run of [eslint](https://eslint.org/) and [TypeScript](https://www.typescriptlang.org/). To run the tests without these, use:

```shell
$ npm run test-no-lint
$ npm run run-tests
```

### Contributing
Expand Down
29 changes: 18 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openactive/data-model-validator",
"version": "2.0.39",
"version": "2.0.83",
"description": "A library to allow a developer to validate a JSON document against the OpenActive Modelling Opportunity Specification",
"homepage": "https://openactive.io",
"author": "OpenActive Community <[email protected]>",
Expand All @@ -12,7 +12,7 @@
],
"main": "src/index.js",
"engines": {
"node": "12.16.3"
"node": "14.16.0"
},
"repository": {
"type": "git",
Expand All @@ -23,11 +23,13 @@
},
"license": "MIT",
"dependencies": {
"@openactive/data-models": "^2.0.127",
"@openactive/data-models": "^2.0.294",
"@types/lodash": "^4.14.182",
"axios": "^0.19.2",
"currency-codes": "^1.5.1",
"html-entities": "^1.3.1",
"jsonpath": "^1.0.2",
"lodash": "^4.17.21",
"moment": "^2.24.0",
"rrule": "^2.6.2",
"striptags": "^3.1.1",
Expand All @@ -36,18 +38,23 @@
"write-file-atomic": "^3.0.3"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.1",
"eslint-plugin-import": "^2.20.0",
"jasmine": "^3.5.0",
"nock": "^10.0.6"
"@types/jasmine": "^5.1.4",
"@types/jasmine-expect": "^3.8.1",
"@types/node": "^20.11.24",
"eslint": "^8.36.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.27.5",
"jasmine": "^4.6.0",
"nock": "^13.3.0",
"sync-request": "^6.1.0",
"typescript": "^5.3.3"
},
"scripts": {
"lint": "eslint \"src/**/*.js\"",
"lint-fix": "eslint \"src/**/*.js\" --fix",
"pretest": "npm run lint",
"test": "npm run test-no-lint",
"test-no-lint": "jasmine",
"pretest": "npm run lint && tsc",
"test": "npm run run-tests",
"run-tests": "jasmine",
"test-debug": "node --inspect-brk -i ./node_modules/jasmine/bin/jasmine.js",
"postpublish": "git push",
"publish-patch": "npm test && git pull && git push && npm version patch && npm publish"
Expand Down
Loading

0 comments on commit f0b6d32

Please sign in to comment.