Skip to content

Commit

Permalink
Add minimal ci (#9)
Browse files Browse the repository at this point in the history
* Add minimal ci

* update yarn cache

* remove typecheck check

* fmt

* remove vitest typecheck
  • Loading branch information
kylebarron authored Nov 22, 2023
1 parent 847cc01 commit b08e637
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 29 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches:
- 'main'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
lint-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Volta
uses: volta-cli/action@v4

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ".yarn/cache"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install

- name: Prettier check
run: yarn fmt:check

- name: Type check
run: yarn typecheck

- name: Test
run: yarn test
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"semi": true,
"trailingComma": "all"
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "tsc --watch --declaration",
"test": "vitest run"
"fmt:check": "prettier ./src/**/*.ts --check",
"fmt": "prettier ./src/**/*.ts --write",
"test": "vitest run",
"typecheck": "tsc --build"
},
"files": [
"dist/",
Expand All @@ -36,6 +39,7 @@
"@rollup/plugin-typescript": "^11.1.2",
"@types/node": "^20.9.3",
"apache-arrow": "^14",
"prettier": "^3.1.0",
"rollup": "^4.1.5",
"rollup-plugin-dts": "^6.1.0",
"ts-node": "^10.9.1",
Expand Down
6 changes: 3 additions & 3 deletions src/algorithm/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function area(input: PolygonData): arrow.Data<arrow.Float>;
export function area(input: PolygonVector): arrow.Vector<arrow.Float>;

export function area(
input: PolygonData | PolygonVector
input: PolygonData | PolygonVector,
): arrow.Data<arrow.Float> | arrow.Vector<arrow.Float> {
if ("data" in input) {
return new arrow.Vector(input.data.map((polygonData) => area(polygonData)));
Expand Down Expand Up @@ -38,11 +38,11 @@ export function signedArea(input: PolygonData): arrow.Data<arrow.Float>;
export function signedArea(input: PolygonVector): arrow.Vector<arrow.Float>;

export function signedArea(
input: PolygonData | PolygonVector
input: PolygonData | PolygonVector,
): arrow.Data<arrow.Float> | arrow.Vector<arrow.Float> {
if ("data" in input) {
return new arrow.Vector(
input.data.map((polygonData) => signedArea(polygonData))
input.data.map((polygonData) => signedArea(polygonData)),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/earcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function earcut(input: PolygonData): Uint32Array;
export function earcut(input: PolygonVector): Uint32Array[];

export function earcut(
input: PolygonData | PolygonVector
input: PolygonData | PolygonVector,
): Uint32Array | Uint32Array[] {
if ("data" in input) {
return input.data.map((data) => earcut(data));
Expand Down Expand Up @@ -53,7 +53,7 @@ function earcutSinglePolygon(data: PolygonData, geomIndex: number): number[] {

const slicedFlatCoords = flatCoords.values.subarray(
coordsBegin * dim,
coordsEnd * dim
coordsEnd * dim,
);

const initialCoordIndex = ringOffsets[ringBegin];
Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/utils/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

export function makeMathGlPolygon(
data: PolygonData,
geomIndex: number
geomIndex: number,
): Polygon {
const geomOffsets = data.valueOffsets;
const ringsData = getPolygonChild(data);
Expand All @@ -26,7 +26,7 @@ export function makeMathGlPolygon(

const slicedFlatCoords = flatCoordData.values.subarray(
coordsBegin * dim,
coordsEnd * dim
coordsEnd * dim,
);
return new Polygon(slicedFlatCoords, {
size: dim,
Expand Down
14 changes: 7 additions & 7 deletions src/algorithm/winding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export enum Winding {
*/
export function windingDirection(input: PolygonData): arrow.Data<arrow.Bool>;
export function windingDirection(
input: PolygonVector
input: PolygonVector,
): arrow.Vector<arrow.Bool>;

export function windingDirection(
input: PolygonData | PolygonVector
input: PolygonData | PolygonVector,
): arrow.Data<arrow.Bool> | arrow.Vector<arrow.Bool> {
if ("data" in input) {
return new arrow.Vector(
input.data.map((polygonData) => windingDirection(polygonData))
input.data.map((polygonData) => windingDirection(polygonData)),
);
}

Expand Down Expand Up @@ -55,20 +55,20 @@ export function windingDirection(
*/
export function modifyWindingDirection(
input: PolygonData,
winding: Winding
winding: Winding,
): void;
export function modifyWindingDirection(
input: PolygonVector,
winding: Winding
winding: Winding,
): void;

export function modifyWindingDirection(
input: PolygonData | PolygonVector,
winding: Winding
winding: Winding,
): void {
if ("data" in input) {
input.data.forEach((polygonData) =>
modifyWindingDirection(polygonData, winding)
modifyWindingDirection(polygonData, winding),
);
return;
}
Expand Down
16 changes: 8 additions & 8 deletions src/child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getPointChild(input: PointData): arrow.Data<arrow.Float>;
export function getPointChild(input: PointVector): arrow.Vector<arrow.Float>;

export function getPointChild(
input: PointData | PointVector
input: PointData | PointVector,
): arrow.Data<arrow.Float> | arrow.Vector<arrow.Float> {
if ("data" in input) {
return input.getChildAt(0)!;
Expand All @@ -37,7 +37,7 @@ export function getLineStringChild(input: LineStringData): PointData;
export function getLineStringChild(input: LineStringVector): PointVector;

export function getLineStringChild(
input: LineStringData | LineStringVector
input: LineStringData | LineStringVector,
): PointData | PointVector {
if ("data" in input) {
return input.getChildAt(0)!;
Expand All @@ -50,7 +50,7 @@ export function getPolygonChild(input: PolygonData): LineStringData;
export function getPolygonChild(input: PolygonVector): LineStringVector;

export function getPolygonChild(
input: PolygonData | PolygonVector
input: PolygonData | PolygonVector,
): LineStringData | LineStringVector {
if ("data" in input) {
return input.getChildAt(0)!;
Expand All @@ -63,7 +63,7 @@ export function getMultiPointChild(input: MultiPointData): PointData;
export function getMultiPointChild(input: MultiPointVector): PointVector;

export function getMultiPointChild(
input: MultiPointData | MultiPointVector
input: MultiPointData | MultiPointVector,
): PointData | PointVector {
if ("data" in input) {
return input.getChildAt(0)!;
Expand All @@ -73,14 +73,14 @@ export function getMultiPointChild(
}

export function getMultiLineStringChild(
input: MultiLineStringData
input: MultiLineStringData,
): LineStringData;
export function getMultiLineStringChild(
input: MultiLineStringVector
input: MultiLineStringVector,
): LineStringVector;

export function getMultiLineStringChild(
input: MultiLineStringData | MultiLineStringVector
input: MultiLineStringData | MultiLineStringVector,
): LineStringData | LineStringVector {
if ("data" in input) {
return input.getChildAt(0)!;
Expand All @@ -93,7 +93,7 @@ export function getMultiPolygonChild(input: MultiPolygonData): PolygonData;
export function getMultiPolygonChild(input: MultiPolygonVector): PolygonVector;

export function getMultiPolygonChild(
input: MultiPolygonData | MultiPolygonVector
input: MultiPolygonData | MultiPolygonVector,
): PolygonData | PolygonVector {
if ("data" in input) {
return input.getChildAt(0)!;
Expand Down
2 changes: 1 addition & 1 deletion src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function isMultiPointData(data: arrow.Data): data is MultiPointData {
}

export function isMultiLineStringData(
data: arrow.Data
data: arrow.Data,
): data is MultiLineStringData {
return isMultiLineString(data.type);
}
Expand Down
2 changes: 1 addition & 1 deletion src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function isMultiPoint(type: arrow.DataType): type is MultiPoint {
}

export function isMultiLineString(
type: arrow.DataType
type: arrow.DataType,
): type is MultiLineString {
// Check the outer vector is a List
if (!arrow.DataType.isList(type)) {
Expand Down
8 changes: 4 additions & 4 deletions src/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function isPointVector(vector: arrow.Vector): vector is PointVector {
}

export function isLineStringVector(
vector: arrow.Vector
vector: arrow.Vector,
): vector is LineStringVector {
return isLineString(vector.type);
}
Expand All @@ -36,19 +36,19 @@ export function isPolygonVector(vector: arrow.Vector): vector is PolygonVector {
}

export function isMultiPointVector(
vector: arrow.Vector
vector: arrow.Vector,
): vector is MultiPointVector {
return isMultiPoint(vector.type);
}

export function isMultiLineStringVector(
vector: arrow.Vector
vector: arrow.Vector,
): vector is MultiLineStringVector {
return isMultiLineString(vector.type);
}

export function isMultiPolygonVector(
vector: arrow.Vector
vector: arrow.Vector,
): vector is MultiPolygonVector {
return isMultiPolygon(vector.type);
}
7 changes: 7 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, expect, it } from "vitest";

describe("hello world", (t) => {
it("foo", () => {
expect(true).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ __metadata:
"@rollup/plugin-typescript": "npm:^11.1.2"
"@types/node": "npm:^20.9.3"
apache-arrow: "npm:^14"
prettier: "npm:^3.1.0"
rollup: "npm:^4.1.5"
rollup-plugin-dts: "npm:^6.1.0"
ts-node: "npm:^10.9.1"
Expand Down Expand Up @@ -1769,6 +1770,15 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^3.1.0":
version: 3.1.0
resolution: "prettier@npm:3.1.0"
bin:
prettier: bin/prettier.cjs
checksum: e95e8f93c6b9aea2ac1e86bebe329bee90c8c50d9a23d1f593eba8d7f39b33b3641eb28785001505b6723c47895a5322ad12a2fb855b289cb7bae450ffc34425
languageName: node
linkType: hard

"pretty-format@npm:^29.5.0":
version: 29.7.0
resolution: "pretty-format@npm:29.7.0"
Expand Down

0 comments on commit b08e637

Please sign in to comment.