-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
153 lines (140 loc) · 5.43 KB
/
Copy pathtinybird.yml
File metadata and controls
153 lines (140 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Tinybird
on:
pull_request:
types: [opened, synchronize, reopened]
push:
# Run on pushes to main, release branches, and previous/future major version branches.
branches:
- main
- 'v[0-9]+.*'
- '[0-9]+.x'
tags:
- 'v[0-9]*'
paths:
- '.github/workflows/tinybird.yml'
- 'compose.dev.analytics.yaml'
- 'ghost/core/core/server/data/tinybird/**'
- '!ghost/core/core/server/data/tinybird/**/*.md'
permissions:
contents: read
jobs:
changes:
name: Detect Tinybird changes
runs-on: ubuntu-slim
permissions:
contents: read
pull-requests: read
outputs:
tinybird: ${{ steps.changed.outputs.tinybird }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
# Pushes remain filtered at the workflow level, so change detection is
# only needed to decide whether the tests should run for a pull request.
- name: Determine whether Tinybird files changed
id: changed
if: github.event_name == 'pull_request'
uses: AurorNZ/paths-filter@c9dd42e99db87803313ff6f4b1150cc9f6c836af # v5.0.0
with:
filters: |
tinybird:
- '.github/workflows/tinybird.yml'
- 'compose.dev.analytics.yaml'
- 'ghost/core/core/server/data/tinybird/**'
- '!ghost/core/core/server/data/tinybird/**/*.md'
tests:
name: Tinybird Tests
runs-on: ubuntu-latest
needs: [changes]
if: github.event_name != 'pull_request' || needs.changes.outputs.tinybird == 'true'
defaults:
run:
working-directory: ghost/core/core/server/data/tinybird
services:
tinybird:
image: tinybirdco/tinybird-local:latest@sha256:cf9de0516700eea366161181e74cae943f1a7310e6f2cc4f5762cb1777ed3fb3
ports:
- 7181:7181
outputs:
datafiles_changed: ${{ steps.datafiles.outputs.tinybird }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: Determine whether Tinybird datafiles changed
id: datafiles
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: AurorNZ/paths-filter@c9dd42e99db87803313ff6f4b1150cc9f6c836af # v5.0.0
with:
filters: |
tinybird:
- 'ghost/core/core/server/data/tinybird/**'
- '!ghost/core/core/server/data/tinybird/**/*.md'
# tinybird.co/install.sh always installs the latest CLI, so this job
# silently tracked upstream. 4.6.14 ingests a nested JSON object into a
# String column as ClickHouse Tuple syntax instead of raw JSON, so every
# JSONExtractString(payload, ...) in pipes/mv_hits.pipe returns '' and all
# 29 endpoint tests read back empty. Pin until that's fixed upstream; keep
# in lockstep with docker/tb-cli/Dockerfile.
- name: Install Tinybird CLI
env:
# renovate: datasource=pypi depName=tinybird versioning=pep440
TINYBIRD_VERSION: 4.6.13
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv tool install "tinybird@${TINYBIRD_VERSION}" --python 3.11 --force
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Build project
run: tb build
- name: Test project
run: tb test run
- name: Trigger and watch traffic analytics infra Tinybird workflow
if: github.repository == 'TryGhost/Ghost' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
env:
GH_TOKEN: ${{ secrets.TRAFFIC_ANALYTICS_GITHUB_TOKEN }}
uses: ./.github/actions/dispatch-workflow
with:
repo: TryGhost/traffic-analytics-infra
workflow: tinybird.yml
branch: main
dispatch-inputs: >-
{
"ghost_ref": "${{ github.sha }}",
"caller_run_id": "${{ github.run_id }}",
"run_local_tests": false
}
required:
name: Tinybird required tests passed or skipped
needs: [changes, tests]
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-slim
steps:
- name: Check if any required jobs failed or were cancelled
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "Tinybird change detection or tests failed or were cancelled." && exit 1
deploy:
name: Deploy Tinybird
runs-on: ubuntu-latest
needs: [tests]
if: github.repository == 'TryGhost/Ghost' && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.tests.outputs.datafiles_changed == 'true'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Trigger and watch traffic analytics infra Tinybird workflow
env:
GH_TOKEN: ${{ secrets.TRAFFIC_ANALYTICS_GITHUB_TOKEN }}
uses: ./.github/actions/dispatch-workflow
with:
repo: TryGhost/traffic-analytics-infra
workflow: tinybird.yml
branch: main
dispatch-inputs: >-
{
"ghost_ref": "${{ github.sha }}",
"caller_run_id": "${{ github.run_id }}",
"run_local_tests": false,
"deploy_staging": true,
"deploy_production": true
}