-
Notifications
You must be signed in to change notification settings - Fork 16
194 lines (184 loc) · 6.19 KB
/
check-package.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Check package flow
on:
workflow_call:
inputs:
actions-ref:
description: "Version of actions, normally the same as workflow"
required: true
type: string
artifact-name:
description: "Unique name for collecting artifacts, it shall be unique for all workflows"
required: true
type: string
install-extras:
description: "optional extras which are needed to include also []"
required: false
type: string
default: ""
install-flags:
description: "Additional pip install flags"
required: false
type: string
default: "-f https://download.pytorch.org/whl/cpu/torch_stable.html"
import-name:
description: "Import name to test with after installation"
required: true
type: string
custom-import-code:
description: "additional import statement, need to be full python code"
type: string
required: false
default: ""
build-matrix:
description: "what building configs in json format, expected keys are `os` and `python-version`"
required: false
type: string
default: |
{
"os": ["ubuntu-latest"],
}
testing-matrix:
description: "what test configs to run in json format, expected keys are `os` and `python-version`"
required: false
type: string
# default operating systems should be pinned to specific versions instead of "-latest" for stability
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
default: |
{
"os": ["ubuntu-22.04", "macos-13", "windows-2022"],
"python-version": ["3.9", "3.13"]
}
env-vars:
description: "custom environment variables in json format"
required: false
type: string
default: |
{
"SAMPLE_ENV_VARIABLE": 1,
}
defaults:
run:
shell: bash
jobs:
pkg-build:
runs-on: ${{ matrix.os }}
env: ${{ fromJSON(inputs.env-vars) }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.build-matrix) }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 0 # checkout entire history for all branches (required when using scm-based versioning)
submodules: recursive
- name: Set up Python 🐍
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version || '3.x' }}
- name: Pull reusable 🤖 actions️
uses: actions/checkout@v4
with:
ref: ${{ inputs.actions-ref }}
path: .cicd
repository: Lightning-AI/utilities
- name: Prepare build env.
run: pip install -r ./.cicd/requirements/gha-package.txt
- name: Create package 📦
uses: ./.cicd/.github/actions/pkg-create
- name: Upload 📤 packages
if: ${{ inputs.artifact-name != '' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}-build-${{ strategy.job-index }}
path: dist
merge-artifacts:
needs: pkg-build
runs-on: ubuntu-latest
steps:
- name: Pull reusable 🤖 actions️
uses: actions/checkout@v4
with:
ref: ${{ inputs.actions-ref }}
path: .cicd
repository: Lightning-AI/utilities
- name: Prepare build env.
run: pip install -r ./.cicd/requirements/gha-package.txt
- name: Download 📥
uses: actions/download-artifact@v4
with:
# download all build artifacts
pattern: ${{ inputs.artifact-name }}-build-*
merge-multiple: true
path: dist
- name: Brief look
run: |
ls -lh dist/
twine check dist/*
- name: Upload 📤
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: dist
pkg-check:
needs: merge-artifacts
runs-on: ${{ matrix.os }}
env: ${{ fromJSON(inputs.env-vars) }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.testing-matrix) }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python 🐍 ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version || '3.x' }}
- name: Pull reusable 🤖 actions️
uses: actions/checkout@v4
with:
ref: ${{ inputs.actions-ref }}
path: .cicd
repository: Lightning-AI/utilities
- name: Download 📥 all packages
if: ${{ inputs.artifact-name != '' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: pypi
- name: Installing package 📦 as Archive
timeout-minutes: 10
uses: ./.cicd/.github/actions/pkg-install
with:
install-from: "archive"
artifact-name: ${{ inputs.artifact-name }}
pkg-extras: ${{ inputs.install-extras }}
pip-flags: ${{ inputs.install-flags }}
import-name: ${{ inputs.import-name }}
custom-import-code: ${{ inputs.custom-import-code }}
- name: Installing package 📦 as Wheel
timeout-minutes: 10
uses: ./.cicd/.github/actions/pkg-install
with:
install-from: "wheel"
artifact-name: ${{ inputs.artifact-name }}
pkg-extras: ${{ inputs.install-extras }}
pip-flags: ${{ inputs.install-flags }}
import-name: ${{ inputs.import-name }}
custom-import-code: ${{ inputs.custom-import-code }}
# TODO: add run doctests
pkg-guardian:
runs-on: ubuntu-latest
needs: pkg-check
if: always()
steps:
- run: echo "${{ needs.pkg-check.result }}"
- name: failing...
if: needs.pkg-check.result == 'failure'
run: exit 1
- name: cancelled or skipped...
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pkg-check.result)
timeout-minutes: 1
run: sleep 90