Github build: Build on 3.10 #305
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.7' | |
- '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.8 | |
extra_packages: argcomplete | |
- os: macos-latest | |
python-version: 3.7.12 | |
- os: windows-latest | |
python-version: 3.7 | |
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@v4 | |
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 }}"} |