Skip to content

Bump node version, add tests and code coverage#26

Merged
garrytrinder merged 1 commit intopnp:masterfrom
garrytrinder:node-bump
Aug 29, 2023
Merged

Bump node version, add tests and code coverage#26
garrytrinder merged 1 commit intopnp:masterfrom
garrytrinder:node-bump

Conversation

@garrytrinder
Copy link
Copy Markdown
Member

@garrytrinder garrytrinder commented Aug 21, 2023

Merging this PR will

@garrytrinder garrytrinder requested review from milanholemans and removed request for milanholemans August 21, 2023 20:48
@garrytrinder garrytrinder force-pushed the node-bump branch 3 times, most recently from 73cef77 to 148dc84 Compare August 22, 2023 20:34
Copy link
Copy Markdown
Contributor

@Jwaegebaert Jwaegebaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work with this PR @garrytrinder. I'm no master of GitHub actions but at first glance, they look all right. I've left a few suggestions but those are mostly cosmetic 😉

Comment thread .c8rc.json
Comment thread .mocharc.json
Comment thread README.md
Comment thread action.yml Outdated
@@ -1,23 +1,30 @@
name: 'CLI for Microsoft 365 Deploy App'
description: 'Deploy an app using CLI for Microsoft 365'
name: "CLI for Microsoft 365 Deploy App"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use single quotes instead of double quotes as we also use single quotes in the CLI 😄
But this is a personal preference of course.

Comment thread package.json
Comment on lines +25 to +46
"keywords": [
"office 365",
"microsoft 365",
"sharepoint framework",
"o365",
"m365",
"spfx",
"sharepoint online",
"sharepoint",
"microsoft teams",
"microsoft graph",
"microsoft flow",
"azure active directory",
"azure ad",
"azure",
"microsoft"
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a few additional keywords regarding power platform could be handy here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jwaegebaert good catch, these are the same keywords we have in the main CLI repo, so we should consider also adding power platform there as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these keywords need a review. Let's leave them as they are for now and work on a new set of keywords that we can apply across all of our repos.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I'll create an issue in the repo of the CLI with a suggestion and we can discuss it there.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment thread src/validate.spec.ts
Comment thread src/validate.spec.ts Outdated
Comment on lines +4 to +6
describe('validate', () => {

it('throws error if APP_FILE_PATH is not passed ', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('validate', () => {
it('throws error if APP_FILE_PATH is not passed ', () => {
describe('validate', () => {
it('throws error if APP_FILE_PATH is not passed ', () => {

Comment thread src/validate.spec.ts Outdated
SKIP_FEATURE_DEPLOYMENT: false,
OVERWRITE: false
};
assert.throws(() => validate(options), Error, `SCOPE must be either 'tenant' or Scope.SiteCollection.`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.throws(() => validate(options), Error, `SCOPE must be either 'tenant' or Scope.SiteCollection.`);
assert.throws(() => validate(options), Error, 'SCOPE must be either 'tenant' or Scope.SiteCollection.');

Comment thread src/validate.spec.ts Outdated
SKIP_FEATURE_DEPLOYMENT: false,
OVERWRITE: false
};
assert.throws(() => validate(options), Error, `SITE_COLLECTION_URL is required if SCOPE is set to Scope.SiteCollection.`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.throws(() => validate(options), Error, `SITE_COLLECTION_URL is required if SCOPE is set to Scope.SiteCollection.`);
assert.throws(() => validate(options), Error, 'SITE_COLLECTION_URL is required if SCOPE is set to Scope.SiteCollection.');

Comment thread src/validate.ts
@garrytrinder
Copy link
Copy Markdown
Member Author

Thanks for the review comments @Jwaegebaert 👍

I've addressed the indenting and quoting comments by applying eslint rules so we fix the style going forwards.

I've taken the approach of using no quotes > single quotes > double quotes for the action.yml file. This seems to be the best approach based on a little research, (see https://stackoverflow.com/a/69850618).

I've also updated some of the npm scripts to bring them inline with the main CLI repo so that we have a more consistent developer experience.

Copy link
Copy Markdown
Contributor

@Jwaegebaert Jwaegebaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome idea to add the eslint rules. I noticed a few files still have a spacing of 4 instead of 2, but I commented on them. I also found another nice addition we could apply. Besides these, it looks good to go 😄

Comment on lines +16 to +50
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: "https://registry.npmjs.org"
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
- name: Compress output (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -cvf build.tar --exclude node_modules ./
- name: Compress output (Windows)
if: matrix.os == 'windows-latest'
run: 7z a -ttar -xr!node_modules -r build.tar .
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.node }}
path: build.tar
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In .github/workflows/test.yml we have an empty line before a new task which looks quite neat. So a suggestion would be to apply it here as well 😄

Suggested change
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: "https://registry.npmjs.org"
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
- name: Compress output (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -cvf build.tar --exclude node_modules ./
- name: Compress output (Windows)
if: matrix.os == 'windows-latest'
run: 7z a -ttar -xr!node_modules -r build.tar .
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.node }}
path: build.tar
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: "https://registry.npmjs.org"
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
- name: Compress output (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -cvf build.tar --exclude node_modules ./
- name: Compress output (Windows)
if: matrix.os == 'windows-latest'
run: 7z a -ttar -xr!node_modules -r build.tar .
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.node }}
path: build.tar

Comment on lines +55 to +110
- name: Configure pagefile
if: matrix.os == 'windows-latest'
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- uses: actions/download-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.nodeBuild }}
- name: Unpack build artifact (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -xvf build.tar && rm build.tar
- name: Unpack build artifact (Windows)
if: matrix.os == 'windows-latest'
run: 7z x build.tar && del build.tar
- name: Use Node.js ${{ matrix.nodeRun }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.nodeRun }}
registry-url: "https://registry.npmjs.org"
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.nodeBuild }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Test without coverage
run: npm test
- name: Test with coverage
run: npm run test:cov
- uses: actions/upload-artifact@v3
with:
name: coverage-${{ matrix.os }}-${{ matrix.nodeRun }}
path: coverage.tar No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an empty line before every task.

Suggested change
- name: Configure pagefile
if: matrix.os == 'windows-latest'
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- uses: actions/download-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.nodeBuild }}
- name: Unpack build artifact (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -xvf build.tar && rm build.tar
- name: Unpack build artifact (Windows)
if: matrix.os == 'windows-latest'
run: 7z x build.tar && del build.tar
- name: Use Node.js ${{ matrix.nodeRun }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.nodeRun }}
registry-url: "https://registry.npmjs.org"
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.nodeBuild }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Test without coverage
run: npm test
- name: Test with coverage
run: npm run test:cov
- uses: actions/upload-artifact@v3
with:
name: coverage-${{ matrix.os }}-${{ matrix.nodeRun }}
path: coverage.tar
- name: Configure pagefile
if: matrix.os == 'windows-latest'
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- uses: actions/download-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.nodeBuild }}
- name: Unpack build artifact (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -xvf build.tar && rm build.tar
- name: Unpack build artifact (Windows)
if: matrix.os == 'windows-latest'
run: 7z x build.tar && del build.tar
- name: Use Node.js ${{ matrix.nodeRun }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.nodeRun }}
registry-url: "https://registry.npmjs.org"
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.nodeBuild }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Test without coverage
run: npm test
- name: Test with coverage
run: npm run test:cov
- uses: actions/upload-artifact@v3
with:
name: coverage-${{ matrix.os }}-${{ matrix.nodeRun }}
path: coverage.tar

Comment thread .c8rc.json Outdated
Comment thread .eslintrc.json Outdated
@@ -0,0 +1,35 @@
{
"root": true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we also have a spacing of 4 instead of 2

Comment thread src/models.ts Outdated
@@ -0,0 +1,24 @@
export interface SpoApp {
CheckInComment: string,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we also have a spacing of 4 instead of 2

Comment thread src/validate.ts
Comment on lines +3 to +14
export interface Options {
APP_FILE_PATH: string;
SCOPE: Scope;
SITE_COLLECTION_URL: string;
SKIP_FEATURE_DEPLOYMENT: boolean;
OVERWRITE: boolean;
}

export enum Scope {
Tenant = 'tenant',
SiteCollection = 'sitecollection'
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we also have a spacing of 4 instead of 2

Suggested change
export interface Options {
APP_FILE_PATH: string;
SCOPE: Scope;
SITE_COLLECTION_URL: string;
SKIP_FEATURE_DEPLOYMENT: boolean;
OVERWRITE: boolean;
}
export enum Scope {
Tenant = 'tenant',
SiteCollection = 'sitecollection'
}
export interface Options {
APP_FILE_PATH: string;
SCOPE: Scope;
SITE_COLLECTION_URL: string;
SKIP_FEATURE_DEPLOYMENT: boolean;
OVERWRITE: boolean;
}
export enum Scope {
Tenant = 'tenant',
SiteCollection = 'sitecollection'
}

Comment thread src/validate.spec.ts Outdated
Comment thread .mocharc.json Outdated
@@ -0,0 +1,11 @@
{
"extension": [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we also have a spacing of 4 instead of 2

Copy link
Copy Markdown
Contributor

@Jwaegebaert Jwaegebaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on this one, @garrytrinder! I don't have anything else to add to this PR, so it's a go from me 😄

@garrytrinder
Copy link
Copy Markdown
Member Author

Thanks again @Jwaegebaert 👍 I managed to fix the eslint rules so that we can now detect errors in the interfaces and enums which were previously being ignored. Thanks again for your attention to detail ❤️

@garrytrinder garrytrinder merged commit 1bc9bd9 into pnp:master Aug 29, 2023
@garrytrinder garrytrinder deleted the node-bump branch August 29, 2023 04:57
@garrytrinder garrytrinder mentioned this pull request Aug 29, 2023
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants