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

chore(build): update copyright headers and pre-commit hook #1736 #1740

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

name: Go tests and checks

on:
pull_request:
paths: 'go/**'
on: pull_request

jobs:
tests:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Python Checks

on:
pull_request:
paths:
- 'py/**'
on: pull_request

jobs:
python-checks:
Expand Down
4 changes: 3 additions & 1 deletion go/plugins/dotprompt/picoschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ import (
)

// TestPicoschema tests the same cases as picoschema_test.ts.
func TestPicoschema(t *testing.T) {
// Temporarily disabled, see https://github.com/firebase/genkit/pull/1741.
func disableTestPicoschema(t *testing.T) {
type test struct {
Description string
YAML string
Want map[string]any
}

// TODO(https://github.com/firebase/genkit/issues/1741): This file has been removed #1651
data, err := os.ReadFile(filepath.FromSlash("../../../js/plugins/dotprompt/tests/picoschema_tests.yaml"))
if err != nil {
t.Fatal(err)
Expand Down
16 changes: 16 additions & 0 deletions go/samples/cloud_run_deploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh
# Copyright 2025 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


# This script deploys a sample to Cloud Run.
# Run it from this directory (go/samples).
Expand Down
16 changes: 16 additions & 0 deletions go/samples/cloud_run_request.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh
# Copyright 2025 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


# This script makes a request to a sample application deployed
# to cloud run.
Expand Down
16 changes: 16 additions & 0 deletions go/samples/pgvector/pgvector.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
-- Copyright 2025 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

-- This SQL enables the vector extension and creates the table and data used
-- in the accompanying sample.

Expand Down
18 changes: 18 additions & 0 deletions js/testapps/next/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/**
* Copyright 2025 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
*/

:root {
--background: #ffffff;
--foreground: #171717;
Expand Down
18 changes: 18 additions & 0 deletions js/testapps/next/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/**
* Copyright 2025 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
*/

import type { Metadata } from 'next';
import { Geist, Geist_Mono } from 'next/font/google';
import './globals.css';
Expand Down
18 changes: 18 additions & 0 deletions js/testapps/next/src/app/page.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/**
* Copyright 2025 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
*/

.title {
display: flex;
gap: 10px;
Expand Down
18 changes: 18 additions & 0 deletions js/testapps/next/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/**
* Copyright 2025 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
*/

'use client';

import { tellJoke } from '@/genkit/joke';
Expand Down
Empty file removed py/.projectile
Empty file.
9 changes: 9 additions & 0 deletions py/bin/check-licenses
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euo pipefail

TOP_DIR=$(git rev-parse --show-toplevel)

pushd "${TOP_DIR}/go"
go-licenses check ./... --disallowed_types=restricted,forbidden,reciprocal,unknown
popd
10 changes: 10 additions & 0 deletions py/bin/cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -x
set -euo pipefail

function genkit::cleanup() {
rm -rf /tmp/e2e* || true && rm -rf /tmp/test-cli* || true
}

genkit::cleanup
11 changes: 11 additions & 0 deletions py/bin/fmt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ fi

TOP_DIR=$(git rev-parse --show-toplevel)

addlicense \
-c "Google LLC" \
-s \
-ignore '**/.github/**/*' \
-ignore '**/.mypy_cache/**/*' \
-ignore '**/bazel-*/**/*' \
-ignore '**/docs/**/*' \
-ignore '**/node_modules/**/*' \
-ignore '**/pnpm-lock.yaml' \
"$TOP_DIR"

# Format all TOML files.
"${TOP_DIR}/py/bin/format_toml_files"
if [[ $? -ne 0 ]]; then
Expand Down
93 changes: 60 additions & 33 deletions py/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ fi

OS_NAME=$(uname)

PYTHON_CLI_TOOLS=(
"httpie" # HTTP client. See: https://httpie.io/
"mypy" # Static type checker. See: https://mypy.readthedocs.io/en/stable/
"ruff" # Fast linter. See: https://github.com/astral-sh/ruff
)

# Updates your shell profile to include a path.
function genkit::update_path() {
local new_path="$1"
Expand Down Expand Up @@ -77,8 +83,19 @@ function genkit::update_path() {
fi
}

function genkit::preconfigure_environment() {
git clean -Xfd
genkit::update_path "$HOME/.cargo/bin"
genkit::update_path "$HOME/.local/bin"
genkit::update_path "$HOME/.local/share/pnpm"
genkit::update_path "$HOME/go/bin"
genkit::update_path "$HOME/google-cloud-sdk/bin"
}

# Install all the required tools common to all audiences.
function genkit::install_prerequisites() {
genkit::preconfigure_environment

if [[ ${OS_NAME} == "Darwin" && -x "$(command -v brew)" ]]; then
# Darwin-based systems.
brew install \
Expand Down Expand Up @@ -109,20 +126,21 @@ function genkit::install_prerequisites() {

# Install rust.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
~/.cargo/bin/rustup update
rustup update

# Install uv for Python versioning, packaging, and workspace management.
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install pnpm for JavaScript package management.
# See: https://github.com/pnpm/pnpm/issues/6217
curl -fsSL https://get.pnpm.io/install.sh | env ENV="$HOME/.bashrc" SHELL="$(which bash)" PNPM_VERSION=10.0.0 bash -

genkit::update_path "$HOME/.cargo/bin"
genkit::update_path "$HOME/.local/share/pnpm"
genkit::update_path "$HOME/go/bin"
curl -fsSL https://get.pnpm.io/install.sh |
env ENV="$HOME/.bashrc" \
SHELL="$(which bash)" \
PNPM_VERSION=10.0.0 \
bash -
}

# Install the Google Cloud SDK.
function genkit::install_google_cloud_sdk() {
# This depends on Python 3.11 and installs it for the user on some systems.
if command -v gcloud &>/dev/null; then
Expand All @@ -135,30 +153,14 @@ function genkit::install_google_cloud_sdk() {
gcloud config set disable_usage_reporting true
}

# Install all the required tools for CI.
function genkit::install_ci_packages() {
genkit::install_prerequisites
genkit::install_python_cli_tools
genkit::install_go_cli_tools
genkit::install_docs_cli_tools
}

# Install all the required tools for engineering.
function genkit::install_eng_packages() {
genkit::install_prerequisites
genkit::install_go_cli_tools
genkit::install_cargo_cli_tools
genkit::install_python_cli_tools
genkit::install_docs_cli_tools
genkit::install_google_cloud_sdk
genkit::install_pnpm_cli_tools
genkit::install_pre_commit_hooks
}

# Install all the required tools that have been written in Go.
function genkit::install_go_cli_tools() {
go install github.com/Gelio/go-global-update@latest
go install github.com/captainhook-go/captainhook/cmd/captainhook@latest
go install github.com/google/addlicense@latest
go install github.com/google/go-licenses@latest
go install github.com/jesseduffield/lazygit@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
}

# Install all the required tools that have been written in Rust. We're assuming
Expand All @@ -178,12 +180,6 @@ function genkit::install_pnpm_cli_tools() {
pnpm add -g genkit-cli
}

PYTHON_CLI_TOOLS=(
"httpie" # HTTP client. See: https://httpie.io/
"mypy" # Static type checker. See: https://mypy.readthedocs.io/en/stable/
"ruff" # Fast linter. See: https://github.com/astral-sh/ruff
)

# Install all the Python-related formatter and static analysis tools.
function genkit::install_python_cli_tools() {
for package in "${PYTHON_CLI_TOOLS[@]}"; do
Expand All @@ -208,7 +204,38 @@ function genkit::install_docs_cli_tools() {

# Install pre-commit hooks.
function genkit::install_pre_commit_hooks() {
~/go/bin/captainhook install -f -c ${TOP_DIR}/py/captainhook.json
captainhook install -f -c "${TOP_DIR}/py/captainhook.json"
}

# Setup genkit.
function genkit::setup_genkit() {
pushd "${TOP_DIR}"
pnpm i
pnpm run setup
popd
}

# Install all the common packages.
function genkit::install_common_packages() {
genkit::install_prerequisites
genkit::install_go_cli_tools
genkit::install_cargo_cli_tools
genkit::install_python_cli_tools
genkit::install_docs_cli_tools
genkit::install_pnpm_cli_tools
}

# Install all the required tools for CI.
function genkit::install_ci_packages() {
genkit::install_common_packages
}

# Install all the required tools for engineering.
function genkit::install_eng_packages() {
genkit::install_common_packages
genkit::install_google_cloud_sdk
genkit::install_pre_commit_hooks
genkit::setup_genkit
}

# Entry point for the setup script.
Expand Down
Loading
Loading