Skip to content

πŸ“ docs: cicd flows #18

πŸ“ docs: cicd flows

πŸ“ docs: cicd flows #18

Workflow file for this run

name: "CI/CD Pipeline (Push: dev-*)"
on:
push:
branches:
- "dev-*"
paths-ignore:
- "docs/**"
permissions:
contents: read
actions: read
jobs:
check-pr:
runs-on: ubuntu-latest
outputs:
has-pr: ${{ steps.check.outputs.has-pr }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for open PR
id: check
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
PR=$(gh pr list --state open --head "${{ github.ref_name }}" --json number -q '.[0].number')
if [ -z "$PR" ]; then
echo "has-pr=false" >> $GITHUB_OUTPUT
else
echo "has-pr=true" >> $GITHUB_OUTPUT
fi
build:
runs-on: ubuntu-latest
needs: [check-pr]
if: needs.check-pr.outputs.has-pr == 'false'
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: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install .'[all]'
- 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()
lint:
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: Lint code
run: |
source venv/bin/activate
pip install -r requirements/requirements-style.txt
black --check .
flake8 zerohertzLib
pylint -r n zerohertzLib
- 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()