diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..7fb2a632 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,26 @@ +name: Check + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + check: + name: Check + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Deno + uses: denoland/setup-deno@v1 + + - name: Check format + run: deno fmt + + - name: Check lint + run: deno lint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c54e72de..37b26b3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,18 +12,10 @@ permissions: contents: read jobs: + check: + name: Check + uses: ./.github/workflows/check.yml + test: name: Test - uses: hasundue/actions/.github/workflows/test-deno.yml@main - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - with: - task: test:unit - submodules: true - - integration: - name: Integration - uses: hasundue/actions/.github/workflows/integration-deno.yml@main - with: - task: test:integration - submodules: true + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..71caa73a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,77 @@ +name: Test + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +defaults: + run: + shell: bash + +jobs: + test: + name: Test + + strategy: + fail-fast: false + matrix: + package: + - cli + - core + - integration + - lib + os: + - ubuntu-latest + - macos-latest + - windows-latest + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Setup Deno + uses: denoland/setup-deno@v1 + + - name: Setup Deno cache + uses: actions/cache@v4 + with: + path: ~/.cache/deno + key: deno-${{ hashFiles('./deno.lock') }} + restore-keys: deno + + - name: Setup Rust cache + if: matrix.package == 'core' + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-${{ hashFiles('./**/Cargo.lock') }} + restore-keys: cargo + + - name: Build core/deno_lockfile + if: matrix.package == 'core' || matrix.package == 'cli' + run: | + cd core/deno_lockfile + deno task build + + - name: Run tests + run: deno test -A --unstable-kv --coverage=./coverage_profile ${{ matrix.package }} + + - name: Create coverage report + run: deno coverage ./coverage_profile --lcov --output=./coverage.lcov + + - name: Upload to Codecov + uses: codecov/codecov-action@v4 + with: + directory: ./ + file: ./coverage.lcov + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/core/bumps.ts b/core/bumps.ts index d1acc349..38e5b205 100644 --- a/core/bumps.ts +++ b/core/bumps.ts @@ -1,5 +1,5 @@ import { increase } from "@molt/lib/constraints"; -import { DependencyState, DependencyUpdate } from "./updates.ts"; +import type { DependencyState, DependencyUpdate } from "./updates.ts"; import * as SemVer from "@std/semver"; export interface DependencyBump { diff --git a/core/locks.ts b/core/locks.ts index 0f530597..fc764aae 100644 --- a/core/locks.ts +++ b/core/locks.ts @@ -9,7 +9,7 @@ import { type NpmPackageInfo, } from "./deno_lockfile/js/mod.ts"; import { - DependencySpec, + type DependencySpec, identify, isDependencySpec, isRemote, diff --git a/core/locks_test.ts b/core/locks_test.ts index ad13fb1a..fbc8dac7 100644 --- a/core/locks_test.ts +++ b/core/locks_test.ts @@ -2,7 +2,7 @@ import * as fs from "@chiezo/amber/fs"; import { assertEquals } from "@std/assert"; import { afterEach, beforeEach, describe, it } from "@std/testing/bdd"; import { parse } from "./specs.ts"; -import { create, extract, LockfileJson, query } from "./locks.ts"; +import { create, extract, type LockfileJson, query } from "./locks.ts"; export const LOCKFILE: LockfileJson = JSON.parse(`{ "version": "3", diff --git a/core/specs.ts b/core/specs.ts index add46cac..4a455634 100644 --- a/core/specs.ts +++ b/core/specs.ts @@ -1,5 +1,5 @@ import { assert } from "@std/assert"; -import { is, Predicate } from "@core/unknownutil"; +import { is, type Predicate } from "@core/unknownutil"; export type DependencyKind = "jsr" | "npm" | "http" | "https"; diff --git a/core/types.ts b/core/types.ts index 21fc6f91..87302424 100644 --- a/core/types.ts +++ b/core/types.ts @@ -1,4 +1,4 @@ -import { DependencyKind } from "./specs.ts"; +import type { DependencyKind } from "./specs.ts"; export type { DependencyBump } from "./bumps.ts"; export type { LockfileJson } from "./locks.ts"; diff --git a/core/updates.ts b/core/updates.ts index d43aa77d..89c7fa38 100644 --- a/core/updates.ts +++ b/core/updates.ts @@ -2,7 +2,7 @@ import { ensure, is } from "@core/unknownutil"; import { filterValues, mapNotNullish, maxWith } from "@std/collections"; import * as SemVer from "@std/semver"; import { - DependencyKind, + type DependencyKind, type DependencySpec, stringify, tryParse, diff --git a/deno.json b/deno.json index 602e1f5e..e40908be 100644 --- a/deno.json +++ b/deno.json @@ -56,6 +56,7 @@ "workspace": [ "./cli", "./core", + "./core/deno_lockfile", "./integration", "./lib" ] diff --git a/integration/packages.ts b/integration/packages.ts index ea56818a..6cff33e9 100644 --- a/integration/packages.ts +++ b/integration/packages.ts @@ -1,5 +1,5 @@ import { match, placeholder as _ } from "@core/match"; -import type { DependencySpec } from "@molt/core/types"; +import type { DependencySpec } from "@molt/core/specs"; import * as Spec from "@molt/core/specs"; import type { Repository } from "./repository.ts"; import * as github from "./github.ts"; diff --git a/integration/registries_test.ts b/integration/registries_test.ts index b9ffc370..6465b9aa 100644 --- a/integration/registries_test.ts +++ b/integration/registries_test.ts @@ -1,4 +1,4 @@ -import { parse, tryParse } from "@molt/core/specs"; +import { tryParse } from "@molt/core/specs"; import { get as getUpdate } from "@molt/core/updates"; import { assertEquals, assertFalse } from "@std/assert";