Skip to content
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
56 changes: 56 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Pull Request Checks

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
paths-ignore:
- 'docs/**'
- '*.md'
- 'README.md'

jobs:
test_and_check_version:
name: Test and Check Version
runs-on: ubuntu-latest

steps:
- name: Check out base branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
path: 'main'

- name: Check out PR branch
uses: actions/checkout@v4
with:
path: 'pr'

- name: Check for version increment
id: check_version
run: |
# Install jq, a tool for parsing JSON
sudo apt-get update && sudo apt-get install -y jq

# Extract version from the main branch's package.json
main_version=$(jq -r .version main/package.json)
echo "Version on main: $main_version"

# Extract version from the PR branch's package.json
pr_version=$(jq -r .version pr/package.json)
echo "Version on PR branch: $pr_version"

if [ "$main_version" == "$pr_version" ]; then
echo "Version has not been incremented from main."
exit 1
fi

# The `sort -V` command handles version numbers correctly.
# It understands that 0.1.10 is greater than 0.1.9.
if [ "$(printf '%s\n' "$main_version" "$pr_version" | sort -V | head -n1)" != "$main_version" ]; then
echo "PR version ($pr_version) is not greater than main version ($main_version)."
exit 1
fi

echo "Version check passed!"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
"dev": "tsx watch src/index.ts",
"format": "biome format --write"
},
"version": "0.0.6"
"version": "0.0.7"
}
16 changes: 11 additions & 5 deletions src/overmind-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type OvermindClientConfig = {
appName?: string;
};

const LOCAL_API_KEY_PREFIX = "ovr_core_";
const LOCAL_BASE_URL = "http://localhost:8000";
const DEFAULT_BASE_URL = "https://api.overmindlab.ai";

export class OvermindClient {
public readonly appName: string;
private version: string = version;
Expand All @@ -36,14 +40,16 @@ export class OvermindClient {
public experimentSlug?: string;

constructor(config: OvermindClientConfig) {
// biome-ignore lint/style/noNonNullAssertion: must always set api key
this.apiKey = config.apiKey || process.env.OVERMIND_API_KEY!;

this.baseUrl =
config.baseUrl ||
process.env.OVERMIND_API_URL ||
process.env.OVERMIND_TRACES_URL ||
"https://api.overmindlab.ai";

// biome-ignore lint/style/noNonNullAssertion: must always set api key
this.apiKey = config.apiKey || process.env.OVERMIND_API_KEY!;
this.apiKey.startsWith(LOCAL_API_KEY_PREFIX)
? LOCAL_BASE_URL
: DEFAULT_BASE_URL;

this.appName = config.appName || "overmind-js";
if (!this.apiKey) {
Expand Down Expand Up @@ -73,7 +79,7 @@ export class OvermindClient {
const traceExporter = this.baseUrl
? new OTLPTraceExporter({
headers: { "X-API-TOKEN": this.apiKey },
url: `${this.baseUrl}/api/v1/traces/create`,
url: `${this.baseUrl}/api/v1/traces`,
})
: new ConsoleSpanExporter();

Expand Down