Repository navigation
108 lines (96 loc) · 4.78 KB
/
Copy pathtest-code-samples-linear.yml
File metadata and controls
108 lines (96 loc) · 4.78 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
---
name: Test Code Samples Linear Ticket
permissions:
contents: read
# Read the triggering run's job list.
actions: read
# Filed separately so PR runs of "Test Code Samples" do not show a skipped
# create-linear-tickets check on every pull request.
#
# "Test Code Samples" runs one matrix leg per product, oss and langsmith.
# This workflow files one Linear ticket per failed leg so an OSS regression
# and a LangSmith regression land as separate issues.
#
# Needs the LINEAR_TEAM_KEY repository variable (a team key such as DOC;
# Settings > Secrets and variables > Actions > Variables). The job warns and
# files nothing when it is unset, instead of failing.
on:
workflow_run:
workflows: ["Test Code Samples"]
types: [completed]
jobs:
create-linear-tickets:
if: >-
github.event.workflow_run.event == 'schedule' &&
(github.event.workflow_run.conclusion == 'failure' ||
github.event.workflow_run.conclusion == 'cancelled')
runs-on: ubuntu-latest
steps:
- name: Warn when LINEAR_TEAM_KEY is unset
if: vars.LINEAR_TEAM_KEY == ''
env:
RUN_URL: ${{ github.event.workflow_run.html_url }}
run: |
echo "::warning::Repository variable LINEAR_TEAM_KEY is unset; no Linear ticket filed for $RUN_URL"
- name: Find the failed legs
if: vars.LINEAR_TEAM_KEY != ''
id: legs
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
# Only fixed product names are written to outputs; job text is not.
jobs=$(gh run view "$RUN_ID" --repo "$GITHUB_REPOSITORY" --json jobs \
--jq '.jobs[] | select(.conclusion != "success") | .name')
echo "Jobs that did not succeed:"
echo "$jobs"
for product in oss langsmith; do
if grep -qF "test-code-samples ($product)" <<< "$jobs"; then
echo "$product=true" >> "$GITHUB_OUTPUT"
else
echo "$product=false" >> "$GITHUB_OUTPUT"
fi
done
if grep -qF "test-code-samples (" <<< "$jobs"; then
echo "any_leg=true" >> "$GITHUB_OUTPUT"
else
echo "any_leg=false" >> "$GITHUB_OUTPUT"
fi
- name: File OSS ticket
if: vars.LINEAR_TEAM_KEY != '' && steps.legs.outputs.oss == 'true'
uses: ctriolo/action-create-linear-issue@699c7c2f0639181e0eaf5622d2987c6584f48a5a # v0.7
with:
linear-api-key: ${{ secrets.LINEAR_API_KEY }}
linear-team-key: ${{ vars.LINEAR_TEAM_KEY }}
linear-issue-title: "Monthly OSS code samples test failed"
linear-issue-description: |
The monthly test of the OSS code samples (`src/code-samples/langchain`, `langgraph`, `deepagents`) did not pass.
**Workflow run:** ${{ github.event.workflow_run.html_url }}
Open the `test-code-samples (oss)` job for per-sample output. Re-run that job alone to retry this leg.
linear-attachment-url: ${{ github.event.workflow_run.html_url }}
linear-attachment-title: "Failed workflow run"
- name: File LangSmith ticket
if: vars.LINEAR_TEAM_KEY != '' && steps.legs.outputs.langsmith == 'true'
uses: ctriolo/action-create-linear-issue@699c7c2f0639181e0eaf5622d2987c6584f48a5a # v0.7
with:
linear-api-key: ${{ secrets.LINEAR_API_KEY }}
linear-team-key: ${{ vars.LINEAR_TEAM_KEY }}
linear-issue-title: "Monthly LangSmith code samples test failed"
linear-issue-description: |
The monthly test of the LangSmith code samples (`src/code-samples/langsmith`) did not pass.
**Workflow run:** ${{ github.event.workflow_run.html_url }}
Open the `test-code-samples (langsmith)` job for per-sample output. Re-run that job alone to retry this leg.
linear-attachment-url: ${{ github.event.workflow_run.html_url }}
linear-attachment-title: "Failed workflow run"
- name: File a generic ticket when no leg ran
if: vars.LINEAR_TEAM_KEY != '' && steps.legs.outputs.any_leg == 'false'
uses: ctriolo/action-create-linear-issue@699c7c2f0639181e0eaf5622d2987c6584f48a5a # v0.7
with:
linear-api-key: ${{ secrets.LINEAR_API_KEY }}
linear-team-key: ${{ vars.LINEAR_TEAM_KEY }}
linear-issue-title: "Monthly code samples run did not complete"
linear-issue-description: |
The monthly code samples run ended as `${{ github.event.workflow_run.conclusion }}` before any product leg reported, so this is a pipeline problem rather than a sample failure.
**Workflow run:** ${{ github.event.workflow_run.html_url }}
linear-attachment-url: ${{ github.event.workflow_run.html_url }}
linear-attachment-title: "Failed workflow run"