-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (131 loc) · 4.14 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
name: CI
on:
push:
schedule:
# Every day at ~7:17am Chicago time.
#
# Using a non-zero minute offset since GitHub Actions suggests
# running jobs at a random minute to avoid overloading their
# servers.
#
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '17 12 * * *'
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
test-readmes-up-to-date:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Make READMEs
run: node tools/make-readmes.js
- name: Ensure READMEs are up to date
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "::error::The READMEs are out of date. Please run 'node tools/make-readmes.js' and commit the changes."
exit 1
else
echo "READMEs are up to date!"
fi
test-python:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- Python/langchain
- Python/openai-manual
- Python/openai-automated
defaults:
run:
shell: bash
working-directory: ${{ matrix.project }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "AUTOBLOCKS_INGESTION_KEY=${{ secrets.AUTOBLOCKS_INGESTION_KEY }}" >> .env
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Check pyproject.toml & poetry.lock are in sync
run: poetry lock --check
- name: Install dependencies
run: poetry install
- name: Run script
run: poetry run python main.py
test-javascript:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- JavaScript/jest-replays
- JavaScript/langchain
- JavaScript/openai-automated
- JavaScript/openai-manual
- JavaScript/spans
defaults:
run:
shell: bash
working-directory: ${{ matrix.project }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "AUTOBLOCKS_INGESTION_KEY=${{ secrets.AUTOBLOCKS_INGESTION_KEY }}" >> .env
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run script
run: npm run start
# This allows us to have one required status check on the "test" job
# since it's not feasible to maintain required status checks on each
# job in the matrixes above.
test:
needs:
- test-python
- test-javascript
if: always()
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "::error::One of the jobs failed or was cancelled."
exit 1
notify:
needs:
- test-python
- test-javascript
if: always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: slackapi/[email protected]
with:
payload: |
{
"text": ":warning: Workflow `${{ github.workflow }}` in repository `${{ github.repository }}` failed. <${{ env.run-url }}|Logs>"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}