Skip to content

Merge pull request #319 from Zerohertz/chore-v1.1.5 #5

Merge pull request #319 from Zerohertz/chore-v1.1.5

Merge pull request #319 from Zerohertz/chore-v1.1.5 #5

name: "CI/CD Pipeline (Push: master)"
on:
push:
branches:
- master
permissions:
contents: write
actions: read
jobs:
build:
runs-on: ubuntu-latest
# [`master` Push] "Merge pull request*/dev-" (Except "Merge pull request*/chore-")
if: |
startsWith(github.event.head_commit.message, 'Merge pull request') &&
contains(github.event.head_commit.message, 'dev-') &&
!contains(github.event.head_commit.message, 'chore-')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Cache virtualenv
uses: actions/cache@v4
with:
path: venv
key: ${{ runner.os }}-python-venv
restore-keys: |
${{ runner.os }}-python-venv-
- name: Install build tools
run: |
python -m venv venv
source venv/bin/activate
pip install build
python -m build .
pip install .'[all]'
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: dist
- name: Slack webhook
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: zerohertzLib
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
if_mention: failure,cancelled
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CHECK }}
if: always()
test:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Cache virtualenv
uses: actions/cache@v4
with:
path: venv
key: ${{ runner.os }}-python-venv
restore-keys: |
${{ runner.os }}-python-venv-
- name: Run tests
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
run: |
source venv/bin/activate
sudo apt update
sudo apt install python3-opencv -y
pip install pytest pytest-cov
pytest --cov --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
flags: python3.11
token: ${{ secrets.CODECOV_TOKEN }}
if: always()
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: always()
- name: Slack webhook
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: zerohertzLib
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
if_mention: failure,cancelled
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CHECK }}
if: always()
# deploy-github:
# runs-on: ubuntu-latest
# needs: [build]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Tag and push
# env:
# GH_USERNAME: ${{ secrets.GH_USERNAME }}
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
# run: |
# VERSION=$(cat zerohertzLib/__init__.py | grep __version__ | sed 's/.*= "\(.*\)"/\1/')
# git config --global user.email "[email protected]"
# git config --global user.name "${GH_USERNAME}"
# git config --global credential.helper "!f() { echo username=${GH_USERNAME}; echo password=${GH_TOKEN}; }; f"
# git tag ${VERSION}
# git push origin ${VERSION}
#
# - name: Slack webhook
# uses: 8398a7/action-slack@v3
# with:
# status: ${{ job.status }}
# author_name: zerohertzLib
# fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
# if_mention: failure,cancelled
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CHECK }}
# if: always()
#
# deploy-pypi:
# runs-on: ubuntu-latest
# needs: [build]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: 3.11
#
# - name: Cache virtualenv
# uses: actions/cache@v4
# with:
# path: venv
# key: ${{ runner.os }}-python-venv
# restore-keys: |
# ${{ runner.os }}-python-venv-
#
# - name: Download build artifacts
# uses: actions/download-artifact@v4
# with:
# name: build-artifacts
# path: dist
#
# - name: Deploy to PyPI
# env:
# PYPI_USERNAME: ${{ secrets.GH_USERNAME }}
# PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
# run: |
# source venv/bin/activate
# pip install twine
# twine upload -u ${PYPI_USERNAME} -p ${PYPI_TOKEN} dist/*
#
# - name: Slack webhook
# uses: 8398a7/action-slack@v3
# with:
# status: ${{ job.status }}
# author_name: zerohertzLib
# fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
# if_mention: failure,cancelled
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CHECK }}
# if: always()