Skip to content

ci: update ci for py and ts, ts version bump #127

ci: update ci for py and ts, ts version bump

ci: update ci for py and ts, ts version bump #127

Workflow file for this run

name: Dockerized Go & TS Build
on:
push:
paths:
- 'proto/**'
- 'package.json'
- 'tsconfig.json'
- 'Makefile'
- 'scripts/generate_pb.sh'
- 'scripts/ts_imports.sh'
- '.github/workflows/build.yml'
- 'README.md'
pull_request:
paths:
- 'proto/**'
- 'package.json'
- 'tsconfig.json'
- 'Makefile'
- 'scripts/generate_pb.sh'
- 'scripts/ts_imports.sh'
- '.github/workflows/build.yml'
jobs:
lint-proto:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache buf modules
uses: actions/cache@v4
with:
path: ~/.cache/buf
key: ${{ runner.os }}-buf-${{ hashFiles('buf.yaml', 'buf.lock') }}
restore-keys: |
${{ runner.os }}-buf-
- name: Update buf module dependencies
run: buf dep update
- name: Lint proto files
run: buf lint
build-and-test:
runs-on: ubuntu-latest
needs: lint-proto
steps:
- uses: actions/checkout@v4
# Cache Go modules early
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24.1'
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('gen/go/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache npm modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Install npm deps early for protoc plugin availability
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24.2.0'
- name: Install npm dependencies
run: npm ci
# --- GHCR Login ---
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Setup buildx before building
- name: Set up Docker Buildx builder
run: |
docker buildx create --use --name mybuilder --driver docker-container || true
docker buildx inspect --bootstrap
- name: Compute lowercase image tag
id: lower-tag
run: |
echo "repo_lower=$(echo 'ghcr.io/${{ github.repository_owner }}/protos-gen' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.lower-tag.outputs.repo_lower }}:latest
cache-from: type=registry,ref=${{ steps.lower-tag.outputs.repo_lower }}:cache
cache-to: type=registry,ref=${{ steps.lower-tag.outputs.repo_lower }}:cache,mode=max
- name: Generate Go protobuf files (inside Docker)
run: |
docker run --rm \
-v ${{ github.workspace }}:/app \
-w /app \
${{ steps.lower-tag.outputs.repo_lower }}:latest \
sh -c "make gen-go"
- name: Generate TypeScript protobuf files (inside Docker)
run: |
docker run --rm \
-v ${{ github.workspace }}:/app \
-w /app \
${{ steps.lower-tag.outputs.repo_lower }}:latest \
sh -c "npm run build"
- name: Generate Python protobuf files (inside Docker)
run: |
docker run --rm \
-v ${{ github.workspace }}:/app \
-w /app \
${{ steps.lower-tag.outputs.repo_lower }}:latest \
sh -c "make gen-py && make update-py-package"
- name: Run tests inside Docker
run: |
docker run --rm \
-v ${{ github.workspace }}:/app \
-w /app \
${{ steps.lower-tag.outputs.repo_lower }}:latest \
sh -c "make test"