Skip to content

Commit

Permalink
Merge pull request #97 from wavefrontHQ/austinov/update_actions
Browse files Browse the repository at this point in the history
Update GitHub Actions Workflows.
  • Loading branch information
ustinov authored Sep 8, 2022
2 parents e409750 + 760263e commit c74aebf
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 76 deletions.
49 changes: 49 additions & 0 deletions .github/actions/lint_n_test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Lint & Test

inputs:
python_version:
default: '3.10'
type: string
input_pkg_name:
required: true
type: string
extra_packages:
type: string

runs:
using: composite
steps:
- name: Set up Python ${{ inputs.python_version }}
uses: actions/setup-python@v3
with:
python-version: ${{ inputs.python_version }}
- name: Install Latest pip and setuptools
run: python -m pip install -U pip setuptools wheel
shell: bash
- name: Install Linters
run: |
python -m pip install -U flake8 flake8-colors
python -m pip install -U flake8-import-order pep8-naming
python -m pip install -U pydocstyle pylint
shell: bash
- name: Install Extra Dependencies ${{ inputs.extra_packages }}
run: python -m pip install -U ${{ inputs.extra_packages }}
shell: bash
- name: Run Flake8 Checks
run: python -m flake8
shell: bash
- name: Run PyLint Checks on ${{ inputs.input_pkg_name }}
run: python -m pylint -d duplicate-code ${{ inputs.input_pkg_name }}
shell: bash
- name: PyDocStyle
run: python -m pydocstyle
shell: bash
- name: Execute Unit Tests
run: python -m unittest discover
shell: bash
- name: Check Version Updated in setup.py Before Merging
# if: ${{ github.event_name == 'pull_request' }}
run: |
test -n "$(git diff -G version= origin/master HEAD -- setup.py)" || \
exit "Package version in setup.py must be incremented before merge."
shell: bash
15 changes: 15 additions & 0 deletions .github/workflows/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Set Global Environment Variables

on:
workflow_call:
outputs:
package_name:
value: 'wavefront_sdk'
requirements:
value: 'Deprecated requests tdigest'

jobs:
debug:
runs-on: ubuntu-latest
steps:
- run: echo "This job is supposed to set environment variables for others."
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Linters & Tests

on:
push:
pull_request:
types:
- opened
- reopened
workflow_call:
inputs:
env_yml:
default: ./.github/workflows/env.yml
type: string

jobs:
setenv:
uses: ./.github/workflows/env.yml
execute:
name: Check Code & Run Tests
needs: setenv
strategy:
fail-fast: false
matrix:
# TODO: Enable Windows
# https://jira.eng.vmware.com/browse/MONIT-30833
os: [macos-latest, ubuntu-latest] # , windows-latest]
python_version: ['3.7', '3.8', '3.9', '3.10']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/lint_n_test
with:
python_version: ${{ matrix.python_version }}
input_pkg_name: ${{ needs.setenv.outputs.package_name }}
extra_packages: ${{ needs.setenv.outputs.requirements }}
34 changes: 34 additions & 0 deletions .github/workflows/publish_on_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Upload Python Package Onto TestPyPI

on:
push:
branches:
- master
workflow_call:
inputs:
env_yml:
default: ./.github/workflows/env.yml
type: string

jobs:
setenv:
uses: ./.github/workflows/env.yml
execute:
name: Prepare and Publish Package
needs: setenv
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/lint_n_test
with:
input_pkg_name: ${{ needs.setenv.outputs.package_name }}
extra_packages: ${{ format('{0} build', needs.setenv.outputs.requirements) }}
- name: Build Package
run: python -m build
- name: Publish Package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
34 changes: 34 additions & 0 deletions .github/workflows/publish_on_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish the Package onto PyPI

on:
release:
types:
- published
workflow_call:
inputs:
env_yml:
default: ./.github/workflows/env.yml
type: string

jobs:
setenv:
uses: ./.github/workflows/env.yml
execute:
name: Prepare and Publish Package
needs: setenv
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/lint_n_test
with:
input_pkg_name: ${{ needs.setenv.outputs.package_name }}
extra_packages: ${{ format('{0} build', needs.setenv.outputs.requirements) }}
- name: Build Package
run: python -m build
- name: Publish Package on PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
42 changes: 0 additions & 42 deletions .github/workflows/python-build.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/python-release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setuptools.setup(
name='wavefront-sdk-python',
version='1.8.8', # The version number. Update with each pull request.
version='1.8.9', # The version number. Update with each pull request.
author='Wavefront by VMware',
url='https://github.com/wavefrontHQ/wavefront-sdk-python',
license='Apache-2.0',
Expand Down

0 comments on commit c74aebf

Please sign in to comment.