Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit ade6515

Browse files
authored
ci: Automate integration tests (#450)
1 parent 129b386 commit ade6515

File tree

36 files changed

+441
-6347
lines changed

36 files changed

+441
-6347
lines changed
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
on:
2+
schedule:
3+
# Run twice per day (12:45 AM & PM)
4+
- cron: '45 */12 * * *'
5+
push:
6+
branches:
7+
# Push to a branch that ends with "/trigger-int-tests" to manually trigger tests
8+
- '**/trigger-int-tests'
9+
name: Integration Tests
10+
jobs:
11+
int_tests_node_10:
12+
name: Node 10
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@master
16+
- name: Cache node_modules
17+
id: cache-modules
18+
uses: actions/cache@v1
19+
with:
20+
path: node_modules
21+
key: ${{ runner.OS }}-build-${{ hashFiles('package.json') }}
22+
- name: npm install
23+
if: steps.cache-modules.outputs.cache-hit != 'true'
24+
run: npm install
25+
- name: build
26+
run: tsc
27+
- name: node 10 integration tests
28+
run: npm run test:int -- -t deploy -d node10
29+
env:
30+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
31+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID}}
32+
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET}}
33+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID}}
34+
int_tests_node_12:
35+
name: Node 12
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@master
39+
- name: Cache node_modules
40+
id: cache-modules
41+
uses: actions/cache@v1
42+
with:
43+
path: node_modules
44+
key: ${{ runner.OS }}-build-${{ hashFiles('package.json') }}
45+
- name: npm install
46+
if: steps.cache-modules.outputs.cache-hit != 'true'
47+
run: npm install
48+
- name: build
49+
run: tsc
50+
- name: node 12 integration tests
51+
run: npm run test:int -- -t deploy -d node12
52+
env:
53+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
54+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID}}
55+
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET}}
56+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID}}
57+
int_tests_python:
58+
name: Python
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@master
62+
- name: Cache node_modules
63+
id: cache-modules
64+
uses: actions/cache@v1
65+
with:
66+
path: node_modules
67+
key: ${{ runner.OS }}-build-${{ hashFiles('package.json') }}
68+
- name: npm install
69+
if: steps.cache-modules.outputs.cache-hit != 'true'
70+
run: npm install
71+
- name: build
72+
run: tsc
73+
- name: python integration tests
74+
run: npm run test:int -- -t deploy -d python
75+
env:
76+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
77+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID}}
78+
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET}}
79+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID}}

.gitignore

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@ node_modules/
44
/coverage/
55
.env*
66
.idea/
7+
tmp/
78

8-
.vscode/launch.json
9+
.vscode/launch.json
10+
11+
# Integration Test Files
12+
hello/
13+
local.settings.json
14+
__pycache__/
15+
.python_packages/
16+
.serverless/

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This plugin enables Azure Functions support within the Serverless Framework.
44

55
[![Code Coverage](https://codecov.io/gh/serverless/serverless-azure-functions/branch/dev/graph/badge.svg)](https://codecov.io/gh/serverless/serverless-azure-functions)
66

7+
![Integration Tests](https://github.com/serverless/serverless-azure-functions/workflows/Integration%20Tests/badge.svg)
8+
79
## Quickstart
810

911
### Pre-requisites
@@ -307,6 +309,29 @@ We use [Jest](https://jestjs.io/) for unit tests, and it is expected that every
307309
308310
Run unit tests using `npm test` or `npm run test:coverage` to get coverage results.
309311
312+
#### Integration Tests
313+
314+
We run our integration tests twice per day from our GitHub workflow. These tests install the beta version of the plugin, deploy a function app (with APIM), re-deploy (to make sure ARM template deployment is skipped), invoke the function directly, invoke the APIM endpoint and then remove the resource group, making assertions on the output at each step. While the number of configurations one could use in the Serverless Framework is virtually infinite, we tried to capture the main runtimes and platforms that are supported by the tool:
315+
316+
- Node 10 on Linux using remote build
317+
- Node 10 on Linux using external package
318+
- Node 10 on Windows
319+
- Node 10 on Windows using webpack
320+
- Node 12 on Linux using remote build
321+
- Node 12 on Linux using external package
322+
- Node 12 on Linux using remote build and premium functions
323+
- Node 12 on Windows
324+
- Node 12 on Windows using premium functions
325+
- Node 12 on Windows using webpack
326+
- Python 3.6 (Linux only)
327+
- Python 3.6 (Linux only) using premium functions
328+
- Python 3.7 (Linux only)
329+
- Python 3.8 (Linux only)
330+
331+
We made these configurations as minimal as possible. If you are having problems with your project, feel free to check to see if our integration tests are passing (see badge at top of readme) and then double check our configuration inside the `integrationTests` directory.
332+
333+
We use [Clover](https://www.npmjs.com/package/clvr) to run the integration tests, and they run 2x per day in our GitHub Action.
334+
310335
#### Signing commits
311336
312337
All commits in your Pull Request will need to be signed. When looking at the commits in the pull request, you will see a green 'verified' icon next to your commit. Commit signature verification is discussed [here](https://help.github.com/en/articles/about-commit-signature-verification).

clvr.config.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"testPattern": "integrationTests/**/*.clvr.ts",
3+
"parentDir": "integrationTests/configurations/"
4+
}

integrationTests/.gitignore

-6
This file was deleted.

integrationTests/configurations/node10-linux-external/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ functions:
2626
handler: hello.sayHello
2727
events:
2828
- http: true
29-
x-azure-settings:
30-
methods:
31-
- GET
32-
authLevel: anonymous
29+
methods:
30+
- GET
31+
authLevel: anonymous
3332

34-
33+

integrationTests/configurations/node10-linux/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ functions:
2525
handler: hello.sayHello
2626
events:
2727
- http: true
28-
x-azure-settings:
29-
methods:
30-
- GET
31-
authLevel: anonymous
28+
methods:
29+
- GET
30+
authLevel: anonymous
3231

33-
32+

integrationTests/configurations/node10-windows-webpack/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ functions:
2525
handler: hello.sayHello
2626
events:
2727
- http: true
28-
x-azure-settings:
29-
methods:
30-
- GET
31-
authLevel: anonymous
28+
methods:
29+
- GET
30+
authLevel: anonymous
3231

33-
32+

integrationTests/configurations/node10-windows/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ functions:
2525
handler: hello.sayHello
2626
events:
2727
- http: true
28-
x-azure-settings:
29-
methods:
30-
- GET
31-
authLevel: anonymous
28+
methods:
29+
- GET
30+
authLevel: anonymous
3231

33-
32+

integrationTests/configurations/node12-linux-external/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ functions:
2626
handler: hello.sayHello
2727
events:
2828
- http: true
29-
x-azure-settings:
30-
methods:
31-
- GET
32-
authLevel: anonymous
29+
methods:
30+
- GET
31+
authLevel: anonymous
3332

34-
33+

integrationTests/configurations/node12-linux-premium/hello.js

-23
This file was deleted.

integrationTests/configurations/node12-linux-premium/host.json

-3
This file was deleted.

integrationTests/configurations/node12-linux-premium/package.json

-17
This file was deleted.

integrationTests/configurations/node12-linux-premium/serverless.yml

-34
This file was deleted.

integrationTests/configurations/node12-linux/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ functions:
2525
handler: hello.sayHello
2626
events:
2727
- http: true
28-
x-azure-settings:
29-
methods:
30-
- GET
31-
authLevel: anonymous
28+
methods:
29+
- GET
30+
authLevel: anonymous
3231

33-
32+

integrationTests/configurations/node12-windows-premium/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ provider:
44
name: azure
55
prefix: tmp
66
stage: qa
7-
region: West Europe
7+
region: Central US
88
runtime: nodejs12
99
os: windows
1010
apim: true
@@ -26,9 +26,8 @@ functions:
2626
handler: hello.sayHello
2727
events:
2828
- http: true
29-
x-azure-settings:
30-
methods:
31-
- GET
32-
authLevel: anonymous
29+
methods:
30+
- GET
31+
authLevel: anonymous
3332

3433

integrationTests/configurations/node12-windows-webpack/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ functions:
2626
handler: hello.sayHello
2727
events:
2828
- http: true
29-
x-azure-settings:
30-
methods:
31-
- GET
32-
authLevel: anonymous
29+
methods:
30+
- GET
31+
authLevel: anonymous
3332

34-
33+

integrationTests/configurations/node12-windows/serverless.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ functions:
2525
handler: hello.sayHello
2626
events:
2727
- http: true
28-
x-azure-settings:
29-
methods:
30-
- GET
31-
authLevel: anonymous
28+
methods:
29+
- GET
30+
authLevel: anonymous
3231

33-
32+

integrationTests/configurations/python36-premium/serverless.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ provider:
77
stage: qa
88
region: West Europe
99
apim: true
10+
environment:
11+
VARIABLE_FOO: 'foo'
1012

1113
plugins:
1214
- serverless-azure-functions
@@ -30,7 +32,6 @@ functions:
3032
handler: hello
3133
events:
3234
- http: true
33-
x-azure-settings:
34-
methods:
35-
- GET
36-
authLevel: anonymous
35+
methods:
36+
- GET
37+
authLevel: anonymous

0 commit comments

Comments
 (0)