Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft CI/CD #2

Merged
merged 16 commits into from
May 8, 2024
27 changes: 27 additions & 0 deletions .github/actions/bumpversion/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "bump version"
description: "bump our version in the repo and push the change"

runs:
using: "composite"
steps:
- name: install bumpversion
run: |
pip install bump2version
shell: bash
- name: configure git
run: |
git config --global user.email "[email protected]"
git config --global user.name "qcog_bot"
shell: bash
- name: bump the version
run: |
bump2version patch --allow-dirty
shell: bash
- name: push to repo
run: |
mkdir -p ~/.ssh
echo "${QCOG_DEPLOY_PUSH_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git push [email protected]:${GITHUB_REPOSITORY}
git push --tags [email protected]:${GITHUB_REPOSITORY}
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/python-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "mkl-python repo"
description: "install a mkl dependent python repo"

runs:
using: "composite"
steps:
- name: Python dependencies
run: |
python -m pip cache purge
python -m pip install --upgrade pip
python -m pip install .
shell: bash
- name: Compile our extensions locally to allow for testing
run: |
python -m build .
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/setup_and_lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "lint"
description: "setup python 3.10 and execute flake8 linting"

runs:
using: "composite"
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10.4'
- name: install linters
run: pip install flake8
shell: bash
- name: run flake8
run: flake8 qcog_python_client
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "pytest"
description: "run pytest and mypy, we run mypy after all requirements are installed"

runs:
using: "composite"
steps:
- name: install flake 8 and pytest
JeffBerger marked this conversation as resolved.
Show resolved Hide resolved
run: pip install pytest mypy
jamesETsmith marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
- name: run mypy
run: mypy qcog_python_client
shell: bash
- name: Test with pytest
run: |
echo pytest tests
shell: bash
28 changes: 28 additions & 0 deletions .github/actions/upload-wheel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "wheel upload to gemfury"
description: "we build our wheel here and upload it to gemfury"

runs:
using: "composite"
steps:
- name: echo the version suffix
run: echo "VERSION SUFFIX = ${VERSION_SUFFIX}"
shell: bash
- name: build wheel
run: |
python -m pip install build wheel
python -m build .
shell: bash
- name: install gemfury CLI
run: |
echo "deb [trusted=yes] https://apt.fury.io/cli/ * *" | sudo tee /etc/apt/sources.list.d/fury-cli.list
sudo apt-get update
sudo apt-get install fury-cli
shell: bash
- name: push wheel to gemfury
run: |
python -m pip install wheel-filename
sudo apt install jq
export PACKAGE_VERSION=`wheel-filename dist/$(ls dist -1) | jq -r '.version'`
fury yank qcog_python_client -v $PACKAGE_VERSION --account qognitive --api-token ${GEMFURY_MASTER_TOKEN} || echo "No existing package to remove, moving on to push."
fury push dist/$(ls dist -1) --api-token ${GEMFURY_MASTER_TOKEN}
shell: bash
30 changes: 30 additions & 0 deletions .github/workflows/all_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on:
push:
branches-ignore:
- develop
- master

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
build-custom-branch:
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v4
- name: Setup python and Lint Code
uses: ./.github/actions/setup_and_lint
- name: Build and install our repo
uses: ./.github/actions/python-build
- name: Run Pytest
uses: ./.github/actions/test
- name: Push our build to gemfury
uses: ./.github/actions/upload-wheel
env:
VERSION_SUFFIX: ${{ github.ref_name }}
GEMFURY_TOKEN: ${{ secrets.GEMFURY_PUSH_TOKEN }}
GEMFURY_MASTER_TOKEN: ${{ secrets.GEMFURY_FULL_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
JeffBerger marked this conversation as resolved.
Show resolved Hide resolved

31 changes: 31 additions & 0 deletions .github/workflows/merge_to_develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
branches:
- develop

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
bump-version-and-upload:
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v4
- name: Setup python and Lint Code
uses: ./.github/actions/setup_and_lint
- name: Build and install our repo
uses: ./.github/actions/python-build
- name: Run Pytest
uses: ./.github/actions/test
- name: Bump version
uses: ./.github/actions/bumpversion
env:
QCOG_DEPLOY_PUSH_KEY: ${{ secrets.QCOG_DEPLOY_PUSH_KEY }}
- name: Push our build to gemfury
uses: ./.github/actions/upload-wheel
env:
GEMFURY_TOKEN: ${{ secrets.GEMFURY_PUSH_TOKEN }}
GEMFURY_MASTER_TOKEN: ${{ secrets.GEMFURY_FULL_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
Loading