-
Notifications
You must be signed in to change notification settings - Fork 4.6k
173 lines (161 loc) · 5.81 KB
/
ci.yml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: CI
on:
workflow_call:
inputs:
python-versions:
description: "Python Versions"
required: false
type: string
default: "['3.10']"
frontend-tests-folder:
description: "Frontend Tests Folder"
required: false
type: string
default: "tests/core"
release:
description: "Release"
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
branch:
description: "(Optional) Branch to checkout"
required: false
type: string
openai_api_key:
description: "OpenAI API Key"
required: false
type: string
store_api_key:
description: "Store API Key"
required: false
type: string
python-versions:
description: "Python Versions"
required: false
type: string
default: "['3.10']"
pull_request:
types: [synchronize, labeled]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-nightly-status:
name: Check Nightly Status
runs-on: ubuntu-latest
outputs:
should-proceed: ${{ steps.check-workflow.outputs.success }}
steps:
- name: Check nightly workflow status
id: check-workflow
uses: actions/github-script@v7
with:
script: |
const workflow_name = 'nightly_build.yml';
const { data: runs } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow_name,
per_page: 1,
status: 'completed'
});
if (runs.workflow_runs.length === 0) {
console.log('No completed workflow runs found');
return core.setOutput('success', 'true');
}
const lastRun = runs.workflow_runs[0];
const success = lastRun.conclusion === 'success';
console.log(`Last nightly build status: ${lastRun.conclusion}`);
core.setOutput('success', success.toString());
set-ci-condition:
needs: check-nightly-status
name: Should Run CI
runs-on: ubuntu-latest
outputs:
should-run-ci: ${{ (needs.check-nightly-status.outputs.should-proceed == 'true' || github.event_name == 'workflow_dispatch') && ((contains( github.event.pull_request.labels.*.name, 'lgtm') && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || github.event_name == 'merge_group')) }}
steps:
# Do anything just to make the job run
- run: echo "Debug CI Condition"
- run: echo "Labels -> ${{ join(github.event.pull_request.labels.*.name, ',') }}"
- run: echo "IsDraft -> ${{ github.event.pull_request.draft }}"
- run: echo "Event name -> ${{ github.event_name }}"
- run: echo "Nightly build status -> ${{ needs.check-nightly-status.outputs.should-proceed }}"
path-filter:
needs: set-ci-condition
if: ${{ needs.set-ci-condition.outputs.should-run-ci == 'true' }}
name: Filter Paths
runs-on: ubuntu-latest
outputs:
python: ${{ steps.filter.outputs.python }}
frontend: ${{ steps.filter.outputs.frontend }}
docs: ${{ steps.filter.outputs.docs }}
frontend-tests: ${{ steps.filter.outputs.frontend-tests }}
components-changes: ${{ steps.filter.outputs.components-changes }}
starter-projects-changes: ${{ steps.filter.outputs.starter-projects-changes }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Filter Paths
id: filter
uses: dorny/paths-filter@v3
with:
filters: ./.github/changes-filter.yaml
test-backend:
needs: path-filter
name: Run Backend Tests
if: ${{ needs.path-filter.outputs.python == 'true'}}
uses: ./.github/workflows/python_test.yml
with:
python-versions: ${{ inputs.python-versions || '["3.10"]' }}
test-frontend:
needs: path-filter
name: Run Frontend Tests
if: ${{ needs.path-filter.outputs.frontend == 'true' || needs.path-filter.outputs.frontend-tests == 'true' || needs.path-filter.outputs.components-changes == 'true' || needs.path-filter.outputs.starter-projects-changes == 'true' }}
uses: ./.github/workflows/typescript_test.yml
with:
tests_folder: ${{ inputs.frontend-tests-folder }}
release: ${{ inputs.release || false }}
secrets:
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
STORE_API_KEY: "${{ secrets.STORE_API_KEY }}"
ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
TAVILY_API_KEY: "${{ secrets.TAVILY_API_KEY }}"
lint-backend:
needs: path-filter
if: ${{ needs.path-filter.outputs.python == 'true'}}
name: Lint Backend
uses: ./.github/workflows/lint-py.yml
test-docs-build:
needs: path-filter
if: ${{ needs.path-filter.outputs.docs == 'true' }}
name: Test Docs Build
uses: ./.github/workflows/docs_test.yml
# https://github.com/langchain-ai/langchain/blob/master/.github/workflows/check_diffs.yml
ci_success:
name: "CI Success"
needs:
[
test-backend,
test-frontend,
lint-backend,
test-docs-build,
set-ci-condition,
]
if: always()
runs-on: ubuntu-latest
env:
JOBS_JSON: ${{ toJSON(needs) }}
RESULTS_JSON: ${{ toJSON(needs.*.result) }}
EXIT_CODE: ${{!contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && needs.set-ci-condition.outputs.should-run-ci == 'true' && '0' || '1'}}
steps:
- name: "CI Success"
run: |
echo $JOBS_JSON
echo $RESULTS_JSON
echo "Exiting with $EXIT_CODE"
exit $EXIT_CODE