From 76826b5e053c0f4465a2e5a15ae71e5bc06f8c31 Mon Sep 17 00:00:00 2001 From: hasundue Date: Sun, 28 Jul 2024 13:11:38 +0900 Subject: [PATCH] chore: setup workflows --- .github/workflows/ci.yml | 86 +++++++++++++++++++++++++++++----- core/bumps.ts | 2 +- core/deno_lockfile | 2 +- core/locks.ts | 2 +- core/locks_test.ts | 2 +- core/specs.ts | 2 +- core/types.ts | 2 +- core/updates.ts | 2 +- deno.json | 5 +- integration/packages.ts | 2 +- integration/registries_test.ts | 2 +- 11 files changed, 83 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c54e72de..0a0a524d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,19 +11,79 @@ on: permissions: contents: read +defaults: + run: + shell: bash + jobs: 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 + + strategy: + fail-fast: false + matrix: + 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 actions/cache for Deno + uses: actions/cache@v4 + with: + path: | + ~/.cache/deno + ~/Library/Caches/deno + ~/AppData/Local/deno + key: ${{ matrix.os }}-deno-${{ hashFiles('./deno.lock') }} + restore-keys: ${{ matrix.os }}-deno + + - name: Setup actions/cache for Cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo + ./core/deno_lockfile/target + key: ${{ matrix.os }}-cargo-${{ hashFiles('./**/Cargo.lock') }} + restore-keys: ${{ matrix.os }}-cargo + + - name: Build core/deno_lockfile + run: | + cd core/deno_lockfile + deno task build + + - name: Check format + if: matrix.os == 'ubuntu-latest' + run: deno fmt --check + + - name: Cache dependencies + run: deno task cache + + - name: Check lint + if: matrix.os == 'ubuntu-latest' + run: deno lint + + - name: Run tests + run: deno test -A --unstable-kv --parallel --shuffle --coverage=./coverage_profile + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + + - 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/deno_lockfile b/core/deno_lockfile index 50bba8f0..447b2416 160000 --- a/core/deno_lockfile +++ b/core/deno_lockfile @@ -1 +1 @@ -Subproject commit 50bba8f00cdc4c1f21a082447d92cd3a2299fbce +Subproject commit 447b241623cc660b1e9d7c4c6c6b6744d94d0ec6 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..24b61af9 100644 --- a/deno.json +++ b/deno.json @@ -5,10 +5,7 @@ "pre-commit": "deno fmt && deno lint && deno task -q check && deno task -q test:unit", "run": "deno run -A --env --unstable-kv ./cli/main.ts", "test": "deno test -A --unstable-kv --no-check", - "test:integration": "deno task test ./integration ./cli", - "test:unit": "deno task test ./lib ./core", - "update": "deno task -q run", - "update:commit": "deno task -q update --commit --prefix 'chore:' --pre-commit=check,test:unit" + "update:commit": "deno task -q run --commit --prefix 'chore:' --pre-commit=check,test:unit" }, "imports": { "@chiezo/amber": "jsr:@chiezo/amber@^0.0.8", 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";