Skip to content
Draft
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
115 changes: 115 additions & 0 deletions .github/actions/prepare-workflow/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: 'Prepare Workflow'
description: 'Setup environment, cache and install dependencies, and optionally download build artifacts'

inputs:
e2e:
description: 'Whether to prepare for e2e tests'
required: false
default: 'false'

runs:
using: 'composite'
steps:
- name: Setup environment
shell: bash
run: |
sudo chown -R testbot .
sudo mkdir -p /home/testbot/.cache/buf
sudo chown -R testbot:testbot /home/testbot/.cache
sudo mkdir -p /github/home/.npm
sudo chown -R testbot:testbot /github/home/.npm
sudo mkdir -p /github/home/.cache
sudo chown -R testbot:testbot /github/home/.cache

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'

- name: Restore node_modules cache
uses: actions/cache/restore@v4
id: cache-node-modules
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
node-modules-${{ runner.os }}-

- name: Install npm dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
shell: bash
run: sudo -E -u testbot bash -lc 'npm ci --audit=false'

- name: Save node_modules cache
if: steps.cache-node-modules.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Prebuild
shell: bash
run: sudo -E -u testbot bash -lc 'npm run prebuild'

- name: Download build artifacts
if: inputs.e2e == 'true'
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: .

- name: Restore build-buf cache
if: inputs.e2e != 'true'
uses: actions/cache/restore@v4
id: cache-build-buf
with:
path: src/gen
key: build-buf-${{ runner.os }}-${{ hashFiles('api_version.lock', 'buf.gen.yaml') }}
restore-keys: |
build-buf-${{ runner.os }}-${{ hashFiles('api_version.lock') }}-
build-buf-${{ runner.os }}-

- name: Generate build-buf if not cached
if: inputs.e2e != 'true' && steps.cache-build-buf.outputs.cache-hit != 'true'
shell: bash
run: sudo -E -u testbot bash -lc 'make build-buf-ci'

- name: Save build-buf cache
if: inputs.e2e != 'true' && steps.cache-build-buf.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: src/gen
key: build-buf-${{ runner.os }}-${{ hashFiles('api_version.lock', 'buf.gen.yaml') }}

- name: Read Playwright version from package.json
if: inputs.e2e == 'true'
id: playwright-version
shell: bash
run: |
PLAYWRIGHT_VERSION=$(jq -r '.devDependencies."@playwright/test"' package.json)
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
echo "Using Playwright version: $PLAYWRIGHT_VERSION"

- name: Restore Playwright browsers cache
if: inputs.e2e == 'true'
uses: actions/cache/restore@v4
id: cache-playwright
with:
path: /home/testbot/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
restore-keys: |
playwright-${{ runner.os }}-

- name: Install Playwright browsers and dependencies
if: inputs.e2e == 'true'
shell: bash
run: |
sudo -E -u testbot bash -lc 'npx playwright install --with-deps'

- name: Save Playwright browsers cache
if: inputs.e2e == 'true' && steps.cache-playwright.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: /home/testbot/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
73 changes: 71 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,80 @@ on:
- main

jobs:
build:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main

- name: Build
run: sudo -u testbot bash -lc 'make build-ci'

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist
src/gen
retention-days: 1

lint:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main

- name: Lint
run: sudo -u testbot bash -lc 'make lint-ci'

test:
uses: viamrobotics/viam-typescript-sdk/.github/workflows/test.yml@main
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main

- name: Test
run: sudo -u testbot bash -lc 'make test-ci'

test-e2e:
if: github.repository_owner == 'viamrobotics'
needs: build
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main
with:
e2e: 'true'

- name: Test E2E
run: sudo -u testbot bash -lc 'make test-e2e-ci'

publish_next:
needs: test
needs: [build, lint, test, test-e2e]
uses: viamrobotics/viam-typescript-sdk/.github/workflows/publish_next.yml@main
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
echo "tag=latest" >> $GITHUB_OUTPUT
fi

- uses: actions/setup-node@v4
- uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
Expand Down
71 changes: 70 additions & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,77 @@ name: Pull Request Update
on: [workflow_dispatch, pull_request]

jobs:
build:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main

- name: Build
run: sudo -u testbot bash -lc 'make build-ci'

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist
src/gen
retention-days: 1

lint:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main

- name: Lint
run: sudo -u testbot bash -lc 'make lint-ci'

test:
uses: viamrobotics/viam-typescript-sdk/.github/workflows/test.yml@main
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main

- name: Test
run: sudo -u testbot bash -lc 'make test-ci'

test-e2e:
if: github.repository_owner == 'viamrobotics'
needs: build
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/rdk-devenv:amd64

steps:
- uses: actions/checkout@v4

- name: Prepare workflow
uses: viamrobotics/viam-typescript-sdk/.github/actions/prepare-workflow@main
with:
e2e: 'true'

- name: Test E2E
run: sudo -u testbot bash -lc 'make test-e2e-ci'

license_check:
uses: viamrobotics/viam-typescript-sdk/.github/workflows/license_finder.yml@main
23 changes: 0 additions & 23 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
docs
src/gen
src/api-version.ts
Loading
Loading