Skip to content

Commit

Permalink
chore(project): bump and improve lib (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh authored Apr 19, 2024
1 parent 26859a3 commit ba59fdb
Show file tree
Hide file tree
Showing 26 changed files with 612 additions and 482 deletions.
9 changes: 9 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"dependencyDashboardApproval": false
},
"rangeStrategy": "bump",
"regexManagers": [
{
"fileMatch": [".+Dockerfile$"],
"matchStrings": [
"datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sENV .*?_VERSION=(?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
}
],
"packageRules": [
{
"matchPackageNames": ["node", "typescript", "@types/node"],
Expand Down
3 changes: 3 additions & 0 deletions .idea/dictionaries/fuxing.xml

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

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import waitForExpect from 'wait-for-expect';

import definition from './bitcoind.json';
Expand All @@ -15,7 +15,7 @@ afterAll(async () => {
});

describe('bitcoind', () => {
let bitcoind: KarfiaTestContainer;
let bitcoind: KarfiaContainer;

beforeAll(() => {
bitcoind = testcontainers.getContainer('bitcoind');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './bitcoind.json';

Expand All @@ -14,7 +14,7 @@ afterAll(async () => {
});

describe('bitcoind', () => {
let bitcoind: KarfiaTestContainer;
let bitcoind: KarfiaContainer;

beforeAll(() => {
bitcoind = testcontainers.getContainer('bitcoind');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"encoding": "hex"
},
"DEFID_URL": {
"type": "Expansion",
"type": "Value",
"value": "http://${RPC_USER}:${RPC_PASSWORD}@defid:8554"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './defid-jellyfish.json';

Expand All @@ -14,8 +14,8 @@ afterAll(async () => {
});

describe('defid + whale', () => {
let defid: KarfiaTestContainer;
let whale: KarfiaTestContainer;
let defid: KarfiaContainer;
let whale: KarfiaContainer;

beforeAll(() => {
defid = testcontainers.getContainer('defid');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './defid.json';

Expand All @@ -14,7 +14,7 @@ afterAll(async () => {
});

describe('defid', () => {
let defid: KarfiaTestContainer;
let defid: KarfiaContainer;

beforeAll(() => {
defid = testcontainers.getContainer('defid');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './defid-jellyfish.json';

Expand All @@ -14,8 +14,8 @@ afterAll(async () => {
});

describe('defid + whale', () => {
let defid: KarfiaTestContainer;
let whale: KarfiaTestContainer;
let defid: KarfiaContainer;
let whale: KarfiaContainer;

beforeAll(() => {
defid = testcontainers.getContainer('defid');
Expand Down
4 changes: 2 additions & 2 deletions definitions/eip155-1337/ganache.unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './ganache.json';

Expand All @@ -15,7 +15,7 @@ describe('testcontainers', () => {
});

describe('ganache', () => {
let ganache: KarfiaTestContainer;
let ganache: KarfiaContainer;

beforeAll(() => {
ganache = testcontainers.getContainer('ganache');
Expand Down
4 changes: 2 additions & 2 deletions definitions/eip155-31337/hardhat.unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './hardhat.json';

Expand All @@ -15,7 +15,7 @@ describe('testcontainers', () => {
});

describe('hardhat', () => {
let hardhat: KarfiaTestContainer;
let hardhat: KarfiaContainer;

beforeAll(() => {
hardhat = testcontainers.getContainer('hardhat');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './solana-test-validator.json';

Expand All @@ -15,7 +15,7 @@ describe('testcontainers', () => {
});

describe('solana-test-validator', () => {
let validator: KarfiaTestContainer;
let validator: KarfiaContainer;

beforeAll(() => {
validator = testcontainers.getContainer('solana-test-validator');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@swc/core": "^1.4.13",
"@swc/core": "^1.4.16",
"@swc/jest": "^0.2.36",
"@types/node": "^20.11.30",
"@workspace/eslint-config": "workspace:*",
Expand Down
19 changes: 12 additions & 7 deletions packages/karfia-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ RUN corepack enable pnpm

ENV PNPM_HOME="/root/.local/share/pnpm/global" \
PATH="$PATH:/root/.local/share/pnpm/global"
RUN pnpm config set store-dir /root/.local/share/pnpm/global/store/v3

# renovate: datasource=npm depName=turbo
ENV TURBO_VERSION=1.12.5
RUN pnpm add -g turbo@${TURBO_VERSION}
COPY package.json package.json
RUN pnpm -v
ENV COREPACK_ENABLE_NETWORK=0

RUN pnpm config set store-dir /root/.local/share/pnpm/global/store/v3

# Isolate workspace by pruning non-related services.
FROM base AS pruner

# renovate: datasource=npm depName=turbo
ENV TURBO_VERSION=1.13.2
RUN pnpm add -g turbo@${TURBO_VERSION}

COPY . .

RUN pnpm turbo prune --scope=karfia-agent --docker
Expand All @@ -30,15 +35,15 @@ COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml

# Mount cache to copy from content-addressable store; ignore cross-device link errors due to different mount points.
RUN --mount=type=cache,target=/root/.local/share/pnpm/global/store/v3\
pnpm install --frozen-lockfile\
| grep -v "cross-device link not permitted\|Falling back to copying packages from store"
pnpm install --frozen-lockfile

COPY --from=pruner /app/out/full/ .

# To relink dependencies with ./bin links
RUN pnpm install --frozen-lockfile --offline

RUN pnpm turbo run build --filter=karfia-agent
RUN --mount=type=cache,id=turborepo-cache,target=node_modules/.cache/turbo\
pnpm turbo run build --filter=karfia-agent

# Run agent
FROM node:20-alpine AS runner
Expand Down
2 changes: 1 addition & 1 deletion packages/karfia-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"ajv-formats": "^3.0.1",
"karfia-definition": "workspace:^",
"trpc-openapi": "^1.2.0",
"zod": "^3.22.4"
"zod": "^3.22.5"
},
"devDependencies": {
"@workspace/jest-preset": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/karfia-agent/routers/probes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
ContainerEndpointHttpAuthorization,
ContainerEndpointHttpJsonRpc,
ContainerEndpointHttpRest,
EnvironmentReference,
KarfiaDefinition,
KarfiaEnvironmentReference,
} from 'karfia-definition';
import { z } from 'zod';

Expand Down Expand Up @@ -236,7 +236,7 @@ function getHttpAuthorizationHeaders(auth: ContainerEndpointHttpAuthorization):
*
* If the value is not a reference, it is returned as is.
*/
function resolveValue(value: string | KarfiaEnvironmentReference): string {
function resolveValue(value: string | EnvironmentReference): string {
if (typeof value === 'string') {
return value;
}
Expand Down
24 changes: 12 additions & 12 deletions packages/karfia-definition/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
"maxLength": 128
},
"environment": {
"$ref": "#/definitions/KarfiaEnvironment"
"$ref": "#/definitions/Environment"
},
"containers": {
"type": "object",
"minProperties": 1,
"maxProperties": 6,
"patternProperties": {
"^(?!karfia)[a-z0-9][a-z0-9-]{0,28}[a-z0-9]$": {
"$ref": "#/definitions/KarfiaContainer"
"$ref": "#/definitions/Container"
}
},
"additionalProperties": false
Expand All @@ -42,17 +42,17 @@
"required": ["id", "caip2", "name", "containers"],
"additionalProperties": false,
"definitions": {
"KarfiaEnvironment": {
"Environment": {
"type": "object",
"maxProperties": 30,
"patternProperties": {
"^[a-zA-Z_]+[a-zA-Z0-9_]*$": {
"$ref": "#/definitions/KarfiaEnvironmentFactory"
"$ref": "#/definitions/EnvironmentFactory"
}
},
"additionalProperties": false
},
"KarfiaEnvironmentFactory": {
"EnvironmentFactory": {
"oneOf": [
{
"type": "object",
Expand All @@ -77,7 +77,7 @@
"type": "object",
"properties": {
"type": {
"const": "Expansion"
"const": "Value"
},
"value": {
"type": "string"
Expand All @@ -88,7 +88,7 @@
}
]
},
"KarfiaEnvironmentReference": {
"EnvironmentReference": {
"type": "object",
"properties": {
"key": {
Expand All @@ -98,7 +98,7 @@
"required": ["key"],
"additionalProperties": false
},
"KarfiaContainer": {
"Container": {
"type": "object",
"properties": {
"image": {
Expand Down Expand Up @@ -145,7 +145,7 @@
"maxProperties": 30,
"patternProperties": {
"^[a-zA-Z_]+[a-zA-Z0-9_]*$": {
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/KarfiaEnvironmentReference" }]
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/EnvironmentReference" }]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -360,10 +360,10 @@
"const": "HttpBasic"
},
"username": {
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/KarfiaEnvironmentReference" }]
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/EnvironmentReference" }]
},
"password": {
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/KarfiaEnvironmentReference" }]
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/EnvironmentReference" }]
}
},
"required": ["type", "username", "password"],
Expand All @@ -376,7 +376,7 @@
"const": "HttpBearer"
},
"token": {
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/KarfiaEnvironmentReference" }]
"oneOf": [{ "type": "string" }, { "$ref": "#/definitions/EnvironmentReference" }]
}
},
"required": ["type", "token"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
- '0:1194'
environment:
KARFIA_DEFINITION_JSON: >-
{"id":"eip155:1337/ganache:7.9.1","caip2":"eip155:1337","name":"Ganache","environment":{"RPC_USER":{"type":"RandomBytes","length":16,"encoding":"hex"},"RPC_PASSWORD":{"type":"RandomBytes","length":16,"encoding":"hex"},"URL":{"type":"Expansion","value":"http://$\${RPC_USER}:$\${RPC_PASSWORD}@ganache:8554"}},"containers":{"ganache":{"image":"docker.io/trufflesuite/ganache@sha256:c62c58290c28e24b427f74c6f597ff696257bd2d8e8d517ce4cf46b29b304a3f","source":"https://github.com/trufflesuite/ganache","environment":{"RPCUSER":{"key":"RPC_USER"},"RPCPASSWORD":{"key":"RPC_PASSWORD"}},"resources":{"cpu":0.25,"memory":256},"endpoints":{"p2p":{"port":8555},"rpc":{"port":8545,"protocol":"HTTP
{"id":"eip155:1337/ganache:7.9.1","caip2":"eip155:1337","name":"Ganache","environment":{"RPC_USER":{"type":"RandomBytes","length":16,"encoding":"hex"},"RPC_PASSWORD":{"type":"RandomBytes","length":16,"encoding":"hex"},"URL":{"type":"Value","value":"http://$\${RPC_USER}:$\${RPC_PASSWORD}@ganache:8554"}},"containers":{"ganache":{"image":"docker.io/trufflesuite/ganache@sha256:c62c58290c28e24b427f74c6f597ff696257bd2d8e8d517ce4cf46b29b304a3f","source":"https://github.com/trufflesuite/ganache","environment":{"RPCUSER":{"key":"RPC_USER"},"RPCPASSWORD":{"key":"RPC_PASSWORD"}},"resources":{"cpu":0.25,"memory":256},"endpoints":{"p2p":{"port":8555},"rpc":{"port":8545,"protocol":"HTTP
JSON-RPC
2.0","authorization":{"type":"HttpBasic","username":{"key":"RPC_USER"},"password":{"key":"RPC_PASSWORD"}},"probes":{"readiness":{"params":[],"method":"eth_blockNumber","match":{"result":{"type":"string"}}}}}},"volumes":{"persistent":{"paths":["/.ganache"],"size":{"initial":"1G","from":"2024-01-01","growth":"1G","rate":"yearly"}}}}}}
KARFIA_DEPLOYMENT_ID: \${KARFIA_DEPLOYMENT_ID}
Expand Down
Loading

0 comments on commit ba59fdb

Please sign in to comment.