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

CI for xdpm with GitHub actions #35

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
71 changes: 71 additions & 0 deletions .github/workflows/cli-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: xdpm CI

on: [push]

jobs:
mac:
runs-on: macos-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm link
- run: xdpm -v
- run: xdpm validate
continue-on-error: true
- run: xdpm package
continue-on-error: true
- run: mkdir -p /Users/runner/Library/Application\ Support/Adobe/Adobe\ XD
- run: xdpm install
continue-on-error: true
- run: git clone https://github.com/AdobeXD/plugin-samples.git
- run: xdpm validate
working-directory: ./plugin-samples/quick-start
- run: xdpm package
working-directory: ./plugin-samples/quick-start
- run: echo "{}" > ./manifest.json
working-directory: ./plugin-samples/quick-start
- run: xdpm validate
working-directory: ./plugin-samples/quick-start
continue-on-error: true

windows:
runs-on: windows-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm link
- run: xdpm -v
- run: xdpm validate
continue-on-error: true
- run: xdpm package
continue-on-error: true
- run: md C:\Users\runneradmin\AppData\Local\Packages\Adobe.CC.XD_adky2gkssdxte\LocalState
- run: xdpm install
continue-on-error: true
- run: git clone https://github.com/AdobeXD/plugin-samples.git
- run: xdpm validate
working-directory: ./plugin-samples/quick-start
- run: xdpm package
working-directory: ./plugin-samples/quick-start
- run: echo "{}" > ./manifest.json
working-directory: ./plugin-samples/quick-start
- run: xdpm validate
working-directory: ./plugin-samples/quick-start
continue-on-error: true
3 changes: 2 additions & 1 deletion lib/manifestSchema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const manifestScema = {
required: ["id", "name", "version", "host", "uiEntryPoints"],
required: ["id", "name", "version", "icons", "host", "uiEntryPoints"],
properties: {
id: {
type: "string",
Expand All @@ -20,6 +20,7 @@ const manifestScema = {
minItems: 2,
uniqueItems: true,
items: {
type: "object",
required: ["path", "width", "height"],
properties: {
path: {
Expand Down
20 changes: 13 additions & 7 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@ function validate(manifest, { root, id } = {}) {
let errors = [];
var validate = ajv.compile(manifestScema);
var valid = validate(manifest);

if ( id && manifest.id !== id ) {
errors.push(
`F1001: Manifest 'id' does not match expected id. Saw '${manifest.id}', expected '${id}'.`
);
}

if (!valid) {
errors = validate.errors.map(
e => `${e.dataPath} (${JSON.stringify(e.params)}) -> ${e.message} `
);
}
manifest.icons.forEach((icon, idx) => {
if (!fs.existsSync(path.join(root || ".", icon.path))) {
errors.push(
`W2004: Icon ${idx} has path ${icon.path}, but no icon was found there.`
);
}
});

if (manifest.icons) {
manifest.icons.forEach((icon, idx) => {
if (!fs.existsSync(path.join(root || ".", icon.path))) {
errors.push(
`W2004: Icon ${idx} has path ${icon.path}, but no icon was found there.`
);
}
});
}

return errors;
}

Expand Down