Skip to content

Commit 1292076

Browse files
authored
ci: 9259 gha (#786)
* ci: gha implement GHA * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix
1 parent d006937 commit 1292076

File tree

4 files changed

+162
-1
lines changed

4 files changed

+162
-1
lines changed

.github/workflows/build-test.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support documentation.
4+
# This workflow will do a clean install of python dependencies, build the source code and run tests across different versions of python
5+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
6+
7+
name: Build and Test
8+
9+
on:
10+
push:
11+
branches: [ '**' ]
12+
pull_request:
13+
branches: [ master ]
14+
15+
# Allows you to run this workflow manually from the Actions tab
16+
workflow_dispatch:
17+
18+
jobs:
19+
build_test:
20+
name: Build and Test on Python ${{ matrix.python-version }} and ${{ matrix.os }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
python-version: ['3.5', '3.6', '3.7', '3.8']
25+
os: [ubuntu-latest]
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Set up Python
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Install dependencies
34+
run: |
35+
pip3 install -r requirements.txt
36+
pip3 install -r requirements-dev.txt
37+
pip3 install --editable .
38+
- name: Execute Python unit tests for code coverage
39+
if: matrix.python-version == '3.5'
40+
run: |
41+
pip3 install -U python-dotenv
42+
py.test --reruns 3 --cov=ibm_watson
43+
- name: Upload coverage to Codecov
44+
if: matrix.python-version == '3.5'
45+
uses: codecov/codecov-action@v1
46+
with:
47+
name: py${{ matrix.python-version }}-${{ matrix.os }}
48+
- name: Execute Python unit tests
49+
if: matrix.python-version != '3.5'
50+
run: |
51+
pip3 install -U python-dotenv
52+
py.test

.github/workflows/deploy.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support documentation.
4+
# This workflow will download a prebuilt Python version, install dependencies, build and deploy/publish a new release
5+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
6+
7+
name: Deploy and Publish
8+
9+
on:
10+
workflow_run:
11+
workflows: ["Build and Test"]
12+
branches: [ master ]
13+
types:
14+
- completed
15+
16+
# Allows you to run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
19+
jobs:
20+
deploy:
21+
if: "!contains(github.event.head_commit.message, 'skip ci')"
22+
name: Deploy and Publish
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
with:
28+
persist-credentials: false
29+
- name: Set up Python
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: '3.8'
33+
- name: Setup Node
34+
uses: actions/setup-node@v1
35+
with:
36+
node-version: 12
37+
- name: Install dependencies
38+
run: |
39+
pip3 install -r requirements.txt
40+
pip3 install -r requirements-dev.txt
41+
pip3 install --editable .
42+
- name: Install Semantic Release dependencies
43+
run: |
44+
sudo apt-get install bumpversion
45+
npm install -g semantic-release
46+
npm install -g @semantic-release/changelog
47+
npm install -g @semantic-release/exec
48+
npm install -g @semantic-release/git
49+
npm install -g @semantic-release/github
50+
npm install -g @semantic-release/commit-analyzer
51+
npm install -g @semantic-release/release-notes-generator
52+
- name: Publish js docs
53+
if: github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags')
54+
env:
55+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
56+
GHA_BRANCH: ${{ github.ref }} # non PR only need to get last part
57+
GHA_COMMIT: ${{ github.sha }}
58+
run: |
59+
sudo apt-get install python3-sphinx
60+
docs/publish_gha.sh
61+
- name: Publish to Git Releases and Tags
62+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
65+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
66+
run: npx semantic-release # --dry-run
67+
- name: Publish a Python distribution to PyPI # must have built dist before
68+
if: github.event.workflow_run.conclusion == 'success' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
69+
uses: pypa/gh-action-pypi-publish@master
70+
with:
71+
password: ${{ secrets.PYPI_PASSWORD }}
72+
user: watson-devex
73+
repository_url: https://upload.pypi.org/legacy
74+
verbose: false

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Watson Developer Cloud Python SDK
22

3-
[![Build Status](https://travis-ci.org/watson-developer-cloud/python-sdk.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/python-sdk)
3+
[![Build and Test](https://github.com/watson-developer-cloud/python-sdk/workflows/Build%20and%20Test/badge.svg?branch=master)](https://github.com/watson-developer-cloud/python-sdk/actions?query=workflow%3A"Build+and+Test")
4+
[![Deploy and Publish](https://github.com/watson-developer-cloud/python-sdk/workflows/Deploy%20and%20Publish/badge.svg?branch=master)](https://github.com/watson-developer-cloud/python-sdk/actions?query=workflow%3A%22Deploy+and+Publish%22)
45
[![Slack](https://wdc-slack-inviter.mybluemix.net/badge.svg)](https://wdc-slack-inviter.mybluemix.net)
56
[![Latest Stable Version](https://img.shields.io/pypi/v/ibm-watson.svg)](https://pypi.python.org/pypi/ibm-watson)
67
[![CLA assistant](https://cla-assistant.io/readme/badge/watson-developer-cloud/python-sdk)](https://cla-assistant.io/watson-developer-cloud/python-sdk)
78

9+
## Deprecated builds
10+
[![Build Status](https://travis-ci.org/watson-developer-cloud/python-sdk.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/python-sdk)
11+
812
Python client library to quickly get started with the various [Watson APIs][wdc] services.
913

1014
<details>

docs/publish_gha.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# checking the build/job numbers allows it to only
3+
# publish once even though we test against multiple python versions
4+
5+
[[ -z "$GHA_BRANCH" ]] && { echo "GHA_BRANCH cannot be null" ; exit 1; }
6+
[[ -z "$GH_TOKEN" ]] && { echo "GH_TOKEN cannot be null" ; exit 1; }
7+
8+
cd $(dirname $0)
9+
pwd
10+
11+
echo "Create Docs"
12+
make document
13+
echo "Publishing Docs..."
14+
15+
git config --global user.email "watdevex@us.ibm.com"
16+
git config --global user.name "watdevex"
17+
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/python-sdk.git gh-pages > /dev/null
18+
19+
pushd gh-pages
20+
# on tagged builds, $GHA_BRANCH is the tag (e.g. v1.2.3), otherwise it's the branch name (e.g. master)
21+
rm -rf $GHA_BRANCH
22+
cp -Rf ../_build/html/ $GHA_BRANCH
23+
../generate_index_html.sh > index.html
24+
25+
git add -f .
26+
git commit -m "Docs for $GHA_BRANCH ($GHA_COMMIT)"
27+
git push -fq origin gh-pages > /dev/null
28+
popd
29+
30+
echo -e "Published Docs for $GHA_BRANCH to gh-pages.\n"
31+

0 commit comments

Comments
 (0)