Skip to content

chore: ✨ new episode 🎙️ » 2024-10-31 #1688

chore: ✨ new episode 🎙️ » 2024-10-31

chore: ✨ new episode 🎙️ » 2024-10-31 #1688

Workflow file for this run

name: CI/CD
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
POETRY_VERSION: 1.8.3 # Make sure this matches the Dockerfile
on:
pull_request:
branches: ["main"]
paths-ignore: ["docs/**"]
push:
branches: ["main"]
paths-ignore: ["docs/**"]
tags:
- "v*"
jobs:
ruff:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- if: steps.poetry-cache.outputs.cache-hit != 'true'
name: Install Poetry and Dependencies
shell: bash
run: |
pip install --upgrade pip
pip install poetry==$POETRY_VERSION
python -m venv .venv
source .venv/bin/activate
poetry install --with dev
- name: ruff
shell: bash
run: |
source .venv/bin/activate
ruff check . --output-format=github
black:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- if: steps.poetry-cache.outputs.cache-hit != 'true'
name: Install Poetry and Dependencies
shell: bash
run: |
pip install --upgrade pip
pip install poetry==$POETRY_VERSION
python -m venv .venv
source .venv/bin/activate
poetry install --with dev
- name: black
shell: bash
run: |
source .venv/bin/activate
black . --check
stylelint:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- id: node-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-cache.outputs.cache-hit != 'true'
run: |
npm ci --no-optional --no-audit --progress=false
- name: Stylelint
run: |
npm run lint:style
eslint:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- id: node-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-cache.outputs.cache-hit != 'true'
run: |
npm ci --no-optional --no-audit --progress=false
- name: ESLint
run: |
npm run lint:js
prettier:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- id: node-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-cache.outputs.cache-hit != 'true'
run: |
npm ci --no-optional --no-audit --progress=false
- name: Prettier
run: |
npm run lint:format
shellcheck:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Install Dependencies
shell: bash
run: |
sudo apt install shellcheck -y
- name: Run shellcheck
shell: bash
run: |
echo "${{ github.ref }}"
bash -c 'shopt -s globstar; shellcheck ./*.sh;'
# Runs the python test suite on the VM
test:
runs-on: ubuntu-22.04
needs: [ruff, black, stylelint, eslint, prettier, shellcheck]
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: System Dependencies
shell: bash
run: |
sudo apt update --yes --quiet
export DEBIAN_FRONTEND=noninteractive
export TZ=Africa/Lusaka
sudo apt install --yes --quiet --no-install-recommends ffmpeg
sudo sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen
sudo locale-gen
sudo ln -fs /usr/share/zoneinfo/Africa/Lusaka /etc/localtime
sudo dpkg-reconfigure tzdata
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LC_ALL=en_US.UTF-8
- if: steps.poetry-cache.outputs.cache-hit != 'true'
name: Install Poetry and Dependencies
shell: bash
run: |
pip install --upgrade pip
pip install poetry==$POETRY_VERSION
python -m venv .venv
source .venv/bin/activate
poetry install --with dev
- name: Test with unittest
shell: bash
env:
OPENAI_API_KEY: "fake_key"
COHERE_API_KEY: "another_fake_key"
TOGETHER_API_KEY: "some_key"
AWS_ACCESS_KEY_ID: "1234567890"
AWS_SECRET_ACCESS_KEY: "fake_secret_key"
AWS_REGION_NAME: "any-region"
AWS_BUCKET_NAME: "bucket-name"
run: |
source .venv/bin/activate
invoke test
- name: "Upload coverage data"
uses: actions/upload-artifact@v4
with:
name: covdata
path: coverage.*
coverage:
name: Coverage
needs: test
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- if: steps.poetry-cache.outputs.cache-hit != 'true'
name: Install Poetry and Dependencies
shell: bash
run: |
pip install --upgrade pip
pip install poetry==$POETRY_VERSION
python -m venv .venv
source .venv/bin/activate
poetry install --with dev
- name: "Download coverage data"
uses: actions/download-artifact@v4
with:
name: covdata
- name: "Extract total coverage"
run: |
source .venv/bin/activate
export TOTAL=$(python -c "import json;print(round(json.load(open('coverage.json'))['totals']['percent_covered']))")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: "Create coverage badge"
if: (github.repository == 'engineervix/zed-news') && (github.ref == 'refs/heads/main')
uses: schneegans/dynamic-badges-action@v1.7.0
with:
# GIST_TOKEN is a GitHub personal access token with scope "gist".
auth: ${{ secrets.GIST_TOKEN }}
gistID: f4b1128b188c4e29722bc879e4ab6574
filename: covbadge.json
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}
# Runs the next steps on the VM
# Creates a GitHub Release when the lint & test jobs succeeds, and only on pushes to tags.
release:
needs: [ruff, black, stylelint, eslint, prettier, shellcheck, test]
permissions:
contents: write
if: needs.test.result == 'success' && startsWith( github.ref, 'refs/tags/v' )
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- if: steps.poetry-cache.outputs.cache-hit != 'true'
name: Install Poetry and Dependencies
shell: bash
run: |
pip install --upgrade pip
pip install poetry==$POETRY_VERSION
python -m venv .venv
source .venv/bin/activate
poetry install --with dev
- name: Get the version
id: get_version
run: |
echo "${{ github.ref }}"
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Generate Release Title
id: get_release_title
shell: bash
run: |
export TODAY="($(TZ=Africa/Lusaka date --iso))"
echo ::set-output name=RELEASE_NAME::"${{ steps.get_version.outputs.VERSION }} $TODAY"
- name: Extract Release Notes
# This creates a file LATEST_RELEASE_NOTES.md in the parent directory (../)
shell: bash
run: |
source .venv/bin/activate
invoke get-release-notes
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.get_release_title.outputs.RELEASE_NAME }}
body_path: ../LATEST_RELEASE_NOTES.md