From c93fe6607839e8fb357dcaf6f6f50d17f335b96a Mon Sep 17 00:00:00 2001 From: curious_andrew Date: Wed, 27 Dec 2023 14:31:45 +0300 Subject: [PATCH 1/4] ++ test workflow --- .github/workflows/test.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e8d386f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: Run Tests + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm test + + - name: Success Message + if: success() + run: echo "Tests passed successfully!" From 74ee30561e13683fad14c9913c617a40feef8794 Mon Sep 17 00:00:00 2001 From: curious_andrew Date: Wed, 27 Dec 2023 14:36:46 +0300 Subject: [PATCH 2/4] rename testing folder and scripts, add worklow to run typing tests --- .github/workflows/test.yml | 15 +++++++++++---- package.json | 4 ++-- tests/{logic => functionality}/createDict.test.ts | 0 .../createGetByKey.test.ts | 0 .../{logic => functionality}/filters/and.test.ts | 0 .../filters/isNotNull.test.ts | 0 .../filters/isNotUndefined.test.ts | 0 .../filters/matchesPluckedStrings.test.ts | 0 .../filters/matchesString.test.ts | 0 .../{logic => functionality}/filters/not.test.ts | 0 tests/{logic => functionality}/filters/or.test.ts | 0 tests/{logic => functionality}/get.test.ts | 0 tests/{logic => functionality}/pluck.test.ts | 0 tests/{typings => typing}/createDict.ts | 0 tests/{typings => typing}/createGetByKey.ts | 0 tests/{typings => typing}/filters.ts | 0 tests/{typings => typing}/get.ts | 0 tests/{typings => typing}/pluck.ts | 0 tests/{typings => typing}/types.ts | 0 19 files changed, 13 insertions(+), 6 deletions(-) rename tests/{logic => functionality}/createDict.test.ts (100%) rename tests/{logic => functionality}/createGetByKey.test.ts (100%) rename tests/{logic => functionality}/filters/and.test.ts (100%) rename tests/{logic => functionality}/filters/isNotNull.test.ts (100%) rename tests/{logic => functionality}/filters/isNotUndefined.test.ts (100%) rename tests/{logic => functionality}/filters/matchesPluckedStrings.test.ts (100%) rename tests/{logic => functionality}/filters/matchesString.test.ts (100%) rename tests/{logic => functionality}/filters/not.test.ts (100%) rename tests/{logic => functionality}/filters/or.test.ts (100%) rename tests/{logic => functionality}/get.test.ts (100%) rename tests/{logic => functionality}/pluck.test.ts (100%) rename tests/{typings => typing}/createDict.ts (100%) rename tests/{typings => typing}/createGetByKey.ts (100%) rename tests/{typings => typing}/filters.ts (100%) rename tests/{typings => typing}/get.ts (100%) rename tests/{typings => typing}/pluck.ts (100%) rename tests/{typings => typing}/types.ts (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e8d386f..99ac328 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,9 +16,16 @@ jobs: - name: Install dependencies run: npm install - - name: Run tests - run: npm test + - name: Run functionality tests + run: npm run test:functionality - - name: Success Message + - name: Functionality tests passed if: success() - run: echo "Tests passed successfully!" + run: echo "Functionality tests passed!" + + - name: Run typing tests + run: npm run test:typing + + - name: Typing tests passed + if: success() + run: echo "Typing tests passed!" diff --git a/package.json b/package.json index 706c401..5acbec3 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "types": "./dist/index.d.ts", "scripts": { "build": "npx rimraf dist && tsc -p ./tsconfig.build.json", - "typing-tests": "tsc -p tsconfig.tests.json", - "tests": "jest" + "tests:typing": "tsc -p tsconfig.tests.json", + "tests:functionality": "jest" }, "author": "avfirsov", "license": "MIT", diff --git a/tests/logic/createDict.test.ts b/tests/functionality/createDict.test.ts similarity index 100% rename from tests/logic/createDict.test.ts rename to tests/functionality/createDict.test.ts diff --git a/tests/logic/createGetByKey.test.ts b/tests/functionality/createGetByKey.test.ts similarity index 100% rename from tests/logic/createGetByKey.test.ts rename to tests/functionality/createGetByKey.test.ts diff --git a/tests/logic/filters/and.test.ts b/tests/functionality/filters/and.test.ts similarity index 100% rename from tests/logic/filters/and.test.ts rename to tests/functionality/filters/and.test.ts diff --git a/tests/logic/filters/isNotNull.test.ts b/tests/functionality/filters/isNotNull.test.ts similarity index 100% rename from tests/logic/filters/isNotNull.test.ts rename to tests/functionality/filters/isNotNull.test.ts diff --git a/tests/logic/filters/isNotUndefined.test.ts b/tests/functionality/filters/isNotUndefined.test.ts similarity index 100% rename from tests/logic/filters/isNotUndefined.test.ts rename to tests/functionality/filters/isNotUndefined.test.ts diff --git a/tests/logic/filters/matchesPluckedStrings.test.ts b/tests/functionality/filters/matchesPluckedStrings.test.ts similarity index 100% rename from tests/logic/filters/matchesPluckedStrings.test.ts rename to tests/functionality/filters/matchesPluckedStrings.test.ts diff --git a/tests/logic/filters/matchesString.test.ts b/tests/functionality/filters/matchesString.test.ts similarity index 100% rename from tests/logic/filters/matchesString.test.ts rename to tests/functionality/filters/matchesString.test.ts diff --git a/tests/logic/filters/not.test.ts b/tests/functionality/filters/not.test.ts similarity index 100% rename from tests/logic/filters/not.test.ts rename to tests/functionality/filters/not.test.ts diff --git a/tests/logic/filters/or.test.ts b/tests/functionality/filters/or.test.ts similarity index 100% rename from tests/logic/filters/or.test.ts rename to tests/functionality/filters/or.test.ts diff --git a/tests/logic/get.test.ts b/tests/functionality/get.test.ts similarity index 100% rename from tests/logic/get.test.ts rename to tests/functionality/get.test.ts diff --git a/tests/logic/pluck.test.ts b/tests/functionality/pluck.test.ts similarity index 100% rename from tests/logic/pluck.test.ts rename to tests/functionality/pluck.test.ts diff --git a/tests/typings/createDict.ts b/tests/typing/createDict.ts similarity index 100% rename from tests/typings/createDict.ts rename to tests/typing/createDict.ts diff --git a/tests/typings/createGetByKey.ts b/tests/typing/createGetByKey.ts similarity index 100% rename from tests/typings/createGetByKey.ts rename to tests/typing/createGetByKey.ts diff --git a/tests/typings/filters.ts b/tests/typing/filters.ts similarity index 100% rename from tests/typings/filters.ts rename to tests/typing/filters.ts diff --git a/tests/typings/get.ts b/tests/typing/get.ts similarity index 100% rename from tests/typings/get.ts rename to tests/typing/get.ts diff --git a/tests/typings/pluck.ts b/tests/typing/pluck.ts similarity index 100% rename from tests/typings/pluck.ts rename to tests/typing/pluck.ts diff --git a/tests/typings/types.ts b/tests/typing/types.ts similarity index 100% rename from tests/typings/types.ts rename to tests/typing/types.ts From 19f81b383ee927455ba515e517f6b4d269da0889 Mon Sep 17 00:00:00 2001 From: curious_andrew Date: Wed, 27 Dec 2023 14:38:39 +0300 Subject: [PATCH 3/4] fix typo --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99ac328..35ce133 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,14 +17,14 @@ jobs: run: npm install - name: Run functionality tests - run: npm run test:functionality + run: npm run tests:functionality - name: Functionality tests passed if: success() run: echo "Functionality tests passed!" - name: Run typing tests - run: npm run test:typing + run: npm run tests:typing - name: Typing tests passed if: success() From 5ec92dfd19162d676674152ab11e636fdd8cf84f Mon Sep 17 00:00:00 2001 From: curious_andrew Date: Wed, 3 Jan 2024 01:03:30 +0300 Subject: [PATCH 4/4] add publish pipeline with tests coverage collection --- .github/workflows/publish.yml | 67 +++++++++++++++++++++++++++++++++++ .gitignore | 3 +- jest.config.js | 4 ++- package.json | 2 +- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..94ec319 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,67 @@ +name: Node.js CI + +on: + push: + tags: -'v*' + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '14' + + - name: Install dependencies + run: npm install + + - name: Run functionality tests + run: npm run tests:functionality + + - name: Run typing tests + run: npm run tests:typing + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage/lcov.info + fail_ci_if_error: true + + build: + needs: test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '14' + - name: Install dependencies + run: npm install + - name: Build + run: npm run build + + publish: + needs: build + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'release') + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '14' + registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: npm install + - name: Build + run: npm run build + - name: Publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.gitignore b/.gitignore index d4e0572..31f7152 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .idea -dist \ No newline at end of file +dist +coverage \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index b413e10..14c6ac4 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,4 +2,6 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', -}; \ No newline at end of file + collectCoverage: true, + coverageReporters: ['json', 'lcov'], +} diff --git a/package.json b/package.json index 5acbec3..ca40c51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fancy-collections", - "version": "1.0.0", + "version": "1.1.0", "description": "A small collection of perfectly typed handy tools for everyday work with collections", "publishConfig": { "access": "public"