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

Fixes to allow Deno check to pass and build to succeed. #2161

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9d18828
add further type checks to catching errors, and then immediately ts-i…
rwblair Oct 14, 2024
cbe29a7
bump github workflows to use deno v2
rwblair Oct 14, 2024
0c4088e
do we really need to specify --node-modules-dir=auto for these deno c…
rwblair Oct 14, 2024
ff37b3a
allow-env during build step.
rwblair Oct 14, 2024
15ebfce
why does installing std library require special permissions?
rwblair Oct 14, 2024
8877ba6
build needs to run git, set --allow-run
rwblair Oct 14, 2024
e6aea46
should of just -A'd it eh?
rwblair Oct 14, 2024
0af7d7e
Update .github/workflows/deno_tests.yml
effigies Oct 15, 2024
a174a76
specify default import from ajv in validators/json.ts imports
rwblair Oct 15, 2024
d941cf6
Merge branch 'fix/deno_2_test_and_build' of github.com:rwblair/bids-v…
rwblair Oct 15, 2024
b67e28f
revert ajv import bump version. Deno may be installing from package.j…
rwblair Oct 15, 2024
dde7007
bump ajv in package.json. Will this break legacy?
rwblair Oct 15, 2024
0b88900
Revert "bump ajv in package.json. Will this break legacy?"
rwblair Oct 15, 2024
fd86b31
move legacy validator to its own directory.
rwblair Oct 15, 2024
3ac00ad
working-dir -> working-directory
rwblair Oct 15, 2024
3331f80
more working-directory setting. fix sym link from legacy test to curr…
rwblair Oct 15, 2024
d3258d2
more working-directory setting. fix sym link from legacy test to curr…
rwblair Oct 15, 2024
c9ed50c
in progress README updates
rwblair Oct 15, 2024
064fea7
Merge branch 'master' of github.com:bids-standard/bids-validator into…
rwblair Oct 17, 2024
c87f70c
set working directory for circleci
rwblair Oct 17, 2024
e9e919c
Merge branch 'fix/deno_2_test_and_build' of github.com:rwblair/bids-v…
rwblair Oct 17, 2024
10044b7
deno loader back to version 11
rwblair Oct 17, 2024
efbbc77
amend circle cache paths, they may not respect working-directory
rwblair Oct 17, 2024
bc6afbb
working-directory -> working_directory
rwblair Oct 17, 2024
8f4fd8f
fix call to get local version
rwblair Oct 17, 2024
25c4bb3
remove circleci config
rwblair Oct 17, 2024
0c3f8a8
first pass at deno dockerfile. Update docker github workflow accordin…
rwblair Oct 21, 2024
5f75b1e
Revert "remove circleci config"
rwblair Oct 21, 2024
6923b6f
Move dockerfile to base. Deno cli now handles git not existing.
rwblair Oct 24, 2024
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
10 changes: 5 additions & 5 deletions .github/workflows/deno_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
- name: Save describe stamp
id: describe
run: echo version=$( git describe ) >> $GITHUB_OUTPUT
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: v1.x
- run: ./build.ts
deno-version: v2.x
- run: deno --node-modules-dir=auto --allow-env --allow-read --allow-run --allow-net ./build.ts
effigies marked this conversation as resolved.
Show resolved Hide resolved
working-directory: ./bids-validator
- run: deno run -A ./bids-validator/dist/validator/bids-validator.js --version
- uses: actions/upload-artifact@v4
Expand All @@ -52,14 +52,14 @@ jobs:
submodules: true
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
deno-version: v2.x
- name: Set permissions with network access
run: echo 'PERMS=--allow-read --allow-write --allow-env --allow-run --allow-net' >> $GITHUB_ENV
if: ${{ matrix.allow-net }}
- name: Set permissions without network access
run: echo 'PERMS=--allow-read --allow-write --allow-env --allow-run --deny-net' >> $GITHUB_ENV
if: ${{ ! matrix.allow-net }}
- run: deno test $PERMS --coverage=cov/ src/
- run: deno test --node-modules-dir=auto $PERMS --coverage=cov/ src/
- name: Collect coverage
run: deno coverage cov/ --lcov --output=coverage.lcov
if: ${{ always() }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schema_web_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: v1.x
deno-version: v2.x
- run: deno task build
working-directory: ./web
- uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schema_web_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: v1.x
deno-version: v2.x
- run: deno task build
working-directory: ./web
- name: Install NPM deps
Expand Down
2 changes: 1 addition & 1 deletion bids-validator/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@bids/schema": "jsr:@bids/[email protected]+d9c23eb0",
"@cliffy/command": "jsr:@cliffy/[email protected]",
"@cliffy/table": "jsr:@cliffy/[email protected]",
"@hed/validator": "npm:[email protected].4",
"@hed/validator": "npm:[email protected].5",
"@ignore": "npm:[email protected]",
"@libs/xml": "jsr:@libs/[email protected]",
"@mango/nifti": "npm:[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion bids-validator/src/files/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assertEquals, assertObjectMatch } from '@std/assert'
import { BIDSFileBrowser, fileListToTree } from './browser.ts'

class TestFile extends File {
webkitRelativePath: string
override webkitRelativePath: string
constructor(
fileBits: BlobPart[],
fileName: string,
Expand Down
4 changes: 2 additions & 2 deletions bids-validator/src/files/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class BIDSFileDeno implements BIDSFile {
try {
this.#fileInfo = Deno.statSync(this._getPath())
} catch (error) {
if (error.code === 'ENOENT') {
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
this.#fileInfo = Deno.lstatSync(this._getPath())
}
}
Expand Down Expand Up @@ -158,7 +158,7 @@ export async function readFileTree(rootPath: string): Promise<FileTree> {
)
ignore.add(await readBidsIgnore(ignoreFile))
} catch (err) {
if (!Object.hasOwn(err, 'code') || err.code !== 'ENOENT') {
if (err && typeof err === 'object' && !('code' in err && err.code !== 'ENOENT')) {
logger.error(`Failed to read '.bidsignore' file with the following error:\n${err}`)
}
}
Expand Down
5 changes: 4 additions & 1 deletion bids-validator/src/files/inheritance.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals, assertThrows } from '@std/assert'
import { assert, assertEquals, assertThrows } from '@std/assert'
import { pathsToTree } from './filetree.ts'
import { walkBack } from './inheritance.ts'

Expand All @@ -17,6 +17,9 @@ Deno.test('walkback inheritance tests', async (t) => {
continue
}
} catch (error) {
assert(error)
assert(typeof error === 'object')
assert('code' in error)
assertEquals(error.code, 'MULTIPLE_INHERITABLE_FILES')
throw error
}
Expand Down
3 changes: 2 additions & 1 deletion bids-validator/src/schema/associations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@
try {
file = walkBack(source, inherit, extensions, suffix).next().value
} catch (error) {
if (error.code === 'MULTIPLE_INHERITABLE_FILES') {
if (error && typeof error === 'object' && 'code' in error && error.code === 'MULTIPLE_INHERITABLE_FILES') {
// @ts-expect-error

Check warning on line 167 in bids-validator/src/schema/associations.ts

View check run for this annotation

Codecov / codecov/patch

bids-validator/src/schema/associations.ts#L166-L167

Added lines #L166 - L167 were not covered by tests
issues.add(error)
break
} else {
Expand Down
3 changes: 2 additions & 1 deletion bids-validator/src/schema/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
try {
sidecars = [...walkBack(this.file)]
} catch (error) {
if (error.code === 'MULTIPLE_INHERITABLE_FILES') {
if (error && typeof error === 'object' && 'code' in error && error.code === 'MULTIPLE_INHERITABLE_FILES') {
// @ts-expect-error

Check warning on line 188 in bids-validator/src/schema/context.ts

View check run for this annotation

Codecov / codecov/patch

bids-validator/src/schema/context.ts#L187-L188

Added lines #L187 - L188 were not covered by tests
this.dataset.issues.add(error)
} else {
throw error
Expand Down
3 changes: 2 additions & 1 deletion bids-validator/src/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export class SchemaStructureError extends Error {
constructor(schemaPath) {
schemaPath: string
constructor(schemaPath: string) {
super(`Validator attempted to access ${schemaPath}, but it wasn't there.`)
this.name = 'SchemaStructureError'
this.schemaPath = schemaPath
Expand Down
2 changes: 1 addition & 1 deletion bids-validator/src/validators/hed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function hedValidate(
context.dataset.issues.add({
code: 'HED_ERROR',
location: context.path,
issueMessage: error,
issueMessage: error as string,
})
}

Expand Down
14 changes: 0 additions & 14 deletions bids-validator/src/validators/isBidsy.ts

This file was deleted.

11 changes: 5 additions & 6 deletions bids-validator/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ export async function getVersion(): Promise<string> {
}

async function getLocalVersion(path: string): Promise<string> {
const p = Deno.run({
// safe.directory setting so we could still operate from another user
cmd: ['git', '-C', path, '-c', 'safe.directory=*', 'describe', '--tags', '--always'],
stdout: 'piped',
// safe.directory setting so we could still operate from another user
const command = new Deno.Command("git", {
args: ['git', '-C', path, '-c', 'safe.directory=*', 'describe', '--tags', '--always'],
})
const description = new TextDecoder().decode(await p.output()).trim()
p.close()
const { success, stdout } = await command.output();
const description = new TextDecoder().decode(stdout).trim()
return description
}

Expand Down
Loading