Skip to content

Commit

Permalink
chore: 🤖 add angular-versions-action to ci pipeline (ngworker#20)
Browse files Browse the repository at this point in the history
* chore: 🤖 add angular-verions-action to ci pipeline

- this change should allow to test the lib source code with different
angular verions

* chore: 🤖 add version to angular-versions-action

* chore: 🤖 fix angular-versions-action input name

* chore: 🤖 use headless test on ci

* chore: 🤖 improve compatibility with v9

* chore: 🤖 remove multi version build to check breaking change

* chore: 🤖 retry with multiple angular versions

* chore: 🤖 fix typo in ci

* chore: 🤖 space ci steps

* chore: 🤖 use right version of angular-versions-action

* chore: 🤖 use latest angular-versions-action

* chore: 🤖 use fixed version of angular-versions-action

* chore: 🤖 trying with version 8 of Angular

* chore: 🤖 modify source code to support angular 8.1

* chore: 🤖 update to use angular-versions-action that support 8.1

* test: add TestBed.inject/TestBed.get wrapper

* chore: add format script

* style: format

* docs: ✏️ add compatibility section in docs

* chore: 🤖 migrate to angular-versions-action v2

* fix: 🐛 increase accuracy on lumberjack dependencies range

* fix: 🐛 use latest patch version for lumberjack deps range

* docs: update compatibility table to express variable patch version

Co-authored-by: Lars Gyrup Brink Nielsen <[email protected]>

Co-authored-by: Nacho Vazquez <[email protected]>
Co-authored-by: Lars Gyrup Brink Nielsen <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2020
1 parent 4ed6a0d commit 29c44ca
Show file tree
Hide file tree
Showing 25 changed files with 465 additions and 161 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ jobs:
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
angular-version: [8.1.x, 9.0.x, 10.0.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Use Angular version ${{ matrix.angular-version }}
uses: ngworker/angular-versions-action@v2
with:
angular_version: ${{ matrix.angular-version }}

- run: yarn
- run: yarn lint
- run: yarn build
- run: yarn test:headless
- run: yarn build:lib
- run: yarn test:lib
- run: yarn test:lib:headless
24 changes: 9 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ All notable changes to this project will be documented in this file. See [standa

### [1.0.7](https://github.com/ngworker/lumberjack/compare/v1.0.6...v1.0.7) (2020-08-28)


### Tests

* 💍 add `LumberjackService` base tests ([9b6f961](https://github.com/ngworker/lumberjack/commit/9b6f961c881a15b4dfa92ace308fbd2cb3306aeb))
- 💍 add `LumberjackService` base tests ([9b6f961](https://github.com/ngworker/lumberjack/commit/9b6f961c881a15b4dfa92ace308fbd2cb3306aeb))

### [1.0.6](https://github.com/ngworker/lumberjack/compare/v1.0.5...v1.0.6) (2020-07-30)

Expand All @@ -19,39 +18,34 @@ All notable changes to this project will be documented in this file. See [standa

### [1.0.3](https://github.com/ngworker/lumberjack/compare/v1.0.2...v1.0.3) (2020-07-22)


### Bug Fixes

* 🐛 remove not published message from readme ([2ccc687](https://github.com/ngworker/lumberjack/commit/2ccc687637894e6f51c2fcfc6fc67d040010ac7a))
- 🐛 remove not published message from readme ([2ccc687](https://github.com/ngworker/lumberjack/commit/2ccc687637894e6f51c2fcfc6fc67d040010ac7a))

### [1.0.2](https://github.com/ngworker/lumberjack/compare/v1.0.1...v1.0.2) (2020-07-22)


### Bug Fixes

* 🐛 cp readme to dist on build lib ([7f04fcc](https://github.com/ngworker/lumberjack/commit/7f04fcc34ad1fe01231182f848e2fbe7dda23cf8))
- 🐛 cp readme to dist on build lib ([7f04fcc](https://github.com/ngworker/lumberjack/commit/7f04fcc34ad1fe01231182f848e2fbe7dda23cf8))

### [1.0.1](https://github.com/ngworker/lumberjack/compare/v1.0.0...v1.0.1) (2020-07-22)


### Bug Fixes

* 🐛 readme and publish info ([#4](https://github.com/ngworker/lumberjack/issues/4)) ([0f63fe9](https://github.com/ngworker/lumberjack/commit/0f63fe9b6acb3d1295d45ef7b3d98ae8ef709224))
- 🐛 readme and publish info ([#4](https://github.com/ngworker/lumberjack/issues/4)) ([0f63fe9](https://github.com/ngworker/lumberjack/commit/0f63fe9b6acb3d1295d45ef7b3d98ae8ef709224))

## 1.0.0 (2020-07-22)


### ⚠ BREAKING CHANGES

* add lumberjack core
- add lumberjack core

### Features

* 🎸 add usage example to app.component ([#2](https://github.com/ngworker/lumberjack/issues/2)) ([637c278](https://github.com/ngworker/lumberjack/commit/637c2780905bfe28fbf6b2e8a11b6204c96f81a1))
* 🎸 create general structure of lumberjack library ([087b716](https://github.com/ngworker/lumberjack/commit/087b716c0dd40d49490911c2eb5c5ba598918d85))

- 🎸 add usage example to app.component ([#2](https://github.com/ngworker/lumberjack/issues/2)) ([637c278](https://github.com/ngworker/lumberjack/commit/637c2780905bfe28fbf6b2e8a11b6204c96f81a1))
- 🎸 create general structure of lumberjack library ([087b716](https://github.com/ngworker/lumberjack/commit/087b716c0dd40d49490911c2eb5c5ba598918d85))

### Tests

* 💍 add empty test file ([7f605a2](https://github.com/ngworker/lumberjack/commit/7f605a2515cc173d9d7d6aca804c46cea62bc6bf))
* 💍 convert app test to spectator and add enhance linting ([#3](https://github.com/ngworker/lumberjack/issues/3)) ([1969806](https://github.com/ngworker/lumberjack/commit/1969806c18eab904a8de85ce512e4f20384a7f6a))
- 💍 add empty test file ([7f605a2](https://github.com/ngworker/lumberjack/commit/7f605a2515cc173d9d7d6aca804c46cea62bc6bf))
- 💍 convert app test to spectator and add enhance linting ([#3](https://github.com/ngworker/lumberjack/issues/3)) ([1969806](https://github.com/ngworker/lumberjack/commit/1969806c18eab904a8de85ce512e4f20384a7f6a))
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
Start by installing all dependencies:

```bash
npm i
yarn
```

Run the tests:

```bash
npm test
yarn test
yarn e2e
```

Run the playground app:

```bash
npm start
yarn start
```

## Building
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[![commitizen](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)]()
[![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)]()
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
[![ngworker](https://img.shields.io/badge/ngworker-%40-red)](https://github.com/ngworker/)
[![spectator](https://img.shields.io/badge/tested%20with-spectator-2196F3.svg?style=flat-square)]()

Expand Down Expand Up @@ -43,6 +43,18 @@ Lumberjack is a versatile Angular Logging library, specially defined to be exten

`yarn add @ngworker/lumberjack`

## Compatibility

`Lumberjack` has tested compatibility with the following Angular versions.

> If the version you are using is not listed, please rise an issue. This list only covers tested versions.
| Angular | Support |
| -------------- | -------- |
| > 10.0.x ||
| > 9.0.x ||
| > 8.1.x ||

## Usage

To start using this app just import it in your application root module.
Expand Down
5 changes: 0 additions & 5 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
Expand Down
6 changes: 1 addition & 5 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es2018",
"types": [
"jasmine",
"jasminewd2",
"node"
]
"types": ["jasmine", "jasminewd2", "node"]
}
}
8 changes: 4 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ module.exports = function (config) {
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
require('@angular-devkit/build-angular/plugins/karma'),
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/lumberjack'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
fixWebpackSourcePaths: true,
},
reporters: ['progress', 'kjhtml'],
port: 9876,
Expand All @@ -27,6 +27,6 @@ module.exports = function (config) {
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
restartOnFileChange: true,
});
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"release": "cd projects/ngworker/lumberjack && standard-version --infile ../../../CHANGELOG.md",
"test:lib:headless": "cross-env CI=true yarn test:lib",
"publish": "cd dist/ngworker/lumberjack && npm publish",
"ci": "yarn install && yarn lint && yarn build && yarn test:headless && yarn build:lib && yarn test:lib:headless"
"ci": "yarn install && yarn lint && yarn build && yarn test:headless && yarn build:lib && yarn test:lib:headless",
"format": "npx prettier --config prettier.config.js --write \"**/*.*\" \"!dist/**\" \"!yarn.lock\""
},
"private": true,
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion projects/ngworker/lumberjack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ This library was generated with [Angular CLI](https://github.com/angular/angular
## Code scaffolding

Run `ng generate component component-name --project lumberjack` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project lumberjack`.
> Note: Don't forget to add `--project lumberjack` or else it will be added to the default project in your `angular.json` file.

> Note: Don't forget to add `--project lumberjack` or else it will be added to the default project in your `angular.json` file.
## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
LumberjackModule,
} from '@ngworker/lumberjack';

import { expectNgModuleToBeGuarded } from '../../tests/expect-ng-module-to-be-guarded';
import { expectNgModuleToBeGuarded, resolveDependency } from '../../tests';

import { ConsoleDriverModule } from './console-driver.module';
import { ConsoleDriver } from './console.driver';
Expand All @@ -29,7 +29,7 @@ const createConsoleDriver = ({
],
});

const [consoleDriver] = (TestBed.inject(LogDriverToken) as unknown) as LogDriver[];
const [consoleDriver] = (resolveDependency(LogDriverToken) as unknown) as LogDriver[];

return consoleDriver;
};
Expand Down
4 changes: 2 additions & 2 deletions projects/ngworker/lumberjack/http-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
}
},
"peerDependencies": {
"@angular/common": "^10.0.14",
"@angular/core": "^10.0.14",
"@angular/common": ">=8.1.3",
"@angular/core": ">=8.1.3",
"rxjs": "^6.5.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe(HttpDriverRootModule.name, () => {
// tslint:disable-next-line: no-null-keyword
const optionalAngularDependency = null;

// @ts-expect-error
expect(() => new HttpDriverRootModule(optionalAngularDependency)).not.toThrow();
expect(() => new HttpDriverRootModule(optionalAngularDependency as any)).not.toThrow();
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { HttpClientModule } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';

import {
Expand All @@ -9,7 +8,7 @@ import {
LumberjackModule,
} from '@ngworker/lumberjack';

import { expectNgModuleToBeGuarded } from '../../tests/expect-ng-module-to-be-guarded';
import { expectNgModuleToBeGuarded, resolveDependency } from '../../tests';

import { HttpDriverConfig } from './http-driver.config';
import { HttpDriverModule } from './http-driver.module';
Expand All @@ -32,7 +31,7 @@ const createHttpDriver = (
],
});

const [httpDriver] = (TestBed.inject(LogDriverToken) as unknown) as LogDriver[];
const [httpDriver] = (resolveDependency(LogDriverToken) as unknown) as LogDriver[];

return httpDriver;
};
Expand Down
2 changes: 1 addition & 1 deletion projects/ngworker/lumberjack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@ngworker/lumberjack",
"version": "1.0.8",
"peerDependencies": {
"@angular/core": "^10.0.14"
"@angular/core": ">=8.1.3"
},
"dependencies": {
"tslib": "^2.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';

import { expectNgModuleToBeGuarded } from '../../tests/expect-ng-module-to-be-guarded';
import { expectNgModuleToBeGuarded, resolveDependency } from '../../tests';

import {
defaultLogConfig,
Expand All @@ -26,7 +26,7 @@ describe(LumberjackModule.name, () => {
imports: [LumberjackModule.forRoot(expectedConfig)],
});

const actualConfig = TestBed.inject(LumberjackLogConfigToken);
const actualConfig = resolveDependency(LumberjackLogConfigToken);
expect(actualConfig).toEqual(expectedConfig);
});

Expand All @@ -35,7 +35,7 @@ describe(LumberjackModule.name, () => {
imports: [LumberjackModule.forRoot()],
});

const actualConfig = TestBed.inject(LumberjackLogConfigToken);
const actualConfig = resolveDependency(LumberjackLogConfigToken);
expect(actualConfig).toEqual(defaultLogConfig);
});

Expand All @@ -44,7 +44,7 @@ describe(LumberjackModule.name, () => {
imports: [LumberjackModule.forRoot()],
});

const actualConfig = TestBed.inject(LogDriverConfigToken);
const actualConfig = resolveDependency(LogDriverConfigToken);
expect(actualConfig).toEqual(defaultLogDriverConfig);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TestBed } from '@angular/core/testing';

import { resolveDependency } from '../../tests';

import { LogDriverConfig, LogDriverConfigToken } from './configs';
import { createDebugLog } from './log-types';
import { LumberjackModule } from './lumberjack.module';
Expand All @@ -9,7 +11,7 @@ const allLogLevelsDisabled: LogDriverConfig = {
levels: [],
};
const createEmptyDebugLog = createDebugLog('');
const logEmptyDebugMessage = () => TestBed.inject(LumberjackService).log(createEmptyDebugLog());
const logEmptyDebugMessage = () => resolveDependency(LumberjackService).log(createEmptyDebugLog());

describe(LumberjackService.name, () => {
it('accepts logs when no log drivers are registered', () => {
Expand Down
2 changes: 1 addition & 1 deletion projects/ngworker/lumberjack/src/lib/lumberjack.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class LumberjackService {
// and use it to log to its output.
@Optional() @Inject(LogDriverToken) logDrivers?: LogDriver[]
) {
logDrivers = logDrivers ?? [];
logDrivers = logDrivers || [];
this.logDrivers = Array.isArray(logDrivers) ? logDrivers : [logDrivers];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Type } from '@angular/core';
import { TestBed } from '@angular/core/testing';

import { resolveDependency } from './resolve-dependency';

export const expectNgModuleToBeGuarded = <TModule>(ngModuleType: Type<TModule>) => {
let ngModule: TModule | undefined;

Expand All @@ -9,7 +11,7 @@ export const expectNgModuleToBeGuarded = <TModule>(ngModuleType: Type<TModule>)
});

expect(() => {
ngModule = TestBed.inject(ngModuleType);
ngModule = resolveDependency(ngModuleType);
})
.withContext(`${ngModuleType.name} must guard against being imported directly`)
.toThrow();
Expand Down
1 change: 1 addition & 0 deletions projects/ngworker/lumberjack/tests/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './expect-ng-module-to-be-guarded';
export * from './resolve-dependency';
Loading

0 comments on commit 29c44ca

Please sign in to comment.