Skip to content

Commit 14e600c

Browse files
author
Christoph Schmatzler
authored
refactor(server): migrate build_runs to Clickhouse (tuist#9355)
1 parent 0dc00df commit 14e600c

58 files changed

Lines changed: 1829 additions & 1414 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/server.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ jobs:
247247
if: github.event.pull_request.draft == false || github.event_name != 'pull_request'
248248
services:
249249
postgres:
250-
image: timescale/timescaledb-ha:pg16
250+
image: postgres:16
251251
env:
252252
POSTGRES_USER: postgres
253253
POSTGRES_PASSWORD: postgres
@@ -478,7 +478,7 @@ jobs:
478478
# timeout-minutes: 15
479479
# services:
480480
# postgres:
481-
# image: timescale/timescaledb-ha:pg16
481+
# image: postgres:16
482482
# env:
483483
# POSTGRES_USER: postgres
484484
# POSTGRES_PASSWORD: postgres
@@ -534,7 +534,7 @@ jobs:
534534
if: github.event.pull_request.draft == false || github.event_name != 'pull_request'
535535
services:
536536
postgres:
537-
image: timescale/timescaledb-ha:pg16
537+
image: postgres:16
538538
env:
539539
POSTGRES_USER: postgres
540540
POSTGRES_PASSWORD: postgres
@@ -594,20 +594,9 @@ jobs:
594594
- uses: actions/checkout@v4
595595
- name: Select Xcode
596596
run: sudo xcode-select -switch /Applications/Xcode_$(cat $GITHUB_WORKSPACE/.xcode-version).app
597-
- name: Set up PostgreSQL with TimescaleDB
597+
- name: Set up PostgreSQL
598598
run: |
599-
brew tap timescale/tap
600-
brew install timescaledb
601-
# Run timescaledb_move.sh to install extension files to PostgreSQL
602-
/opt/homebrew/bin/timescaledb_move.sh || true
603-
# Stop PostgreSQL before configuring
604-
if brew services list | grep -q "^postgresql@17\\s\\+started"; then
605-
brew services stop postgresql@17
606-
sleep 2
607-
fi
608-
# Configure TimescaleDB - specify the correct PostgreSQL 17 config path
609-
timescaledb-tune --quiet --yes --pg-config /opt/homebrew/opt/postgresql@17/bin/pg_config
610-
# Start PostgreSQL with the new shared_preload_libraries config
599+
brew install postgresql@17
611600
brew services start postgresql@17
612601
# Wait for PostgreSQL to start (check via TCP)
613602
for i in {1..30}; do
@@ -620,8 +609,6 @@ jobs:
620609
done
621610
# Create runner user for database access
622611
/opt/homebrew/opt/postgresql@17/bin/createuser -h localhost -s runner || true
623-
# Verify TimescaleDB extension is available
624-
/opt/homebrew/opt/postgresql@17/bin/psql -h localhost -d postgres -c "CREATE EXTENSION IF NOT EXISTS timescaledb; SELECT extversion FROM pg_extension WHERE extname = 'timescaledb';"
625612
- uses: jdx/mise-action@v3.2.0
626613
with:
627614
working_directory: .

AGENTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Tuist Server is an Elixir/Phoenix web application that extends the functionality
8080
**Key Technologies:**
8181
- **Backend**: Elixir 1.18.3 with Phoenix 1.7.12 framework
8282
- **Databases**:
83-
- PostgreSQL with TimescaleDB extension (primary database)
83+
- PostgreSQL (primary database)
8484
- ClickHouse (analytics database, write-only through IngestRepo)
8585
- **Frontend**: Phoenix LiveView with JavaScript/TypeScript and esbuild
8686
- **Package Management**: pnpm for JavaScript dependencies
@@ -104,7 +104,7 @@ Tuist Server is an Elixir/Phoenix web application that extends the functionality
104104
## Development Setup
105105

106106
**Prerequisites:**
107-
- PostgreSQL 16 with TimescaleDB extension
107+
- PostgreSQL 16
108108
- Mise development environment manager
109109
- Private key from 1Password for `priv/secrets/dev.key`
110110

@@ -234,7 +234,6 @@ The application deploys to Render with different environments:
234234

235235
- Always run `mix ecto.migrate` after pulling database migrations
236236
- Use `mise run install` after pulling dependency changes
237-
- The application requires TimescaleDB extension - install it if migrations fail
238237
- Local development connects to `http://localhost:8080` for Tuist CLI integration
239238

240239
# Tuist Handbook

docs/docs/en/contributors/code/server.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ Source: [github.com/tuist/tuist/tree/main/server](https://github.com/tuist/tuist
1313

1414
The server powers Tuist’s server-side features like authentication, accounts and projects, cache storage, insights, previews, registry, and integrations (GitHub, Slack, and SSO). It is a Phoenix/Elixir application with Postgres and ClickHouse.
1515

16-
::: warning TIMESCALEDB DEPRECATION
17-
<!-- -->
18-
TimescaleDB is deprecated and will be removed. For now, if you need it for local setup or migrations, use the [TimescaleDB installation docs](https://docs.timescale.com/self-hosted/latest/install/installation-macos/).
19-
<!-- -->
20-
:::
21-
2216
## How to contribute {#how-to-contribute}
2317

2418
Contributions to the server require signing the CLA (`server/CLA.md`).

docs/docs/en/guides/server/self-host/install.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,9 @@ Tuist server has been tested and is compatible with the following minimum versio
5555
5656
| Component | Minimum Version | Notes |
5757
| --- | --- | --- |
58-
| PostgreSQL | 15 | With TimescaleDB extension |
59-
| TimescaleDB | 2.16.1 | Required PostgreSQL extension (deprecated) |
58+
| PostgreSQL | 15 | |
6059
| ClickHouse | 25 | Required for analytics |
6160
62-
::: warning TIMESCALEDB DEPRECATION
63-
<!-- -->
64-
TimescaleDB is currently a required PostgreSQL extension for Tuist server, used for time-series data storage and querying. However, **TimescaleDB is deprecated** and will be dropped as a required dependency in the near future as we migrate all time-series functionality to ClickHouse. For now, ensure your PostgreSQL instance has TimescaleDB installed and enabled.
65-
<!-- -->
66-
:::
67-
6861
### Running Docker-virtualized images {#running-dockervirtualized-images}
6962
7063
We distribute the server as a [Docker](https://www.docker.com/) image via [GitHub’s Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).
@@ -73,19 +66,17 @@ To run it, your infrastructure must support running Docker images. Note that mos
7366
7467
### Postgres database {#postgres-database}
7568
76-
In addition to running the Docker images, you'll need a [Postgres database](https://www.postgresql.org/) with the [TimescaleDB extension](https://www.timescale.com/) to store relational and time-series data. Most infrastructure providers include Postgres databases in their offering (e.g., [AWS](https://aws.amazon.com/rds/postgresql/) & [Google Cloud](https://cloud.google.com/sql/docs/postgres)).
77-
78-
**TimescaleDB Extension Required:** Tuist requires the TimescaleDB extension for efficient time-series data storage and querying. This extension is used for command events, analytics, and other time-based features. Ensure your PostgreSQL instance has TimescaleDB installed and enabled before running Tuist.
69+
In addition to running the Docker images, you'll need a [Postgres database](https://www.postgresql.org/) to store relational data. Most infrastructure providers include Postgres databases in their offering (e.g., [AWS](https://aws.amazon.com/rds/postgresql/) & [Google Cloud](https://cloud.google.com/sql/docs/postgres)).
7970
8071
::: info MIGRATIONS
8172
<!-- -->
82-
The Docker image's entrypoint automatically runs any pending schema migrations before starting the service. If migrations fail due to a missing TimescaleDB extension, you'll need to install it in your database first.
73+
The Docker image's entrypoint automatically runs any pending schema migrations before starting the service.
8374
<!-- -->
8475
:::
8576
8677
### ClickHouse database {#clickhouse-database}
8778
88-
Tuist uses [ClickHouse](https://clickhouse.com/) for storing and querying large amounts of analytics data. ClickHouse is **required** for features like build insights and will be the primary time-series database as we phase out TimescaleDB. You can choose whether to self-host ClickHouse or use their hosted service.
79+
Tuist uses [ClickHouse](https://clickhouse.com/) for storing and querying large amounts of analytics data. ClickHouse is **required** for features like build insights. You can choose whether to self-host ClickHouse or use their hosted service.
8980
9081
::: info MIGRATIONS
9182
<!-- -->
@@ -301,7 +292,7 @@ On top of the `TUIST_GITHUB_APP_CLIENT_ID` and `TUIST_GITHUB_APP_CLIENT_SECRET`,
301292

302293
We provide a comprehensive Docker Compose configuration that includes all required dependencies for testing Tuist server on your local machine before deploying to your infrastructure:
303294

304-
- PostgreSQL 15 with TimescaleDB 2.16 extension (deprecated)
295+
- PostgreSQL 15
305296
- ClickHouse 25 for analytics
306297
- ClickHouse Keeper for coordination
307298
- MinIO for S3-compatible storage

docs/docs/public/server/self-host/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# with all dependencies included (PostgreSQL, ClickHouse, MinIO, Redis)
44

55
services:
6-
# PostgreSQL with TimescaleDB extension
6+
# PostgreSQL
77
postgres:
8-
image: timescale/timescaledb-ha:pg16
8+
image: postgres:16
99
container_name: tuist-postgres
1010
restart: unless-stopped
1111
environment:

server/AGENTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Tuist Server is an Elixir/Phoenix web application that extends the Tuist CLI. It
77

88
**Key Technologies**
99
- Backend: Elixir 1.18.3 with Phoenix 1.7.12
10-
- Databases: PostgreSQL with TimescaleDB (primary), ClickHouse (analytics; write via IngestRepo, read via ClickHouseRepo)
10+
- Databases: PostgreSQL (primary), ClickHouse (analytics; write via IngestRepo, read via ClickHouseRepo)
1111
- Frontend: Phoenix LiveView with JavaScript/TypeScript and esbuild
1212
- Package management: pnpm for JavaScript dependencies
1313

@@ -29,7 +29,7 @@ Tuist Server is an Elixir/Phoenix web application that extends the Tuist CLI. It
2929

3030
## Development Setup
3131
**Prerequisites**
32-
- PostgreSQL 16 with TimescaleDB extension
32+
- PostgreSQL 16
3333
- Mise development environment manager
3434
- Private key from 1Password for `priv/secrets/dev.key`
3535

@@ -115,7 +115,6 @@ mise run dev
115115
## Important Notes
116116
- Run `mix ecto.migrate` after pulling migrations.
117117
- Use `mise run install` after dependency changes.
118-
- TimescaleDB extension is required.
119118
- Local development connects to `http://localhost:8080` for Tuist CLI integration.
120119

121120
## Data Export Documentation

server/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Contributions to the Tuist Server require signing a Contributor License Agreemen
1111
### Requirements
1212

1313
- [Postgres](https://formulae.brew.sh/formula/postgresql@16)
14-
- [TimescaleDB](https://docs.timescale.com/self-hosted/latest/install/installation-macos/)
1514
- [Mise](https://mise.jdx.dev/)
1615

1716
### Set up
@@ -41,5 +40,4 @@ Pass: tuistrocks
4140
1. Run `tuist auth` to authenticate.
4241
1. You are now connected to the local Tuist Server! You can try running `tuist cache` and see the binaries being uploaded.
4342

44-
> [!IMPORTANT]
45-
> If the execution of database migrations fails because the TimescaleDB extension is not installed, you'll have to [install the extension](https://docs.timescale.com/self-hosted/latest/install/installation-macos/#set-up-the-timescaledb-extension) in the `tuist_development` database.
43+

server/data-export.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ Sensitive authentication data (passwords, tokens) are excluded from exports.
3737
- Alert rules (name, category, metric, deviation thresholds, Slack channel configuration)
3838
- Alert history (triggered alerts with current/previous values, timestamps)
3939

40-
### Analytics Data
40+
### Analytics Data (ClickHouse)
41+
The following data is stored in ClickHouse for analytics purposes:
42+
- **Build runs** (`build_runs` table): Complete build execution data including duration, status, cache statistics, CI metadata, git information, and custom tags
43+
- **Build issues** (`build_issues` table): Compilation warnings and errors from builds
44+
- **Build files** (`build_files` table): Individual file compilation metrics
45+
- **Build targets** (`build_targets` table): Target/module build performance
46+
- **Cacheable tasks** (`cacheable_tasks` table): Xcode cache task analytics with hit/miss status
47+
- **CAS outputs** (`cas_outputs` table): Content-addressable storage upload/download records
4148
- Build performance metrics
42-
- Build issues and compilation data
4349
- QA testing logs and results
44-
- Build runs with cache hit/miss statistics (cacheable_task_remote_hits_count, cacheable_task_local_hits_count, cacheable_tasks_count)
4550

4651
### Non-Exportable Data
4752
- Swift package registry data (shared community resources)

server/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3.8'
22
services:
33
db:
4-
image: timescale/timescaledb-ha:pg16
4+
image: postgres:16
55
restart: always
66
environment:
77
- POSTGRES_USER=postgres

server/lib/mix/tasks/db/create.ex

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
defmodule Mix.Tasks.Db.Create do
22
@moduledoc ~S"""
3-
This task extends the ecto.create task installing any necessary extensions right after the creation of the datatabase.
3+
This task extends the ecto.create task to ensure all repos are started after database creation.
44
"""
55
use Mix.Task
66
use Boundary, classify_to: Tuist.Mix
@@ -17,18 +17,6 @@ defmodule Mix.Tasks.Db.Create do
1717

1818
for repo <- repos do
1919
ensure_repo(repo, args)
20-
21-
case repo do
22-
Tuist.ClickHouseRepo ->
23-
:ok
24-
25-
Tuist.IngestRepo ->
26-
:ok
27-
28-
Tuist.Repo ->
29-
{:ok, _} =
30-
Ecto.Adapters.SQL.query(repo, "CREATE EXTENSION IF NOT EXISTS timescaledb", [])
31-
end
3220
end
3321
end
3422
end

0 commit comments

Comments
 (0)