Overview
The current setup for CI/CD in the project leverages GitHub Actions for automation tasks such as building, testing, and deploying applications. Below is a detailed step-by-step guide for engaging with the CI/CD workflow using various components of the project.
Step 1: GitHub Actions Configuration
The primary CI/CD workflows are defined in YAML files located in the .github/workflows/
directory. Key files include:
- build-balena-disk-image.yaml: This workflow is responsible for building disk images for the Balena platform.
Example snippet:
name: Build Balena Disk Images
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to be used for the release'
required: true
type: string
commit:
description: 'Commit or branch name'
required: false
type: string
default: 'master'
jobs:
balena-build-images:
strategy:
matrix:
board: ['pi1', 'pi2', 'pi3', 'pi4']
Step 2: Running Tests
Testing in the CI/CD pipeline is essential. This is facilitated by the docker-test.yaml
workflow, which can be configured to spin up Docker containers to run tests.
Example snippet:
- name: Stop the test container
run: |
docker compose -f docker-compose.test.yml down
Step 3: Linting Python Code
The project uses flake8
for linting the Python codebase. Running the linter can be part of both the CI/CD pipeline as well as local development.
To run the linter on GitHub Actions, the following command can be defined in the workflow:
Example snippet:
- name: Run Linter
run: |
flake8 .
Locally, act
can be used to run GitHub Actions commands to test the CI pipeline:
Command to run:
$ act -W .github/workflows/python-lint.yaml
Step 4: Deploying the Application
Deployment tasks can be automated via workflows like deploy-website.yaml
, which builds and deploys the website.
Example deployment steps:
- name: Build website
run: |
cd website
mkdir -p _site
python bin/build-pi-imager-json.py > _site/rpi-imager.json
cp -rf assets _site/
cp index.html _site/
The deployment to GitHub Pages can be handled using:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
Step 5: Managing Environment Variables
Environment variables can assist in managing configurations for various stages in the pipeline. This is particularly important for sensitive data such as API tokens.
Example:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Step 6: Build Multi-Architecture Support
The CI/CD system supports building images for various Raspberry Pi boards through matrix strategies, allowing workflow efficiency.
Example:
- name: Get base board
run: |
if [ "${{ matrix.board }}" == 'pi1' ]; then
echo "BALENA_IMAGE=raspberry-pi" >> $GITHUB_ENV
elif [ "${{ matrix.board }}" == 'pi2' ]; then
echo "BALENA_IMAGE=raspberry-pi2" >> $GITHUB_ENV
fi
Conclusion
The CI/CD workflow of the project is robust and leverages various tools like GitHub Actions to manage build, test, and deploy phases efficiently. This integration allows for an automated and streamlined process when working with the screenly/anthias
project.
Sources: