-
Notifications
You must be signed in to change notification settings - Fork 119
177 lines (164 loc) · 6.17 KB
/
Copy pathnotebooks.yaml
File metadata and controls
177 lines (164 loc) · 6.17 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
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
174
175
176
177
# 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.ya?ml' # This workflow
- '.github/actions/**/action.ya?ml' # Possibly used by this workflow
- '.github/notebook_lists/*' # Notebook lists
- 'recipes/**/*.ipynb'
pull_request:
branches:
- main
paths:
- '.github/workflows/notebooks.ya?ml' # This workflow
- '.github/actions/**/action.ya?ml' # Possibly used by 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: "Harden Runner"
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
disable-sudo-and-containers: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
- name: Checkout
if: ${{ inputs.pr }}
id: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.pr && format('refs/pull/{0}/head',inputs.pr) || '' }}
persist-credentials: false
- 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.11
3.12
ref: ${{ needs.test_workflow_ready.outputs.ref }}
all: ${{ fromJSON(needs.test_workflow_ready.outputs.all) }}
free-disk-space: '{"large-packages": false}' # Takes a long time
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) }}
free-disk-space: '{"large-packages": false}' # Takes a long time
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
free-disk-space: '{"large-packages": false}' # Takes a long time
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: "Harden Runner"
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
disable-sudo-and-containers: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
- 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 }}