Skip to content

Commit

Permalink
chore(ci): use node versions 20 through 23 for GitHub actions
Browse files Browse the repository at this point in the history
ISSUE: firebase/genkit#1995

CHANGELOG:
- [x] Update biome configuration to respect editorconfig and ignore some
  more directories.
- [x] Fix some lint in TypeScript files.
- [x] Update .gitignore to exclude .cache dir.
- [x] Update workflows to use node version 20-23.
- [x] Update `bin/setup` to use node version 22 as default on eng
  workstations.
- [x] Adds additional script commands to run lint and format checks.
- [x] Clean up copyright headers in GitHub action configuration.
  • Loading branch information
yesudeep committed Feb 15, 2025
1 parent 4ba47de commit 8087d3c
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 89 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-License-Identifier: Apache-2.0

name: Deploy to GitHub Pages

Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-License-Identifier: Apache-2.0

name: Release JS

Expand All @@ -25,7 +14,7 @@ on:
options:
- next
- latest

jobs:
build:
name: Run build tasks
Expand Down
21 changes: 7 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-License-Identifier: Apache-2.0

name: "JS: Run Tests"

Expand All @@ -26,14 +15,18 @@ on:

jobs:
test:
name: Run tests (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['20', '21', '22', '23']
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
- name: Setup Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/js/dist
node_modules
.DS_Store
.cache
.firebaserc
.idea
/js/dist
/third_party/docsite/src/content/refdocs
bazel-*
node_modules
4 changes: 2 additions & 2 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
TOP_DIR=$(git rev-parse --show-toplevel)

PNPM_VERSION="10.2.0"
NODE_VERSION="23"
NODE_VERSION="22" # See: https://github.com/firebase/genkit/issues/1995
NVM_VERSION="0.40.1"

AUDIENCE="eng"
Expand Down Expand Up @@ -204,6 +204,7 @@ function dotpromptz::install_go_cli_tools_eng() {
function dotpromptz::install_cargo_cli_tools_eng() {
cargo install --locked \
convco \
pylyzer \
rust-parallel \
taplo-cli
}
Expand Down Expand Up @@ -244,7 +245,6 @@ function dotpromptz::configure_commit_template() {
function dotpromptz::install_pre_commit_hooks() {
dotpromptz::configure_commit_template
captainhook install -f -c "${TOP_DIR}/captainhook.json"
#git config --local include.path ../.gitconfig
}

# Install all the common packages.
Expand Down
10 changes: 5 additions & 5 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"organizeImports": {
"enabled": true
},
Expand All @@ -12,6 +12,7 @@
"files": {
"ignoreUnknown": true,
"ignore": [
"**/.cache/**",
"**/.dist/**",
"**/.eggs/**",
"**/.idea/**",
Expand All @@ -31,15 +32,14 @@
".nx/**",
".trunk/**",
"bazel-*/**",
"go/**",
"node_modules/**",
"python/**",
"third_party/**"
]
},
"formatter": {
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80
"useEditorconfig": true
},
"vcs": {
"clientKind": "git",
Expand Down
2 changes: 1 addition & 1 deletion js/src/adapters/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { RenderedPrompt, Part, Message } from '../types.js';
import type { Message, Part, RenderedPrompt } from '../types.js';

export interface GeminiContent {
role: 'user' | 'model';
Expand Down
2 changes: 1 addition & 1 deletion js/src/adapters/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { RenderedPrompt, Part, Message } from '../types.js';
import type { Message, Part, RenderedPrompt } from '../types.js';

export interface OpenAIMessage {
role: 'system' | 'user' | 'assistant' | 'tool';
Expand Down
30 changes: 15 additions & 15 deletions js/src/dotprompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@

import * as Handlebars from 'handlebars';
import * as helpers from './helpers';
import { parseDocument, toMessages } from './parse';
import { picoschema } from './picoschema';
import {
PromptFunction,
DataArgument,
JSONSchema,
PromptMetadata,
RenderedPrompt,
SchemaResolver,
ToolDefinition,
ToolResolver,
ParsedPrompt,
PromptStore,
type DataArgument,
type JSONSchema,
type ParsedPrompt,
type PromptFunction,
type PromptMetadata,
PromptRefFunction,
type PromptStore,
type RenderedPrompt,
type SchemaResolver,
type ToolDefinition,
type ToolResolver,
} from './types';
import { parseDocument, toMessages } from './parse';
import { picoschema } from './picoschema';
import { removeUndefinedFields } from './util';

/** Function to resolve partial names to their content */
export interface PartialResolver {
(partialName: string): string | null | Promise<string | null>;
}
export type PartialResolver = (
partialName: string
) => string | null | Promise<string | null>;

export interface DotpromptOptions {
/** A default model to use if none is supplied. */
Expand Down
2 changes: 1 addition & 1 deletion js/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { parse } from 'yaml';
import {
import type {
DataArgument,
MediaPart,
Message,
Expand Down
2 changes: 1 addition & 1 deletion js/src/picoschema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { JSONSchema, SchemaResolver } from './types.js';
import type { JSONSchema, SchemaResolver } from './types.js';

const JSON_SCHEMA_SCALAR_TYPES = [
'string',
Expand Down
8 changes: 4 additions & 4 deletions js/src/stores/dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

import { createHash } from 'crypto';
import { promises as fs } from 'fs';
import path from 'path';
import { createHash } from 'crypto';
import {
import type {
PartialRef,
PromptData,
PromptRef,
PromptStoreWritable,
PartialRef,
} from '../types';

interface DirStoreOptions {
Expand Down Expand Up @@ -60,7 +60,7 @@ export class DirStore implements PromptStoreWritable {
}

private async scanDirectory(
dir: string = '',
dir = '',
results: string[] = []
): Promise<string[]> {
const fullPath = path.join(this.directory, dir);
Expand Down
12 changes: 6 additions & 6 deletions js/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,18 @@ export type JSONSchema = any;
* an underlying JSON schema, utilized for shorthand to a schema library
* provided by an external tool.
**/
export interface SchemaResolver {
(schemaName: string): JSONSchema | null | Promise<JSONSchema | null>;
}
export type SchemaResolver = (
schemaName: string
) => JSONSchema | null | Promise<JSONSchema | null>;

/**
* SchemaResolver is a function that can resolve a provided tool name to
* an underlying ToolDefinition, utilized for shorthand to a tool registry
* provided by an external library.
**/
export interface ToolResolver {
(toolName: string): ToolDefinition | null | Promise<ToolDefinition | null>;
}
export type ToolResolver = (
toolName: string
) => ToolDefinition | null | Promise<ToolDefinition | null>;

/**
* RenderedPrompt is the final result of rendering a Dotprompt template.
Expand Down
8 changes: 4 additions & 4 deletions js/test/spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import { describe, it, expect, suite } from 'vitest';
import { readdirSync, readFileSync } from 'node:fs';
import { parse } from 'yaml';
import { readFileSync, readdirSync } from 'node:fs';
import { join, relative } from 'node:path';
import { describe, expect, it, suite } from 'vitest';
import { parse } from 'yaml';
import { Dotprompt } from '../src/dotprompt';
import { DataArgument, JSONSchema, ToolDefinition } from '../src/types';
import type { DataArgument, JSONSchema, ToolDefinition } from '../src/types';

const specDir = join('..', 'spec');
const files = readdirSync(specDir, { recursive: true, withFileTypes: true });
Expand Down
11 changes: 4 additions & 7 deletions js/test/stores/dir.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { createHash } from 'crypto';
import { promises as fs } from 'fs';
import path from 'path';
import { createHash } from 'crypto';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { DirStore } from '../../src/stores/dir';
import { PromptData } from '../../src/types';
import type { PromptData } from '../../src/types';

describe('DirStore', () => {
const tempDir = path.join(process.cwd(), 'test-prompts');
Expand All @@ -38,10 +38,7 @@ describe('DirStore', () => {
return createHash('sha1').update(content).digest('hex').substring(0, 8);
}

async function createPromptFile(
name: string,
content: string = 'test source'
) {
async function createPromptFile(name: string, content = 'test source') {
const filePath = path.join(tempDir, name);
await fs.mkdir(path.dirname(filePath), { recursive: true });
await fs.writeFile(filePath, content);
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"packageManager": "[email protected]+sha256.ccce81bf7498c5f0f80e31749c1f8f03baba99d168f64590fc7e13fad3ea1938",
"scripts": {
"format": "pnpm dlx @biomejs/biome format --write ."
"format": "pnpm dlx @biomejs/biome check --formatter-enabled=true --linter-enabled=false --organize-imports-enabled=true --fix . && bin/add_license",
"format:check": "pnpm dlx @biomejs/biome ci --linter-enabled=false --formatter-enabled=true --organize-imports-enabled=false . && bin/check_license",
"lint": "pnpm dlx @biomejs/biome lint --fix . && bin/add_license"
}
}

0 comments on commit 8087d3c

Please sign in to comment.