Skip to content

Commit c74aebf

Browse files
authored
Merge pull request #97 from wavefrontHQ/austinov/update_actions
Update GitHub Actions Workflows.
2 parents e409750 + 760263e commit c74aebf

File tree

8 files changed

+170
-76
lines changed

8 files changed

+170
-76
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Lint & Test
2+
3+
inputs:
4+
python_version:
5+
default: '3.10'
6+
type: string
7+
input_pkg_name:
8+
required: true
9+
type: string
10+
extra_packages:
11+
type: string
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Set up Python ${{ inputs.python_version }}
17+
uses: actions/setup-python@v3
18+
with:
19+
python-version: ${{ inputs.python_version }}
20+
- name: Install Latest pip and setuptools
21+
run: python -m pip install -U pip setuptools wheel
22+
shell: bash
23+
- name: Install Linters
24+
run: |
25+
python -m pip install -U flake8 flake8-colors
26+
python -m pip install -U flake8-import-order pep8-naming
27+
python -m pip install -U pydocstyle pylint
28+
shell: bash
29+
- name: Install Extra Dependencies ${{ inputs.extra_packages }}
30+
run: python -m pip install -U ${{ inputs.extra_packages }}
31+
shell: bash
32+
- name: Run Flake8 Checks
33+
run: python -m flake8
34+
shell: bash
35+
- name: Run PyLint Checks on ${{ inputs.input_pkg_name }}
36+
run: python -m pylint -d duplicate-code ${{ inputs.input_pkg_name }}
37+
shell: bash
38+
- name: PyDocStyle
39+
run: python -m pydocstyle
40+
shell: bash
41+
- name: Execute Unit Tests
42+
run: python -m unittest discover
43+
shell: bash
44+
- name: Check Version Updated in setup.py Before Merging
45+
# if: ${{ github.event_name == 'pull_request' }}
46+
run: |
47+
test -n "$(git diff -G version= origin/master HEAD -- setup.py)" || \
48+
exit "Package version in setup.py must be incremented before merge."
49+
shell: bash

.github/workflows/env.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Set Global Environment Variables
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
package_name:
7+
value: 'wavefront_sdk'
8+
requirements:
9+
value: 'Deprecated requests tdigest'
10+
11+
jobs:
12+
debug:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- run: echo "This job is supposed to set environment variables for others."

.github/workflows/main.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Linters & Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
types:
7+
- opened
8+
- reopened
9+
workflow_call:
10+
inputs:
11+
env_yml:
12+
default: ./.github/workflows/env.yml
13+
type: string
14+
15+
jobs:
16+
setenv:
17+
uses: ./.github/workflows/env.yml
18+
execute:
19+
name: Check Code & Run Tests
20+
needs: setenv
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# TODO: Enable Windows
25+
# https://jira.eng.vmware.com/browse/MONIT-30833
26+
os: [macos-latest, ubuntu-latest] # , windows-latest]
27+
python_version: ['3.7', '3.8', '3.9', '3.10']
28+
runs-on: ${{ matrix.os }}
29+
steps:
30+
- uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0
33+
- uses: ./.github/actions/lint_n_test
34+
with:
35+
python_version: ${{ matrix.python_version }}
36+
input_pkg_name: ${{ needs.setenv.outputs.package_name }}
37+
extra_packages: ${{ needs.setenv.outputs.requirements }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Upload Python Package Onto TestPyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_call:
8+
inputs:
9+
env_yml:
10+
default: ./.github/workflows/env.yml
11+
type: string
12+
13+
jobs:
14+
setenv:
15+
uses: ./.github/workflows/env.yml
16+
execute:
17+
name: Prepare and Publish Package
18+
needs: setenv
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
- uses: ./.github/actions/lint_n_test
25+
with:
26+
input_pkg_name: ${{ needs.setenv.outputs.package_name }}
27+
extra_packages: ${{ format('{0} build', needs.setenv.outputs.requirements) }}
28+
- name: Build Package
29+
run: python -m build
30+
- name: Publish Package to TestPyPI
31+
uses: pypa/gh-action-pypi-publish@release/v1
32+
with:
33+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
34+
repository_url: https://test.pypi.org/legacy/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish the Package onto PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_call:
8+
inputs:
9+
env_yml:
10+
default: ./.github/workflows/env.yml
11+
type: string
12+
13+
jobs:
14+
setenv:
15+
uses: ./.github/workflows/env.yml
16+
execute:
17+
name: Prepare and Publish Package
18+
needs: setenv
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
- uses: ./.github/actions/lint_n_test
25+
with:
26+
input_pkg_name: ${{ needs.setenv.outputs.package_name }}
27+
extra_packages: ${{ format('{0} build', needs.setenv.outputs.requirements) }}
28+
- name: Build Package
29+
run: python -m build
30+
- name: Publish Package on PyPI
31+
if: startsWith(github.ref, 'refs/tags')
32+
uses: pypa/gh-action-pypi-publish@release/v1
33+
with:
34+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/python-build.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/python-release.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

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

0 commit comments

Comments
 (0)