Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI lint and test #82

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install
run: npm install

- name: Prettier check
run: npm run fmt:check

- name: Type check
run: npm run typecheck

- name: Test
run: npm run 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"
}
56 changes: 48 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
"default": "./dist/dist.es.mjs"
},
"scripts": {
"build": "npm run build:tsc && npm run build:rollup",
"build:tsc": "tsc",
"build:rollup": "rollup -c rollup.config.js",
"build:tsc": "tsc",
"build": "npm run build:tsc && npm run build:rollup",
"clean": "rimraf dist",
"watch": "tsc --watch",
"fmt:check": "prettier './src/**/*.ts' --check",
"fmt": "prettier './src/**/*.ts' --write",
"prepublishOnly": "npm run clean && npm run build",
"test": "vitest run",
"prepublishOnly": "npm run clean && npm run build"
"typecheck": "tsc --build",
"watch": "tsc --watch"
},
"files": [
"dist/",
Expand All @@ -54,6 +57,7 @@
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.2",
"apache-arrow": "^13.0.0",
"prettier": "^3.1.0",
"rimraf": "^5.0.5",
"rollup": "^3.26.2",
"rollup-plugin-dts": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/arc-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const defaultProps: DefaultProps<GeoArrowArcLayerProps> = {
};

export class GeoArrowArcLayer<
ExtraProps extends {} = {}
ExtraProps extends {} = {},
> extends CompositeLayer<Required<GeoArrowArcLayerProps> & ExtraProps> {
static defaultProps = defaultProps;
static layerName = "GeoArrowArcLayer";
Expand Down
4 changes: 2 additions & 2 deletions src/column-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const defaultProps: DefaultProps<GeoArrowColumnLayerProps> = {
* coordinates.
*/
export class GeoArrowColumnLayer<
ExtraProps extends {} = {}
ExtraProps extends {} = {},
> extends CompositeLayer<Required<GeoArrowColumnLayerProps> & ExtraProps> {
static defaultProps = defaultProps;
static layerName = "GeoArrowColumnLayer";
Expand All @@ -130,7 +130,7 @@ export class GeoArrowColumnLayer<
}

_renderLayersPoint(
geometryColumn: PointVector
geometryColumn: PointVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down
2 changes: 1 addition & 1 deletion src/earcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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
2 changes: 1 addition & 1 deletion src/h3-hexagon-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const defaultProps: DefaultProps<GeoArrowH3HexagonLayerProps> = {
};

export class GeoArrowH3HexagonLayer<
ExtraProps extends {} = {}
ExtraProps extends {} = {},
> extends CompositeLayer<Required<GeoArrowH3HexagonLayerProps> & ExtraProps> {
static defaultProps = defaultProps;
static layerName = "GeoArrowH3HexagonLayer";
Expand Down
4 changes: 2 additions & 2 deletions src/heatmap-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const defaultProps: DefaultProps<GeoArrowHeatmapLayerProps> = {
};

export class GeoArrowHeatmapLayer<
ExtraProps extends {} = {}
ExtraProps extends {} = {},
> extends CompositeLayer<Required<GeoArrowHeatmapLayerProps> & ExtraProps> {
static defaultProps = defaultProps;
static layerName = "GeoArrowHeatmapLayer";
Expand All @@ -92,7 +92,7 @@ export class GeoArrowHeatmapLayer<
}

_renderLayersPoint(
geometryColumn: PointVector
geometryColumn: PointVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down
10 changes: 5 additions & 5 deletions src/path-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const defaultProps: DefaultProps<GeoArrowPathLayerProps> = {
* Render lists of coordinate points as extruded polylines with mitering.
*/
export class GeoArrowPathLayer<
ExtraProps extends {} = {}
ExtraProps extends {} = {},
> extends CompositeLayer<Required<GeoArrowPathLayerProps> & ExtraProps> {
static defaultProps = defaultProps;
static layerName = "GeoArrowPathLayer";
Expand All @@ -112,15 +112,15 @@ export class GeoArrowPathLayer<

const lineStringVector = getGeometryVector(
table,
EXTENSION_NAME.LINESTRING
EXTENSION_NAME.LINESTRING,
);
if (lineStringVector !== null) {
return this._renderLayersLineString(lineStringVector);
}

const multiLineStringVector = getGeometryVector(
table,
EXTENSION_NAME.MULTILINESTRING
EXTENSION_NAME.MULTILINESTRING,
);
if (multiLineStringVector !== null) {
return this._renderLayersMultiLineString(multiLineStringVector);
Expand All @@ -139,7 +139,7 @@ export class GeoArrowPathLayer<
}

_renderLayersLineString(
geometryColumn: LineStringVector
geometryColumn: LineStringVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down Expand Up @@ -206,7 +206,7 @@ export class GeoArrowPathLayer<
}

_renderLayersMultiLineString(
geometryColumn: MultiLineStringVector
geometryColumn: MultiLineStringVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down
2 changes: 1 addition & 1 deletion src/picking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GeoArrowPickingInfo } from "./types";

export function getPickingInfo(
{ info, sourceLayer }: GetPickingInfoParams,
table: arrow.Table
table: arrow.Table,
): GeoArrowPickingInfo {
// Geometry index as rendered
let index = info.index;
Expand Down
8 changes: 4 additions & 4 deletions src/scatterplot-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const defaultProps: DefaultProps<GeoArrowScatterplotLayerProps> = {
};

export class GeoArrowScatterplotLayer<
ExtraProps extends {} = {}
ExtraProps extends {} = {},
> extends CompositeLayer<Required<GeoArrowScatterplotLayerProps> & ExtraProps> {
static defaultProps = defaultProps;
static layerName = "GeoArrowScatterplotLayer";
Expand All @@ -116,7 +116,7 @@ export class GeoArrowScatterplotLayer<

const multiPointVector = getGeometryVector(
table,
EXTENSION_NAME.MULTIPOINT
EXTENSION_NAME.MULTIPOINT,
);
if (multiPointVector !== null) {
return this._renderLayersMultiPoint(multiPointVector);
Expand All @@ -135,7 +135,7 @@ export class GeoArrowScatterplotLayer<
}

_renderLayersPoint(
geometryColumn: PointVector
geometryColumn: PointVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down Expand Up @@ -197,7 +197,7 @@ export class GeoArrowScatterplotLayer<
}

_renderLayersMultiPoint(
geometryColumn: MultiPointVector
geometryColumn: MultiPointVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down
10 changes: 5 additions & 5 deletions src/solid-polygon-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const defaultProps: DefaultProps<GeoArrowSolidPolygonLayerProps> = {
};

export class GeoArrowSolidPolygonLayer<
ExtraProps extends {} = {}
ExtraProps extends {} = {},
> extends CompositeLayer<
Required<GeoArrowSolidPolygonLayerProps> & ExtraProps
> {
Expand All @@ -122,7 +122,7 @@ export class GeoArrowSolidPolygonLayer<

const MultiPolygonVector = getGeometryVector(
table,
EXTENSION_NAME.MULTIPOLYGON
EXTENSION_NAME.MULTIPOLYGON,
);
if (MultiPolygonVector !== null) {
return this._renderLayersMultiPolygon(MultiPolygonVector);
Expand All @@ -141,7 +141,7 @@ export class GeoArrowSolidPolygonLayer<
}

_renderLayersPolygon(
geometryColumn: PolygonVector
geometryColumn: PolygonVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down Expand Up @@ -217,7 +217,7 @@ export class GeoArrowSolidPolygonLayer<
}

_renderLayersMultiPolygon(
geometryColumn: MultiPolygonVector
geometryColumn: MultiPolygonVector,
): Layer<{}> | LayersList | null {
const { data: table } = this.props;

Expand Down Expand Up @@ -322,7 +322,7 @@ export class GeoArrowSolidPolygonLayer<

function encodePickingColors(
geomToCoordOffsets: Int32Array,
encodePickingColor: (id: number, result: number[]) => void
encodePickingColor: (id: number, result: number[]) => void,
): Uint8ClampedArray {
const largestOffset = geomToCoordOffsets[geomToCoordOffsets.length - 1];
const pickingColors = new Uint8ClampedArray(largestOffset);
Expand Down
Loading