-
Notifications
You must be signed in to change notification settings - Fork 13
192 lines (177 loc) · 6.18 KB
/
build.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
name: Build python package and splunk app
on:
push:
tags:
- 'v*'
branches:
- '*'
pull_request:
branches:
- master
- devel
jobs:
build:
runs-on: '${{ matrix.os }}'
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
include:
- os: ubuntu-latest
python-version: 3.10
build_sdist: true
# Building docs with 3.7 results in old Sphnix and bloated output
build_splunk_app: true
# - os: ubuntu-latest
# python-version: 3.7
# build_splunk_app: true
- os: ubuntu-latest
python-version: 3.9
extra_packages: argcomplete
- os: macos-latest
python-version: 3.9
- os: windows-latest
python-version: 3.9
steps:
- name: Job details
env:
BUILD_SDIST: ${{matrix.build_sdist}}
EXTRA_PKGS: ${{matrix.extra_packages}}
run: echo BUILD_SDIST=$BUILD_SDIST
- name: 'Set up Python ${{ matrix.python-version }}'
uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python-version }}'
- name: Cache multiple paths
uses: actions/cache@v3
with:
path: |-
$HOME/.cache/pip
$HOME/.pyenv
key: >
${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
- uses: actions/checkout@v3
- name: MacOS pyenv setup
run: |
if [ ! -e "$HOME/.pyenv/.git" ]; then
if [ -e "$HOME/.pyenv" ]; then
rm -rf ~/.pyenv
fi
git clone https://github.com/pyenv/pyenv.git ~/.pyenv --depth 10
else
(cd ~/.pyenv; git pull)
fi
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
hash -r
eval "$(pyenv init -)"
hash -r
pyenv install --list
pyenv install -s $PYENV_VERSION
pyenv rehash
pip install wheel
# Since pyenv can be cached across OSX builds, uninstall first for a fresh build
if pip show kintyre-splunk-conf; then pip uninstall -y kintyre-splunk-conf; fi
if pip show ksconf; then pip uninstall -y ksconf; fi
if: ${{ matrix.os == 'macOS' }}
env:
PYENV_VERSION: ${{matrix.python-version}}
- name: Upgrade pip & install packaging tools
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- run: pip install $EXTRA_PKGS -r requirements-ci.txt
- name: Install ksconf python package
run: pip install .
- run: echo "Build $GITHUB_RUN_NUMBER BRANCH=$GITHUB_BASE_REF TAG=$GITHUB_REF"
- run: pip list --format=columns
- run: >
export DO_RELEASE=True
echo DO_RELEASE=$DO_RELEASE
if: contains(github.ref, 'tags/v') && matrix.build_sdist == true
- run: ksconf --version
- run: coverage run -m unittest discover -s tests
# - run: coverage run -a -m make_cli_docs
- run: coverage xml
- name: Submit to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
###############################################################
# This isn't working for some reason....
# Using lcov file: ./coverage/lcov.info
# Error: Lcov file not found.
# - name: Coveralls
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
###############################################################
# This fails with:
# requests.exceptions.HTTPError: 422 Client Error:
# Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
# - run: coveralls
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish ksconf to PyPI
if: contains(github.ref, 'tags/v') && matrix.build_sdist == true
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.KSCONF_PYPI_TOKEN }}
run: |
echo $GITHUB_REF
echo "::group::Pip install"
pip install twine
echo "::endgroup::"
echo "::group::Run setup.py"
python setup.py sdist bdist_wheel
echo "::endgroup::"
twine upload dist/ksconf-*
- name: Build and publish legacy kintyre-splunk-conf to PyPI
if: contains(github.ref, 'tags/v') && matrix.build_sdist == true
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
BUILD_OLD_PACKAGE: 1
run: |
echo "::group::Run legacy/setup.py"
python setup.py sdist bdist_wheel
echo "::endgroup::"
twine upload dist/kintyre_splunk_conf-*
- name: Build Splunk app
id: buildpkg
if: matrix.build_splunk_app == true
run: |
python -m pip install -r requirements-doc.txt
python splunk_app/build.py -vv
set +x
echo "path=$(cat .release_path)" >> $GITHUB_OUTPUT
echo "name=$(cat .release_name)" >> $GITHUB_OUTPUT
env:
KSCONF_DEBUG: 1
- name: Create release and upload GitHub artifact
uses: softprops/action-gh-release@v1
if: contains(github.ref, 'tags/v') && matrix.build_splunk_app == true
with:
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
files: ${{ steps.buildpkg.outputs.path }}
- name: Bump latest version in the ksconf-pre-commit repo
if: contains(github.ref, 'tags/v') && matrix.build_sdist == true
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.PRE_COMMIT_PAT }}
repository: Kintyre/ksconf-pre-commit
event-type: bumpversion-event
client-payload: >
{"ref": "${{ github.ref }}",
"sha": "${{ github.sha }}"}