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

chore: CI workflow [DT-5996] #25

Merged
merged 14 commits into from
Nov 1, 2024
129 changes: 129 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: CI

on: [pull_request]

concurrency:
# Cancels workflows that are already running when a new one is triggered for a branch
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

format:
name: Format
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Format
run: pnpm fmt:check

lint:
name: Lint
runs-on: ubuntu-latest
# Skip job until we get a linter added
if: false

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: echo "Add pnpm lint command here"

test:
name: Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Test
run: pnpm test

typecheck:
name: Typecheck
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Typecheck
run: pnpm typecheck
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2024 Allen Institute
Copyright 2024 Allen Institute

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand All @@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
"regl": "^2.1.0",
"zarrita": "0.4.0-next.14"
}
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"build": "pnpm -r run --no-bail build",
"watch": "pnpm -r run watch",
"fmt": "npx prettier . --write",
"fmt:check": "npx prettier . --check"
"fmt:check": "npx prettier . --check",
"test": "pnpm -r run --no-bail test:ci",
"typecheck": "pnpm -r --no-bail run typecheck"
},
"devDependencies": {
"@parcel/packager-ts": "2.12.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/dzi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
"lodash": "^4.17.21",
"regl": "^2.1.0"
}
}
}
16 changes: 8 additions & 8 deletions packages/dzi/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ export function getVisibleTiles(dzi: DziImage, camera: { view: box2D; screenSize

const availableTiles = tilesInLayer(dzi, layer);
const baseLayer = findLargestSingleTileLayer(dzi);
const baseIndex: TileIndex = { col: 0, row: 0 }
const baseIndex: TileIndex = { col: 0, row: 0 };
const baseTile: DziTile = {
index: baseIndex,
layer: baseLayer,
relativeLocation: Box2D.create([0, 0], [1, 1]),
url: tileUrl(dzi, baseLayer, baseIndex)
}
url: tileUrl(dzi, baseLayer, baseIndex),
};

// note that the tile boxes are in pixels relative to the layer in which they reside
// the given view is assumed to be a parameter (in the space [0:1]) of the image as a whole
Expand All @@ -82,7 +82,7 @@ export function getVisibleTiles(dzi: DziImage, camera: { view: box2D; screenSize
// filter out tiles which are not in view
})
.filter((t) => !!Box2D.intersection(t.relativeLocation, camera.view));
return (baseLayer < layer) ? [baseTile, ...tiles] : tiles;
return baseLayer < layer ? [baseTile, ...tiles] : tiles;
}
/**
* NOTE: THE REMAINDER OF THIS FILE IS EXPORTED ONLY FOR TESTING PURPOSES
Expand All @@ -97,13 +97,13 @@ export function firstSuitableLayer(imageWidth: number, screenWidth: number) {
}

/**
*
* @param dzi
*
* @param dzi
* @returns the index of the largest layer which contains only a single tile
*
*
*/
function findLargestSingleTileLayer(dzi: DziImage): number {
return Math.floor(Math.log2(dzi.tileSize))
return Math.floor(Math.log2(dzi.tileSize));
}
export function tileWithOverlap(total: number, step: number, overlap: number): Interval[] {
const blocks: Interval[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/dzi/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function buildDziRenderer(regl: REGL.Regl): Renderer<DziImage, DziTile, R
};
};
return {
destroy: () => { }, // no private resources to destroy
destroy: () => {}, // no private resources to destroy
cacheKey: (item, _requestKey, _data, _settings) => `${item.url}`,
fetchItemContent: fetchDziTile,
getVisibleItems: (dzi, settings) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/geometry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
"typescript": "^5.3.3",
"vitest": "^1.4.0"
}
}
}