-
Notifications
You must be signed in to change notification settings - Fork 7
170 lines (164 loc) · 5.17 KB
/
generate.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
name: cicd
on: [push]
jobs:
build:
runs-on: ubuntu-20.04
strategy:
max-parallel: 1
matrix:
python-version: [3.9]
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setup Go and protoc
run: |
python do.py setup_ext
- name: Install dependencies
run: |
python do.py setup
python do.py init
- name: Generate Python and Go SDK
run: |
".env/bin/python" do.py generate_sdk
- name: Build distribution
run: |
python do.py dist
python do.py generate_distribution_checksum
- name: Commit go and python pkg
id: get_sha
run: |
git config user.name "Github Actions Bot"
git config user.email "[email protected]"
git pull
git add --force gosnappi/\*
git add --force snappi/\*
git add --force requirements.txt
if git status --porcelain | grep .
then
git commit -m "Update auto generated go snappi"
git push
else
echo "No change in auto generated go snappi"
fi
echo "::set-output name=sha::$(git rev-parse HEAD)"
- name: storing get_sha in file
run: |
echo "${{ steps.get_sha.outputs.sha }}" > store_sha_file
- name: Archive generated artifacts
uses: actions/upload-artifact@v2
with:
name: generated-artifacts
path: |
dist
snappi
gosnappi
models-release
*.proto
store_sha_file
python_tests:
needs: build
runs-on: ubuntu-20.04
strategy:
max-parallel: 6
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v2
with:
name: generated-artifacts
- name: Install dependencies
run: |
python do.py setup
python do.py install
- name: Display structure of downloaded files
run: ls -R
- name: Run python tests
run: |
sudo python do.py testpy
go_tests:
needs: build
runs-on: ubuntu-20.04
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/download-artifact@v2
with:
name: generated-artifacts
- name: Display structure of downloaded files
run: ls -R
- name: Run go tests
run: |
python do.py testgo
publish_python_package:
if: github.ref == 'refs/heads/main'
needs: [go_tests, python_tests]
runs-on: ubuntu-20.04
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.6
- uses: actions/download-artifact@v2
with:
name: generated-artifacts
- name: Display structure of downloaded files
run: ls -R
- name: Get package version
id: get_version
run: |
echo "::set-output name=version::v$(python do.py version)"
- name: Check tag for current version
uses: mukunku/[email protected]
id: check_tag
with:
tag: ${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package
if: github.ref == 'refs/heads/main' && steps.check_tag.outputs.exists == 'false'
run: |
PYPI_USERNAME=__token__ PYPI_PASSWORD=${{ secrets.PYPI_API_TOKEN }} python do.py release
- name: Create release and publish artifacts
if: github.ref == 'refs/heads/main' && steps.check_tag.outputs.exists == 'false'
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*,models-release,*.proto"
tag: ${{ steps.get_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: get_sha value from file
id: get_sha
run: |
echo "::set-output name=value::$(cat store_sha_file)"
- name: Create tag for gosnappi
if: github.ref == 'refs/heads/main' && steps.check_tag.outputs.exists == 'false'
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/gosnappi/${{ steps.get_version.outputs.version }}",
sha: "${{ steps.get_sha.outputs.value }}"
})