[Avg. reading time: 4 minutes]
CI YAML
CI/CD is not just a tool or a YAML file. It is a system of interconnected components working together to ensure code quality.
checkout → install → test → notify
- CI is not about automation alone.
- It is about reducing the time between writing code and discovering problems.
- Faster feedback = better code quality
name: Build and Test
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test Calculator App
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
python -m unittest test_calc.py -v
- name: Send Discord failure notification
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0.4.0
with:
args: >
@here The Calculator App integration test failed for
${{ github.repository }}.
Check run ${{ github.run_id }} on GitHub for details.
- name: Send Discord success notification
if: success()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0.4.0
with:
args: >
The Calculator App for ${{ github.repository }}
passed successfully.
Run ID: ${{ github.run_id }}