-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the initial implementation of Schemar.
- Loading branch information
1 parent
2b12e80
commit a3e8624
Showing
41 changed files
with
41,146 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INPUT_URLS="https://johnnyreilly.com" # will pass | ||
# INPUT_URLS="https://news.ycombinator.com/" # will fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
!.* | ||
lib | ||
dist | ||
node_modules | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# In TypeScript actions, `dist/` is a special directory. When you reference | ||
# an action with the `uses:` property, `dist/index.js` is the code that will be | ||
# run. For this project, the `dist/index.js` file is transpiled from other | ||
# source files. This workflow ensures the `dist/` directory contains the | ||
# expected transpiled code. | ||
# | ||
# If this workflow is run from a feature branch, it will act as an additional CI | ||
# check and fail if the checked-in `dist/` directory does not match what is | ||
# expected from the build. | ||
name: Check transpiled JavaScript in dist is up to date | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check-dist: | ||
name: check dist | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/prepare | ||
|
||
- name: Build dist directory | ||
id: build | ||
run: pnpm run build:release | ||
|
||
# This will fail the workflow if the PR wasn't created by Dependabot. | ||
- name: Compare directories | ||
id: diff | ||
run: | | ||
if [ "$(git diff --ignore-space-at-eol --text dist/index.js | wc -l)" -gt "0" ]; then | ||
echo "Detected uncommitted changes after build." | ||
echo "You may need to run 'pnpm run build:release' locally and commit the changes." | ||
echo "" | ||
echo "See diff below:" | ||
echo "" | ||
git diff --ignore-space-at-eol --text dist/index.js | ||
echo "" | ||
# say this again in case the diff is long | ||
echo "You may need to run 'pnpm run build:release' locally and commit the changes." | ||
echo "" | ||
exit 1 | ||
fi | ||
# If `dist/` was different than expected, and this was not a Dependabot | ||
# PR, upload the expected version as a workflow artifact. | ||
- if: ${{ failure() && steps.diff.outcome == 'failure' }} | ||
name: Upload artifact | ||
id: upload | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/prepare | ||
- run: pnpm run test | ||
|
||
- name: Test local action | ||
id: test-action | ||
uses: ./ | ||
with: | ||
urls: https://johnnyreilly.com | ||
|
||
name: Test | ||
|
||
on: | ||
pull_request: ~ | ||
push: | ||
branches: | ||
- main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
pnpm run build:release | ||
git add dist | ||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
lib/ | ||
dist/ | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug Action", | ||
"skipFiles": ["<node_internals>/**"], | ||
"program": "lib/index.js", | ||
"preLaunchTask": "build:debug", | ||
"envFile": "${workspaceFolder}/.env" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "build:debug", | ||
"label": "build:debug", | ||
"detail": "Build the project for debugging" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,51 @@ | |
<a href="https://github.com/johnnyreilly/schemar/blob/main/LICENSE.md" target="_blank"><img alt="License: MIT" src="https://img.shields.io/github/license/johnnyreilly/schemar?color=21bb42"></a> | ||
<img alt="Style: Prettier" src="https://img.shields.io/badge/style-prettier-21bb42.svg" /> | ||
<img alt="TypeScript: Strict" src="https://img.shields.io/badge/typescript-strict-21bb42.svg" /> | ||
<img alt="npm package version" src="https://img.shields.io/npm/v/schemar?color=21bb42" /> | ||
</p> | ||
|
||
## Usage | ||
|
||
This action works by: | ||
|
||
1. Checking the supplied URL features structured data using the [Schema.org validator](https://validator.schema.org/) | ||
2. If no structured data is found, the action fails. It also fails if the structured data is invalid. | ||
|
||
```yml | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: johnnyreilly/[email protected] | ||
with: | ||
urls: https://johnnyreilly.com | ||
|
||
name: Validate structured data | ||
|
||
on: | ||
pull_request: ~ | ||
push: | ||
branches: | ||
- main | ||
``` | ||
## Development | ||
To develop this GitHub Action, you'll need Node.js 20 and pnpm. Then install the dependencies: | ||
```shell | ||
npm i schemar | ||
pnpm i | ||
``` | ||
|
||
```ts | ||
import { greet } from "schemar"; | ||
To run the action locally you can either use the `debug` script: | ||
|
||
greet("Hello, world! 💖"); | ||
```shell | ||
pnpm run debug | ||
``` | ||
|
||
Or debug in VS Code using the `Debug Action` launch configuration. | ||
|
||
Whichever you use, you configure inputs using the [.env](./.env) file. | ||
|
||
<!-- You can remove this notice if you don't want it 🙂 no worries! --> | ||
|
||
> 💙 This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: "Schemar" | ||
description: "Validate structured data on a website" | ||
author: "johnnyreilly" | ||
|
||
# Add your action's branding here. This will appear on the GitHub Marketplace. | ||
branding: | ||
icon: "check-square" | ||
color: "green" | ||
|
||
# Define your inputs here. | ||
inputs: | ||
urls: | ||
description: "List of URL(s) to analyze" | ||
required: true | ||
|
||
# Define your outputs here. | ||
outputs: | ||
results: | ||
description: "An array of the results: Result[]" | ||
|
||
processedValidationResult: | ||
description: "The processed validation result" | ||
|
||
runs: | ||
using: node20 | ||
main: dist/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./validationResult.js"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.