forked from PostHog/posthog
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (102 loc) · 4.71 KB
/
Copy pathci-agent-proxy.yml
File metadata and controls
121 lines (102 loc) · 4.71 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
name: Agent Proxy CI
on:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
pull-requests: read
jobs:
changes:
runs-on: ubuntu-latest
timeout-minutes: 5
name: Determine need to run agent-proxy checks
outputs:
agent_proxy: ${{ steps.filter.outputs.agent_proxy || 'true' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
client-id: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }}
private-key: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}
- uses: ./.github/actions/paths-filter
id: filter
if: github.event_name != 'push'
with:
token: ${{ steps.app-token.outputs.token || github.token }}
filters: |
agent_proxy:
- 'services/agent-proxy/**'
- '.github/workflows/ci-agent-proxy.yml'
agent-proxy:
name: Agent Proxy checks
needs: changes
if: needs.changes.outputs.agent_proxy == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
token: ${{ github.token }}
- name: Get pnpm store path
id: pnpm-store
run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies
run: pnpm install --frozen-lockfile --filter @posthog/agent-proxy...
- name: Save pnpm cache
if: github.ref == 'refs/heads/master'
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- name: Typecheck
working-directory: services/agent-proxy
run: pnpm typecheck
- name: Test
working-directory: services/agent-proxy
run: pnpm exec vitest run
- name: Lint
working-directory: services/agent-proxy
run: pnpm exec oxlint
- name: Format check
working-directory: services/agent-proxy
run: pnpm exec oxfmt --check 'src/**/*.ts' 'tests/**/*.ts' 'scripts/**/*.ts'
agent_proxy_ci:
needs: [changes, agent-proxy]
name: Agent Proxy CI Pass
runs-on: ubuntu-latest
timeout-minutes: 5
# always(), not !cancelled(): a skipped required check is treated as a pass by
# branch protection, so on cancellation the gate must run and emit an explicit
# result rather than skip into a green. A cancelled or timed-out job is caught
# by the != success && != skipped checks below; a legitimate no-change skip passes.
if: always()
steps:
- name: Check outcomes
run: |
if [[ "${{ needs.changes.result }}" != "success" && "${{ needs.changes.result }}" != "skipped" ]]; then
echo "Change detection did not succeed (result: ${{ needs.changes.result }})."
exit 1
fi
if [[ "${{ needs.agent-proxy.result }}" != "success" && "${{ needs.agent-proxy.result }}" != "skipped" ]]; then
echo "Agent Proxy checks did not succeed (result: ${{ needs.agent-proxy.result }})."
exit 1
fi
echo "All agent-proxy checks passed."