Skip to content

Commit f432836

Browse files
Development (#33)
* update commit hash * add manifest validator action; does not yet check root-level * testing jq instaltion; changing others to pull_request only * force run on jqtest * add further testing * got file checking working. updated manifest file to fail * reset manifest file; clean up actions * BAAS-30360: Add Twilio third party snippets (#32) * main => development (#31) * change production=>main branch * update commit hash * BAAS-30360: add twilio third party snippets * update commit hash * test * Commit performed using Copy Push Files action * Commit performed using Copy Push Files action * Commit performed using Copy Push Files action * test * update commit hash * update commit hash * test * update commit hash * test * update commit hash --------- Co-authored-by: MongoCaleb <[email protected]> Co-authored-by: ActionBot <[email protected]> Co-authored-by: MongoCaleb <[email protected]> --------- Co-authored-by: jwongmongodb <[email protected]> Co-authored-by: MongoCaleb <[email protected]>
1 parent a3d368c commit f432836

24 files changed

+425
-10
lines changed

.github/workflows/Remove-Function-Name-Prefix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Remove Function Name Prefixes
22

33
on:
44
workflow_call:
5-
push:
5+
pull_request:
66

77
jobs:
88
remove-function-prefix:

.github/workflows/Update-Commit-Hash.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Update Commit Hash
22

33
on:
4-
push:
4+
pull_request:
55
workflow_dispatch:
66

77
jobs:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Validate Base Manifest.json"
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
type: string
9+
required: false
10+
description: 'Version of jq to install'
11+
default: '1.7'
12+
force:
13+
type: boolean
14+
required: false
15+
description: 'Do not check for existing jq installation before continuing.'
16+
default: false
17+
18+
jobs:
19+
Setup-jq:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: 'Setup jq'
24+
uses: dcarbone/install-jq-action@v2
25+
with:
26+
version: '${{ inputs.version }}'
27+
force: '${{ inputs.force }}'
28+
- id: validate_manifest
29+
run: |
30+
for fn in $(jq -r '.' manifest.json | jq -r '.snippetCategories[].metadata'); do
31+
fullpath=".$fn"
32+
echo "the next file is $fullpath"
33+
if test -f $fullpath; then
34+
echo "File exists."
35+
else
36+
echo "**MANIFEST FILE DOES NOT EXIST**"
37+
exit 1
38+
fi
39+
done
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Validate Manifests
2+
on: [pull_request]
3+
4+
jobs:
5+
validate-github-actions-workflows:
6+
name: Validate JSON Schemas
7+
permissions:
8+
contents: read
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Validate scehmas
13+
uses: dsanders11/[email protected]
14+
with:
15+
schema: ./snippets/manifest-schema.json
16+
files: ./snippets/functions/**/**.json
17+
- name: Test
18+
run: |
19+
content=`cat ./manifest.json`
20+
echo $content
21+
barf=${{fromJson($content)}}
22+
echo ${{ barf }}

latestCommit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8efff924551200067d16409d2cf4cfc212070231
1+
86bf61d24dc9a0784485282a5063f559f91ad7ee

manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"metadata": "/snippets/functions/mongodb-crud/manifest.json"
88
},
99
{
10+
"metadata": "/snippets/functions/api-functions/manifest.json"
11+
},
12+
{
13+
"metadata": "/snippets/functions/function-context/manifest.json"
14+
},
15+
{
1016
"metadata": "/snippets/triggers/match/manifest.json"
1117
},
1218
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
exports = async function(arg){
2+
const url = "https://api.stackexchange.com/2.3/answers?key=U4DMV*8nvpm3EOpvf69Rxw((&site=stackoverflow&page=1&pagesize=10&order=desc&sort=activity&filter=default";
3+
4+
const response = await context.http.get({ url: url })
5+
// The response body is a BSON.Binary object, so parse it:
6+
const result = EJSON.parse(response.body.text())
7+
// console.log(JSON.stringify(result));
8+
return result;
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"category": "Function API Calls",
3+
"categoryId": "f9edca1b-a841-4037-8e6c-421d547ca160",
4+
"viewType": "functionSnippet",
5+
"snippets": [
6+
{
7+
"id": "f812224f-55dd-4192-98d8-59246053940b",
8+
"title": "Call an external API from a function",
9+
"snippet": "/callExternalAPI.js",
10+
"description": "Use the function's context.http to call an external API."
11+
}
12+
]
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
exports = async function(number1, number2){
2+
3+
// To call other named functions:
4+
var result = context.functions.execute("sum", number1, number2);
5+
6+
return result;
7+
};
8+
9+
// This examples calls a function named "sum" that looks like this:
10+
/*
11+
exports = async function(number1, number2) {
12+
return number1 + number2
13+
};
14+
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"category": "Function Context Examples",
3+
"categoryId": "38b0fd8f-fefe-4cb4-838c-a094d61e299e",
4+
"viewType": "functionSnippet",
5+
"snippets": [
6+
{
7+
"id": "c2171069-9b17-41b0-bb5c-475a141a13ed",
8+
"title": "Call another function from a function",
9+
"snippet": "/callFunction.js",
10+
"description": "Use the Function context to call another function."
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)