-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (111 loc) · 3.83 KB
/
main.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
name: Main
on:
push:
tags: "v[0-9]+.[0-9]+.[0-9]+"
branches: "main"
pull_request:
branches: "*"
env:
HOME_REPO: "elastic/faker-datasets"
jobs:
unit-tests:
name: Unit tests (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: make prereq
- name: Lint code
run: make lint
- name: Run tests
run: make test V=2
package-build:
name: Package build (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: make prereq
- name: Build package
run: make pkg-build
- name: Upload artifacts
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
with:
name: python-package-${{ matrix.python-version }}-${{ matrix.os }}
path: dist/*
package-tests:
name: Package tests (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs: package-build
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
path: code
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: python-package-${{ matrix.python-version }}-${{ matrix.os }}
path: dist
- name: Install package
run: make -f code/Makefile pkg-install
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- unit-tests
- package-tests
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: "3.8"
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: python-package-3.8-ubuntu-latest
path: dist
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@8a08d616893759ef8e1aa1f2785787c0b97e20d6 # v1.10.0
if: github.repository != env.HOME_REPO
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
print_hash: true
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@8a08d616893759ef8e1aa1f2785787c0b97e20d6 # v1.10.0
if: github.repository == env.HOME_REPO
with:
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true