Skip to content

ci(Draft): add turbo and release workflow #184

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release Packages

on:
workflow_dispatch:
inputs:
release_type:
description: 'Type of release'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
dry_run:
description: 'Dry run (no actual release)'
required: true
default: false
type: boolean

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Install dependencies
run: pnpm install

- name: Run format checks
run: pnpm format

- name: Start emulator and run tests
run: |
pnpm emulator &
EMULATOR_PID=$!
sleep 10 # Give emulator time to start
pnpm turbo test
kill $EMULATOR_PID

- name: Build packages
run: pnpm turbo build

# New step to create changesets if they don't exist
- name: Create changeset if needed
run: |
if [ -z "$(ls .changeset/*.md 2>/dev/null)" ]; then
echo "No changesets found. Creating changeset with ${{ inputs.release_type }} bump..."
pnpm changeset add --${{ inputs.release_type }}
else
echo "Existing changesets found. Using those for versioning."
fi

- name: Create Release Pull Request or Publish
if: ${{ !inputs.dry_run }}
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
commit: "chore: version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Dry Run - Show Changes
if: ${{ inputs.dry_run }}
run: |
echo "This is a dry run. The following changes would be made:"
pnpm changeset version --dry-run
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: 10.10.0
run_install: false # We'll do this later

# Setup Node.js with pnpm
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies (pnpm)
run: pnpm install
- name: Check formatting
run: pnpm format:ci
run: pnpm format
- name: Start Firebase Emulator Suite
uses: invertase/[email protected]
with:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ functions/lib/**/*.js
functions/lib/**/*.js.map

# Firebase cache
.firebase/
.firebase/
.turbo/
.next/
.dataconnect/
51 changes: 25 additions & 26 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests.v2",
"request": "launch",
"runtimeExecutable": "yarn",
"args": [
"test",
"--watch-all=false",
"--test-name-pattern",
"${jest.testNamePattern}",
"--test-path-pattern",
"${jest.testFilePattern}"
],
"cwd": "${workspaceFolder}/packages/angular",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
}

]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests.v2",
"request": "launch",
"runtimeExecutable": "yarn",
"args": [
"test",
"--watch-all=false",
"--test-name-pattern",
"${jest.testNamePattern}",
"--test-path-pattern",
"${jest.testFilePattern}"
],
"cwd": "${workspaceFolder}/packages/angular",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"angular.enable-strict-mode-prompt": false
}
}
120 changes: 120 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Contributing to TanStack Query Firebase

Thank you for your interest in contributing to TanStack Query Firebase! This document provides guidelines and instructions for setting up the development environment and contributing to the project.

## Development Setup

### Prerequisites

- Node.js 20 or later
- pnpm 8.15.4 or later
- Firebase CLI (for local development)

### Initial Setup

1. Clone the repository:
```bash
git clone https://github.com/invertase/tanstack-query-firebase.git
cd tanstack-query-firebase
```

2. Install dependencies:
```bash
pnpm install
```

3. Start the Firebase emulators (required for testing):
```bash
pnpm emulator
```

## Development Tools

### Turborepo

This project uses Turborepo for managing the monorepo. Key commands:

- `pnpm turbo build` - Build all packages
- `pnpm turbo test` - Run tests across all packages
- `pnpm turbo dev` - Start development servers

The Turborepo configuration ensures proper dependency management and caching for all tasks.

### Biome

We use Biome for code formatting and linting. Available commands:

- `pnpm format` - Format all files
- `pnpm format:ci` - Check formatting without making changes
- `pnpm format:fix` - Fix formatting issues

### Changesets

We use Changesets for versioning and publishing packages. To create a new changeset:

1. Make your changes
2. Run `pnpm changeset`
3. Follow the prompts to describe your changes
4. Commit the generated changeset file

## Testing

The project uses Vitest for testing. Each package has its own test suite and configuration:

- React package: `cd packages/react && pnpm test`
- Angular package: `cd packages/angular && pnpm test`

Tests are configured to run sequentially (no parallel execution) to prevent race conditions. The test configuration is managed in each package's `vitest.config.ts` file.

To run all tests through Turborepo:
```bash
pnpm test
```

Note: Make sure the Firebase emulator is running before executing tests.

## GitHub Workflows

The project has two main workflows:

1. **Tests** (`tests.yaml`):
- Runs on push to main and pull requests
- Checks formatting
- Runs tests for changed packages
- Uses Firebase emulators for testing
- Respects package-specific test configurations

2. **Release** (`release.yml`):
- Manual trigger with release type selection
- Creates or updates changesets
- Publishes packages to npm
- Supports dry runs

## Making Changes

1. Create a new branch for your changes
2. Make your changes
3. Add tests if applicable
4. Run formatting: `pnpm format`
5. Run tests: `pnpm test`
6. Create a changeset if needed: `pnpm changeset`
7. Submit a pull request

## Code Style

- Use Biome for formatting and linting
- Follow the existing code style
- Write tests for new features
- Update documentation as needed

## Documentation

Documentation is managed in the `docs` directory and uses docs.page for hosting. When making changes:

1. Update relevant documentation
2. Test documentation changes locally
3. Ensure all links are working

## Questions?

If you have any questions about contributing, please open an issue or reach out to the maintainers.
Loading