Skip to content

Commit 92bb496

Browse files
committed
Bump node version, add tests and code coverage
1 parent d30432d commit 92bb496

26 files changed

+3749
-3328
lines changed

.c8rc.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"exclude": [
3+
"**/*.spec.js"
4+
],
5+
"reporter": [
6+
"lcov",
7+
"text",
8+
"text-summary"
9+
],
10+
"check-coverage": true,
11+
"branches": 100,
12+
"functions": 100,
13+
"lines": 100,
14+
"statements": 100,
15+
"skip-full": true
16+
}

.eslintrc.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended"
6+
],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"project": [
10+
"./tsconfig.json"
11+
]
12+
},
13+
"plugins": [
14+
"@typescript-eslint"
15+
],
16+
"rules": {
17+
"indent": "off",
18+
"@typescript-eslint/indent": [
19+
"error",
20+
2
21+
],
22+
"quotes": "off",
23+
"@typescript-eslint/quotes": [
24+
"error",
25+
"single",
26+
{
27+
"allowTemplateLiterals": true
28+
}
29+
]
30+
},
31+
"ignorePatterns": [
32+
"node_modules/",
33+
"dist/",
34+
"coverage/",
35+
"lib/"
36+
]
37+
}

.github/workflows/check_pr.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Check PR
2+
3+
on: pull_request
4+
5+
jobs:
6+
build:
7+
if: github.repository_owner == 'pnp'
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [macos-latest, windows-latest, ubuntu-latest]
12+
node: [18]
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Use Node.js ${{ matrix.node }}
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: ${{ matrix.node }}
21+
registry-url: "https://registry.npmjs.org"
22+
23+
- name: Cache node modules
24+
id: cache
25+
uses: actions/cache@v3
26+
with:
27+
path: |
28+
**/node_modules
29+
key: node_modules-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
30+
31+
- name: Restore dependencies
32+
if: steps.cache.outputs.cache-hit != 'true'
33+
run: npm ci
34+
35+
- name: Build
36+
run: npm run build
37+
38+
- name: Compress output (non-Windows)
39+
if: matrix.os != 'windows-latest'
40+
run: tar -cvf build.tar --exclude node_modules ./
41+
42+
- name: Compress output (Windows)
43+
if: matrix.os == 'windows-latest'
44+
run: 7z a -ttar -xr!node_modules -r build.tar .
45+
46+
- name: Upload build artifact
47+
uses: actions/upload-artifact@v3
48+
with:
49+
name: build-${{ matrix.os }}-${{ matrix.node }}
50+
path: build.tar
51+
52+
test:
53+
if: github.repository_owner == 'pnp'
54+
needs: build
55+
runs-on: ${{ matrix.os }}
56+
strategy:
57+
matrix:
58+
os: [macos-latest, windows-latest, ubuntu-latest]
59+
nodeRun: [18]
60+
nodeBuild: [18]
61+
62+
steps:
63+
- name: Configure pagefile
64+
if: matrix.os == 'windows-latest'
65+
uses: al-cheb/[email protected]
66+
with:
67+
minimum-size: 16GB
68+
maximum-size: 16GB
69+
disk-root: "C:"
70+
71+
- uses: actions/download-artifact@v3
72+
with:
73+
name: build-${{ matrix.os }}-${{ matrix.nodeBuild }}
74+
75+
- name: Unpack build artifact (non-Windows)
76+
if: matrix.os != 'windows-latest'
77+
run: tar -xvf build.tar && rm build.tar
78+
79+
- name: Unpack build artifact (Windows)
80+
if: matrix.os == 'windows-latest'
81+
run: 7z x build.tar && del build.tar
82+
83+
- name: Use Node.js ${{ matrix.nodeRun }}
84+
uses: actions/setup-node@v3
85+
with:
86+
node-version: ${{ matrix.nodeRun }}
87+
registry-url: "https://registry.npmjs.org"
88+
89+
- name: Cache node modules
90+
id: cache
91+
uses: actions/cache@v3
92+
with:
93+
path: |
94+
**/node_modules
95+
key: node_modules-${{ matrix.os }}-${{ matrix.nodeBuild }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
96+
97+
- name: Restore dependencies
98+
if: steps.cache.outputs.cache-hit != 'true'
99+
run: npm ci
100+
101+
- name: Test without coverage
102+
run: npm test
103+
104+
- name: Test with coverage
105+
run: npm run test:cov
106+
107+
- uses: actions/upload-artifact@v3
108+
with:
109+
name: coverage-${{ matrix.os }}-${{ matrix.nodeRun }}
110+
path: coverage.tar

.github/workflows/test.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on: [workflow_dispatch]
2+
3+
jobs:
4+
cli_deploy_job:
5+
runs-on: ubuntu-latest
6+
7+
strategy:
8+
matrix:
9+
node-version: [18.x]
10+
11+
name: CLI Deploy Job
12+
13+
steps:
14+
- name: Login to tenant
15+
uses: pnp/action-cli-login@v2
16+
id: login
17+
with:
18+
ADMIN_USERNAME: ${{ secrets.ADMIN_USERNAME }}
19+
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }}
20+
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- name: CLI for Microsoft 365 Deploy
25+
uses: ./
26+
id: deploy
27+
with:
28+
APP_FILE_PATH: sharepoint/solution/test.sppkg
29+
SKIP_FEATURE_DEPLOYMENT: true
30+
OVERWRITE: true
31+
32+
- name: Get the id of the app deployed
33+
run: echo "The id of the app deployed is ${{ steps.deploy.outputs.APP_ID }}"

.github/workflows/test_site.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on: [workflow_dispatch]
2+
3+
jobs:
4+
cli_deploy_job_site:
5+
runs-on: ubuntu-latest
6+
7+
strategy:
8+
matrix:
9+
node-version: [18.x]
10+
11+
name: CLI Deploy Job
12+
13+
steps:
14+
- name: Login to tenant
15+
uses: pnp/action-cli-login@v2
16+
id: login
17+
with:
18+
ADMIN_USERNAME: ${{ secrets.ADMIN_USERNAME }}
19+
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }}
20+
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- name: CLI for Microsoft 365 Deploy
25+
uses: ./
26+
id: deploy
27+
with:
28+
APP_FILE_PATH: sharepoint/solution/test.sppkg
29+
SCOPE: sitecollection
30+
SITE_COLLECTION_URL: https://tenant.sharepoint.com/sites/siteapps
31+
32+
- name: Get the id of the app deployed
33+
run: echo "The id of the app deployed is ${{ steps.deploy.outputs.APP_ID }}"

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# comment out in distribution branches
22
node_modules/
3+
lib
34

45
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
56
# Logs
@@ -88,4 +89,7 @@ typings/
8889
.fusebox/
8990

9091
# DynamoDB Local files
91-
.dynamodb/
92+
.dynamodb/
93+
94+
# macOS
95+
.DS_Store

.mocharc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extension": [
3+
"ts"
4+
],
5+
"spec": "lib/**/*.spec.js",
6+
"reporter": "min",
7+
"require": "source-map-support/register",
8+
"watch": "lib/**/*.js",
9+
"timeout": 10000,
10+
"logpanel": true
11+
}

README.md

+10-34
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Create a workflow `.yml` file in your `.github/workflows` directory. An [example
1515

1616
#### Optional requirement
1717
Since `action-cli-login` requires user name and password which are sensitive pieces of information, it would be ideal to store them securely. We can achieve this in a GitHub repo by using [secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets). So, click on `settings` tab in your repo and add 2 new secrets:
18-
- `adminUsername` - store the admin user name in this (e.g. [email protected])
19-
- `adminPassword` - store the password of that user in this.
18+
- `ADMIN_USERNAME` - store the admin user name in this (e.g. [email protected])
19+
- `ADMIN_PASSWORD` - store the password of that user in this.
20+
2021
These secrets are encrypted and can only be used by GitHub actions.
2122

2223
### Compatibility matrix
@@ -25,7 +26,7 @@ The following table lists which versions of the GitHub action are compatible wit
2526

2627
Version | CLI for Microsoft 365 version
2728
--- | ---
28-
v3.0.0 | v6.0.0
29+
^v3.0.0 | v6.0.0
2930
v2.0.2 | v5.8.0
3031
v1.0.0 | v2.5.0
3132

@@ -58,7 +59,7 @@ jobs:
5859
runs-on: ubuntu-latest
5960
strategy:
6061
matrix:
61-
node-version: [10.x]
62+
node-version: [18.x]
6263

6364
steps:
6465

@@ -68,18 +69,18 @@ jobs:
6869

6970
# CLI for Microsoft 365 login action
7071
- name: Login to tenant
71-
uses: pnp/action-cli-login@v2.0.0
72+
uses: pnp/action-cli-login@v2
7273
with:
73-
ADMIN_USERNAME: ${{ secrets.adminUsername }}
74-
ADMIN_PASSWORD: ${{ secrets.adminPassword }}
74+
ADMIN_USERNAME: ${{ secrets.ADMIN_USERNAME }}
75+
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }}
7576

7677
# CLI for Microsoft 365 deploy app action
7778
# Use either option 1 or option 2
7879

7980
# Option 1 - Deploy app at tenant level
8081
- name: Option 1 - Deploy app to tenant
8182
id: climicrosoft365deploy # optional - use if output needs to be used
82-
uses: pnp/action-cli-deploy@v2.0.0
83+
uses: pnp/action-cli-deploy@v4
8384
with:
8485
APP_FILE_PATH: sharepoint/solution/spfx-cli-microsoft365-action.sppkg
8586
SKIP_FEATURE_DEPLOYMENT: true
@@ -88,7 +89,7 @@ jobs:
8889

8990
# Option 2 - Deploy app to a site collection
9091
- name: Option 2 - Deploy app to a site collection
91-
uses: pnp/action-cli-deploy@v2.0.0
92+
uses: pnp/action-cli-deploy@v4
9293
with:
9394
APP_FILE_PATH: sharepoint/solution/spfx-cli-microsoft365-action.sppkg
9495
SCOPE: sitecollection
@@ -100,30 +101,5 @@ jobs:
100101
run: echo "The id of the app deployed is ${{ steps.climicrosoft365deploy.outputs.APP_ID }}"
101102
```
102103
103-
104104
#### Self-hosted runners
105105
If self-hosted runners are used for running the workflow, then please make sure that they have `PowerShell` or `bash` installed on them.
106-
107-
## Release notes
108-
109-
### v3.0.1
110-
111-
- Fixes compatibility bug with CLI for Microsoft 365 v6.0.0
112-
113-
### v3.0.0
114-
115-
- Ensured compatibility with CLI for Microsoft 365 v6.0.0
116-
117-
### v2.0.2
118-
119-
- Fixes bug where app ID was invalid
120-
121-
### v2.0.0
122-
123-
- Renames action to 'CLI for Microsoft 365'
124-
125-
### v1.0.1
126-
- Fixed 'skipFeatureDeployment not included in spo app deploy command for Windows' solving #4
127-
128-
### v1.0.0
129-
- Added inital 'CLI for Microsoft 365 deploy' GitHub action solving #2

0 commit comments

Comments
 (0)