Skip to content

Commit

Permalink
Merge pull request #222 from zowe/feat/add-secrets-sdk
Browse files Browse the repository at this point in the history
Add Secrets SDK with Rust keyring bindings
  • Loading branch information
zFernand0 authored Nov 14, 2023
2 parents 05aa573 + f21170e commit 95e819f
Show file tree
Hide file tree
Showing 19 changed files with 1,339 additions and 289 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/dev-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Zowe SDK Release

on:
pull_request_target:
types:
- closed
branches:
- main

jobs:
release:
if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release-dev') }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: main
token: ${{ secrets.ZOWE_ROBOT_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Increment dev version
id: update-version
shell: python
run: |
import sys
sys.path.append("src")
from _version import __version__
prerelease_tag = "dev"
tag_end_index = __version__.index(prerelease_tag) + len(prerelease_tag)
new_version = __version__[:tag_end_index] + str(int(__version__[tag_end_index:]) + 1)
with open("src/_version.py", 'w') as f:
f.write("__version__ = \"" + new_version + "\"\n")
print("::set-output name=version::" + new_version)
print("::set-output name=cargo-version::" + "-".join(new_version.rsplit(".", 1)))
- name: Increment dev version (cargo)
run: cargo install cargo-edit && cargo set-version ${{ steps.update-version.outputs.cargo-version }}
working-directory: src/secrets

- name: Build dist wheels
run: bash build.sh

- name: Commit version update
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: "Bump version to ${{ steps.update-version.outputs.version }} [ci skip]"
commit_options: "--signoff"
commit_user_name: ${{ secrets.ZOWE_ROBOT_USER }}
commit_user_email: ${{ secrets.ZOWE_ROBOT_EMAIL }}
file_pattern: "src/_version.py src/secrets/Cargo.*"
tagging_message: v${{ steps.update-version.outputs.version }}

- name: Publish packages to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_ROBOT_TOKEN }}
69 changes: 0 additions & 69 deletions .github/workflows/dev-release.yaml.old

This file was deleted.

66 changes: 33 additions & 33 deletions .github/workflows/sdk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,41 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 ./src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
coverage run -m pytest ./tests/unit
- name: Generate a coverage xml file
run: |
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ matrix.python-version == '3.11' }}
with:
directory: ./
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 ./src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
coverage run -m pytest ./tests/unit
- name: Generate a coverage xml file
run: |
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ matrix.python-version == '3.12' }}
with:
directory: ./
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
144 changes: 144 additions & 0 deletions .github/workflows/secrets-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# This file is autogenerated by maturin v1.3.1
# To update, run
#
# maturin generate-ci github
#
name: Secrets SDK CI

on:
push:
paths:
- "src/secrets/**"
- ".github/workflows/secrets-sdk.yml"
pull_request:
paths:
- "src/secrets/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set environment variables
run: src/secrets/scripts/configure-cross.sh ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --skip-auditwheel
sccache: "true"
manylinux: auto
docker-options: -e PKG_CONFIG_SYSROOT_DIR -e PKG_CONFIG_PATH
working-directory: src/secrets
before-script-linux: |
if command -v yum &> /dev/null; then
yum update && yum install -y libsecret-devel.${{ env.CROSS_DEB_ARCH }} pkgconfig
else
dpkg --add-architecture ${{ env.CROSS_DEB_ARCH }}
sed -i "s/deb /deb [arch=amd64] /g" /etc/apt/sources.list
echo "deb [arch=${{ env.CROSS_DEB_ARCH }}] http://ports.ubuntu.com/ubuntu-ports/ jammy main universe" >> /etc/apt/sources.list
echo "deb [arch=${{ env.CROSS_DEB_ARCH }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main universe" >> /etc/apt/sources.list
apt-get update && apt-get install -y libsecret-1-dev:${{ env.CROSS_DEB_ARCH }} pkg-config
fi
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: src/secrets/dist

windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86, aarch64]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
if: ${{ matrix.target != 'aarch64' }}
with:
python-version: "3.10"
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: "true"
working-directory: src/secrets
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: src/secrets/dist

macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: "true"
working-directory: src/secrets
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: src/secrets/dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: src/secrets
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: src/secrets/dist

release:
name: Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_ROBOT_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing *
working-directory: src/secrets
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"rust-analyzer.linkedProjects": ["./src/secrets/Cargo.toml"],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
Expand Down
23 changes: 14 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

## Recent Changes

- Bug: Fixed profile merge order to match Node.js SDK
- Feature: Added method to load profile properties from environment variables
- Bugfix: Fixed exception handling in session.py [#213] (https://github.com/zowe/zowe-client-python-sdk/issues/213)
- Feature: Added a CredentialManager class to securely retrieve values from credentials and manage multiple credential entries on Windows [#134](https://github.com/zowe/zowe-client-python-sdk/issues/134)
- Feature: Added method to Save profile properties to zowe.config.json file [#73](https://github.com/zowe/zowe-client-python-sdk/issues/73)
- Feature: Added method to Save secure profile properties to vault [#72](https://github.com/zowe/zowe-client-python-sdk/issues/72)
- Bugfix: Fixed issue for datasets and jobs with special characters in URL [#211] (https://github.com/zowe/zowe-client-python-sdk/issues/211)
- Feature: Added method to load profile properties from environment variables
- BugFix: Validation of zowe.config.json file matching the schema [#192](https://github.com/zowe/zowe-client-python-sdk/issues/192)
### Enhancements

- Added method to save secure profile properties to vault [#72](https://github.com/zowe/zowe-client-python-sdk/issues/72)
- Added method to save profile properties to zowe.config.json file [#73](https://github.com/zowe/zowe-client-python-sdk/issues/73)
- Added CredentialManager class to securely retrieve values from credentials and manage multiple credential entries on Windows [#134](https://github.com/zowe/zowe-client-python-sdk/issues/134)
- Added method to load profile properties from environment variables [#136](https://github.com/zowe/zowe-client-python-sdk/issues/136)
- Added validation of zowe.config.json file matching the schema [#192](https://github.com/zowe/zowe-client-python-sdk/issues/192)
- Added Secrets SDK for storing client secrets in OS keyring [#208](https://github.com/zowe/zowe-client-python-sdk/issues/208)

### Bug Fixes

- Fixed profile merge order to match Node.js SDK [#190](https://github.com/zowe/zowe-client-python-sdk/issues/190)
- Fixed issue for datasets and jobs with special characters in URL [#211](https://github.com/zowe/zowe-client-python-sdk/issues/211)
- Fixed exception handling in session.py [#213](https://github.com/zowe/zowe-client-python-sdk/issues/213)
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sphinx_rtd_theme>=0.5.1
sphinxcontrib-spelling==5.4.0
sphinxcontrib-spelling==8.0.0
-e ./src/core
-e ./src/zos_console
-e ./src/zos_files
Expand Down
Loading

0 comments on commit 95e819f

Please sign in to comment.