Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit fa10629

Browse files
author
Bassem Dghaidi
authored
Merge pull request #16 from mena-devs/cd-pipeline
Upgrade CI/CD pipelines
2 parents b481313 + f401667 commit fa10629

File tree

8 files changed

+3686
-105
lines changed

8 files changed

+3686
-105
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: Publish NPM
1+
name: Publish to npm
22

33
on:
4+
push:
5+
tags:
6+
- '[0-9].[0-9]+.[0-9]+'
47
release:
58
types: [published]
69

@@ -13,7 +16,10 @@ jobs:
1316
with:
1417
node-version: 10
1518
registry-url: https://registry.npmjs.org/
16-
- run: npm ci
17-
- run: npm publish
19+
- name: npm install and publish
20+
run: |
21+
ls -lha
22+
npm ci
23+
npm publish
1824
env:
19-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
25+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.github/workflows/test.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
branches: [ master, develop ]
8+
9+
jobs:
10+
11+
# Removing the build job for now because it's useless
12+
# and a time waster. If there's a need for it, we'll introduce
13+
# it later
14+
#
15+
# build:
16+
# runs-on: ubuntu-latest
17+
18+
# steps:
19+
# - uses: actions/checkout@v2
20+
# - name: npm install and build webpack
21+
# run: |
22+
# ls -lha
23+
# npm ci
24+
# npm run build --if-present
25+
# - uses: actions/upload-artifact@master
26+
# with:
27+
# name: webpack artifacts
28+
# path: dist/
29+
30+
31+
test:
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
matrix:
36+
os: [ubuntu-latest, windows-2016]
37+
node-version: [10.x, 12.x]
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
- name: Use Node.js ${{ matrix.node-version }}
42+
uses: actions/setup-node@v1
43+
with:
44+
node-version: ${{ matrix.node-version }}
45+
- name: npm install and test
46+
run: |
47+
ls -lha
48+
npm ci
49+
npm test
50+
env:
51+
CI: true

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,61 @@ console.dir(result, {depth: null});
273273
}
274274
```
275275

276+
### 7. Using closures as wildcard (Success)
277+
278+
You can utilize closures to return an entire sub-object or sub-array from specific keys in a payload. This can be useful in cases where you want to return all values under a key without the need for further matching.
279+
280+
```javascript
281+
const match = require('@menadevs/objectron');
282+
283+
const payload = {
284+
request: {
285+
status: 200,
286+
headers: [
287+
{
288+
"name": "User-Agent",
289+
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3)"
290+
},
291+
{
292+
"name": "Referer",
293+
"value": "https://www.somethingabcxyz.kfc/"
294+
}
295+
]
296+
}
297+
}
298+
299+
const tester = {
300+
request: {
301+
status: 200,
302+
headers: (val) => val
303+
}
304+
};
305+
306+
const result = match(payload, tester);
307+
308+
# Output
309+
> {
310+
match: true,
311+
total: 2,
312+
matches: {
313+
request: {
314+
status: 200,
315+
headers: [
316+
{
317+
"name": "User-Agent",
318+
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3)"
319+
},
320+
{
321+
"name": "Referer",
322+
"value": "https://www.somethingabcxyz.kfc/"
323+
}
324+
]
325+
}
326+
},
327+
groups: {}
328+
}
329+
```
330+
276331
## FAQs
277332

278333
### 1. What's the difference between Objectron and any other Schema Validator?

0 commit comments

Comments
 (0)