-
Notifications
You must be signed in to change notification settings - Fork 28
153 lines (142 loc) · 5.14 KB
/
notebooks.yaml
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
# SPDX-License-Identifier: Apache-2.0
name: Testing Notebooks
on:
schedule: # Test all notebooks daily
- cron: '0 10 * * *'
workflow_dispatch: # Test notebooks on demand
inputs:
pr:
description: 'Pull Request number or leave empty for all notebooks'
required: false
type: string
default: ''
push:
branches:
- main
paths:
- '.github/workflows/notebooks.yaml' # This workflow
- '.github/notebook_lists/*' # Notebook lists
- 'recipes/**/*.ipynb'
pull_request:
branches:
- main
paths:
- '.github/workflows/notebooks.yaml' # This workflow
- '.github/notebook_lists/*' # Notebook lists
- 'recipes/**/*.ipynb'
env:
LC_ALL: en_US.UTF-8
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
test_workflow_ready:
# Don't run schedule target in forks
if: ${{ (github.event_name != 'schedule') || (github.repository_owner == 'ibm-granite-community') }}
permissions:
pull-requests: write
statuses: write
runs-on: ubuntu-latest
outputs:
ref: ${{ inputs.pr && format('refs/pull/{0}/merge',inputs.pr) || '' }}
all: ${{ contains(fromJSON('["schedule","workflow_dispatch"]'), github.event_name) && !inputs.pr }}
status_url: ${{ steps.pr.outputs.status_url }}
run_url: ${{ steps.pr.outputs.run_url }}
steps:
- name: Checkout
if: ${{ inputs.pr }}
id: checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.pr && format('refs/pull/{0}/head',inputs.pr) || '' }}
- name: Pull Request dispatch
if: ${{ inputs.pr }}
id: pr
run: |
echo "status_url=$STATUS_URL" >> "$GITHUB_OUTPUT"
echo "run_url=$RUN_URL" >> "$GITHUB_OUTPUT"
gh api -X POST "$STATUS_URL" -f "context=PR Test" -f "state=$STATUS_STATE" -f "description=$STATUS_DESCRIPTION" -f "target_url=$RUN_URL&pr=$PR"
gh pr comment "$PR" -b "$GITHUB_WORKFLOW workflow launched on this PR: [View run]($RUN_URL)"
env:
PR: ${{ inputs.pr }}
STATUS_URL: ${{ github.api_url }}/repos/${{ github.repository }}/statuses/${{ steps.checkout.outputs.commit }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
STATUS_STATE: pending
STATUS_DESCRIPTION: This check has started...
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
vanilla:
needs:
- test_workflow_ready
permissions:
contents: read
uses: ibm-granite-community/utils/.github/workflows/test_notebook.yaml@main
secrets:
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }}
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
WATSONX_URL: ${{ secrets.WATSONX_URL }}
with:
notebook-lists: |
.github/notebook_lists/vanilla_notebooks.txt
python-versions: >-
3.10
3.11
ref: ${{ needs.test_workflow_ready.outputs.ref }}
all: ${{ fromJSON(needs.test_workflow_ready.outputs.all) }}
pdl:
needs:
- test_workflow_ready
permissions:
contents: read
uses: ibm-granite-community/utils/.github/workflows/test_notebook.yaml@main
secrets:
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }}
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
WATSONX_URL: ${{ secrets.WATSONX_URL }}
with:
notebook-lists: |
.github/notebook_lists/pdl_notebooks.txt
python-versions: >-
3.11
ref: ${{ needs.test_workflow_ready.outputs.ref }}
all: ${{ fromJSON(needs.test_workflow_ready.outputs.all) }}
ollama:
needs:
- test_workflow_ready
permissions:
contents: read
uses: ibm-granite-community/utils/.github/workflows/test_notebook.yaml@main
with:
notebook-lists: |
.github/notebook_lists/ollama_notebooks.txt
python-versions: >-
3.11
ref: ${{ needs.test_workflow_ready.outputs.ref }}
all: ${{ fromJSON(needs.test_workflow_ready.outputs.all) }}
action: .github/actions/ollama-setup
test_workflow_complete:
needs:
- test_workflow_ready
- vanilla
- pdl
- ollama
permissions:
pull-requests: write
statuses: write
runs-on: ubuntu-latest
if: ${{ !cancelled() && (needs.test_workflow_ready.result == 'success') }}
steps:
- name: Pull Request dispatch
if: ${{ inputs.pr }}
run: |
gh api -X POST "$STATUS_URL" -f "context=PR Test" -f "state=$STATUS_STATE" -f "description=$STATUS_DESCRIPTION" -f "target_url=$RUN_URL&pr=$PR"
env:
PR: ${{ inputs.pr }}
STATUS_URL: ${{ needs.test_workflow_ready.outputs.status_url }}
RUN_URL: ${{ needs.test_workflow_ready.outputs.run_url }}
STATUS_STATE: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 'failure' || 'success' }}
STATUS_DESCRIPTION: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 'Failure' || 'Success' }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}