Skip to content

Commit

Permalink
Update CI [0.2.x] (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg authored Aug 4, 2021
1 parent a2e2f38 commit e14b432
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 81 deletions.
131 changes: 123 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,143 @@ on:
push:
branches:
- master
- development
- '[0-9]+.[0-9]+.x'
pull_request:
branches:
- master
- development
- '[0-9]+.[0-9]+.x'

jobs:
test:
env:
NUCLIO_LABEL: 1.5.22

jobs:
unit:
name: Unit test (Python ${{ matrix.python_version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.6, 3.7, 3.8]
python_version: [ 2.7, 3.6 ]
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Dump runner context
run: echo "$RUNNER_CONTEXT"
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}

- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1

- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.python_version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
make install_pipenv PIPENV_PYTHON_VERSION=${{ matrix.python-version }}
make install_pipenv PIPENV_PYTHON_VERSION=${{ matrix.python_version }}
- name: Lint
run: make lint

- name: Test
run: make test

# integration:
# name: Integration test (Python ${{ matrix.python_version }})
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# python_version: [ 2.7, 3.6 ]
# steps:
# - name: Dump github context
# run: echo "$GITHUB_CONTEXT"
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
#
# - name: Dump runner context
# run: echo "$RUNNER_CONTEXT"
# env:
# RUNNER_CONTEXT: ${{ toJson(runner) }}
#
# - name: Clone Nuclio sdk py
# uses: actions/checkout@v2
# with:
# path: nuclio-sdk-py
#
# - name: Clone Nuclio
# uses: actions/checkout@v2
# with:
# repository: nuclio/nuclio
# ref: development
# path: nuclio
# token: ${{ github.token }}
#
# - uses: actions/setup-go@v2
# with:
# go-version: "^1.14.0"
#
# - uses: actions/cache@v2
# with:
# path: ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/nuclio/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-
#
# - name: Set runtime env
# run: |
# function_name=$(echo "sdk-py-func-${{ matrix.python_version }}" | tr '.' '-')
#
# # if pull request, else push
# if [ "${{ github.event_name }}" == "pull_request" ]; then\
# actor=${{ github.actor }};\
# branch=${{ github.head_ref }};\
# else\
# actor=${{ github.repository_owner }};\
# branch=${GITHUB_REF#refs/heads/};\
# fi
#
# echo "FUNCTION_NAME=$function_name" >> $GITHUB_ENV
# echo "ACTOR=$actor" >> $GITHUB_ENV
# echo "BRANCH=$branch" >> $GITHUB_ENV
#
# - name: Build nuctl
# run: make nuctl-bin
# working-directory: nuclio
#
# - name: Install nuctl
# run: |
#
# # install nuctl
# cp nuctl-$NUCLIO_LABEL-linux-amd64 nuctl
# sudo -EH install nuctl /usr/local/bin
#
# # print version for sanity
# nuctl version
# working-directory: nuclio
#
# - name: Deploy function
# run: |
# nuctl deploy $FUNCTION_NAME \
# --verbose \
# --runtime python:${{ matrix.python_version }} \
# --handler main:handler \
# --build-command "@nuclio.postCopy" \
# --build-command "pip install git+https://github.com/$ACTOR/nuclio-sdk-py.git@$BRANCH" \
# --path $(pwd)/hack/ci_assets/function/main.py
# working-directory: nuclio-sdk-py
# env:
# NUCLIO_DASHBOARD_DEFAULT_FUNCTION_MOUNT_MODE: volume
#
# - name: Invoke function
# run: |
# nuctl invoke $FUNCTION_NAME
#
# - name: Print function container logs
# run: |
# docker logs nuclio-nuclio-$FUNCTION_NAME
69 changes: 69 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"

env:
PIPENV_PYTHON_VERSION: 3.7

jobs:
build-and-release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Dump runner context
run: echo "$RUNNER_CONTEXT"
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}

- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PIPENV_PYTHON_VERSION }}

- name: Set envs
run: |
VERSION_TAG=${GITHUB_REF#refs/tags/}
RC_RELEASE=false
if echo $VERSION_TAG | grep -qE ".*-rc[0-9]+"; then\
RC_RELEASE=true;\
fi
echo "NUCLIO_SDK_PY_VERSION=$VERSION_TAG" >> $GITHUB_ENV
echo "RC_RELEASE=$RC_RELEASE" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
make install_pipenv
- name: Build
run: |
make build
- name: Release Test-PyPI
uses: pypa/[email protected]
if: env.RC_RELEASE == 'true'
with:
user: __token__
skip_existing: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true

- name: Release PyPI
uses: pypa/[email protected]
if: env.RC_RELEASE == 'false'
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ dist/
nuclio_sdk.egg-info/
*.pyc
.idea
.github/act
VERSION
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
PIPENV_PYTHON_VERSION ?= 3.7

PIPENV_PYTHON_VERSION ?= 3.7
NUCLIO_SDK_PY_VERSION ?= $(shell git describe --tags --abbrev=0)

.PHONY: all
all:
$(error please pick a target)

.PHONY: upload
upload: clean build lint test
upload: ensure-version clean build lint test
python -m pipenv run upload

.PHONY: build
build:
build: ensure-version
python -m pipenv run build

.PHONY: clean
clean:
rm -rf dist build nuclio_sdk.egg-info
@rm -rf VERSION dist build nuclio_sdk.egg-info

.PHONY: clean_pyc
clean_pyc:
Expand All @@ -34,11 +34,15 @@ lint:
python -m pipenv run lint

.PHONY: install_pipenv
install_pipenv:
install_pipenv: ensure-version
python -m pip install --user pipenv
python -m pipenv --python ${PIPENV_PYTHON_VERSION}
ifeq ($(PIPENV_PYTHON_VERSION), 2.7)
python -m pipenv install --ignore-pipfile --skip-lock --requirements requirements.py2.txt
else
python -m pipenv install --dev
endif

.PHONY: ensure-version
ensure-version:
@echo $(NUCLIO_SDK_PY_VERSION) | tee VERSION
6 changes: 4 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ nuclio-sdk = {editable = true,path = "."}
[dev-packages]
flake8 = "*"
twine = "*"
bleach = "==3.1.4"
bleach = "==3.3.0"

[scripts]
build = "python setup.py sdist bdist_wheel"
build = "python -m build --sdist --wheel --outdir dist/"
test = "python -m unittest discover -s nuclio_sdk/test -p 'test_*.py' -v"
upload = "twine upload dist/*"
upload-test = "twine upload --repository testpypi dist/*"
flake8 = "flake8 nuclio_sdk"
lint = "flake8 nuclio_sdk"
Loading

0 comments on commit e14b432

Please sign in to comment.