Skip to content

Commit

Permalink
feat: Updated tests and switched environment
Browse files Browse the repository at this point in the history
  • Loading branch information
iFaxity committed Jun 25, 2022
1 parent f54ef53 commit c69b14e
Show file tree
Hide file tree
Showing 103 changed files with 2,223 additions and 17,686 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches:
- main
- next
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches:
- main
schedule:
- cron: '43 1 * * 5'

Expand All @@ -28,7 +31,8 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language:
- javascript
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
Expand Down
68 changes: 19 additions & 49 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ name: Test and Deploy
on:
push:
branches:
- master
- main
- next
pull_request:
branches:
- master
- main

env:
CY_COVERAGE_OUTPUT: ./cypress/coverage/lcov.info
COVERAGE_OUTPUT: ./coverage/lcov.info
CACHE_PATHS: |
**/node_modules
~/.cache/Cypress
jobs:
# Setups testing environment on each version
setup:
name: Setup (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ macos-latest, windows-latest, ubuntu-latest ]
name: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18
- name: Cache dependencies
id: cache
uses: actions/cache@v2
Expand All @@ -38,71 +34,47 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

# Testing through cypress
# Testing through Vitest
test:
name: Test (${{ matrix.os }}, ${{ matrix.browser }})
name: Test
needs: setup
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
os: [ macos-latest, ubuntu-latest ]
browser: [ chrome, firefox ]
experimental: [ false ]
include:
# Cypress + Windows = fails, sometimes
- os: windows-latest
browser: edge
experimental: true
- os: windows-latest
browser: firefox
experimental: true
- os: windows-latest
browser: chrome
experimental: true
runs-on: ubuntu-latest

steps:
# Restore packages from cache
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}#${{ hashFiles('package-lock.json') }}

- name: Run cypress (Cypress)
uses: cypress-io/github-action@v2
env:
DEBUG: code-coverage
with:
browser: ${{ matrix.browser }}
# Run tests
- name: Run Vitest
run: npm run test:coverage

# Upload coverage report to codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
flags: unittests
file: ${{ env.CY_COVERAGE_OUTPUT }}
name: ${{ runner.os }} - ${{ matrix.browser }}
# Should be true, but Windows is being difficult
fail_ci_if_error: false
file: ${{ env.COVERAGE_OUTPUT }}

# Release verison if tests succeeded
# Release verison if tests succeeded, (only for main branch)
release:
name: Publish
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18

- name: Install dependencies
run: npm ci
- name: Build
Expand All @@ -113,5 +85,3 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}


30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ InterLINQed
[![Codacy grade](https://img.shields.io/codacy/grade/e723a0514a1843e584c7f44fb29d3c63?style=for-the-badge&logo=codacy)](https://app.codacy.com/gh/iFaxity/interlinqed/dashboard)
[![npm](https://img.shields.io/npm/v/interlinqed?style=for-the-badge&logo=npm)](https://npmjs.org/package/interlinqed)

A functional implementation of LINQ in TypeScript, inspired by [linq-ts](https://www.npmjs.com/package/linqts).
A functional implementation of LINQ in TypeScript using iterators, inspired by [linq-ts](https://www.npmjs.com/package/linqts).

So why use this package over linq-ts?
Well if you use linq-ts there is no tree shake support at all since it uses classes.
Which amounts up to 7.4kb minified code (according to bundlephobia).
7.4kb of code just for transforming lists is a bit much in the modern web, if you do not use everything from the library.

Well this package is funtional and therefore fully tree shaken, which decreases the bundle size to mere bytes if you only use a handful of functions.
This package is based on pure functions and therefore supports tree-shaking, which decreases the bundle size to mere bytes if you only use a handful of functions.

However to fully support TypeScript this is a functional library that uses a chaining method to chain together the different functions, hence the name **interlinqed**, check the [examples](#examples) section for more specific details.
However to fully support TypeScript this is a pure-function library that uses a chaining method to chain together the different functions, hence the name **interlinqed**, check the [examples](#examples) section for more specific details.

The target browsers are IE9+ or any ES5 compatible browser version.
The functions can be used on their own but it is easier to use the linq helper to automatically resolve types and chain the methods correctly.

The target browsers are any ES6 compatible browser version as the package uses Generators.
Use 1.x.x if support for an older browser is required (IE9+).

Installation
--------------------------
Expand All @@ -31,14 +34,14 @@ API
--------------------------

```js
import { Linq } from 'interlinqed';
import { linq } from 'interlinqed';
```

Examples
--------------------------

```js
import { Linq, Where, Select, OrderBy, ThenByDescending } from 'interlinqed';
import { linq, where, select, orderBy, thenByDescending, toArray } from 'interlinqed';

const pets = [
{ name: 'Barley', age: 8 },
Expand All @@ -51,12 +54,12 @@ const pets = [
{ name: 'Hogan', age: 12 },
];

const result = Linq(pets,
list => Where(list, pet => pet.age > 3),
list => OrderBy(list, pet => pet.age,
ThenByDescending(pet => pet.name)
),
list => Select(list, pet => ([ pet.name, pet.age ]))
const result = linq(pets,
where(pet => pet.age > 3),
orderBy(pet => pet.age),
thenByDescending(pet => pet.name),
select(pet => ([ pet.name, pet.age ])),
toArray(),
);

/*
Expand All @@ -74,7 +77,8 @@ result = [
Docs
--------------------------

The typedoc are available [here](https://ifaxity.github.io/interlinqed).
The typedoc is available [here](https://ifaxity.github.io/interlinqed).
Only available for the latest version.

Testing
--------------------------
Expand Down
44 changes: 0 additions & 44 deletions bin/build

This file was deleted.

6 changes: 0 additions & 6 deletions cypress.json

This file was deleted.

78 changes: 0 additions & 78 deletions cypress/integration/builder.spec.ts

This file was deleted.

Loading

0 comments on commit c69b14e

Please sign in to comment.