diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a029345 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,49 @@ +name: Build Test + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Cache PlatformIO + uses: actions/cache@v4 + with: + path: | + ~/.platformio + .pio + key: ${{ runner.os }}-pio-${{ hashFiles('**/platformio.ini') }} + restore-keys: | + ${{ runner.os }}-pio- + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install platformio + + - name: Build firmware + run: pio run + working-directory: ${{ github.workspace }} + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + if: success() + with: + name: firmware + path: .pio/build/megaatmega2560/firmware.hex + retention-days: 7 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..867e063 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,25 @@ +name: Pre-commit Build Check + +on: + - pre-commit + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install platformio + + - name: Build firmware + run: pio run diff --git a/BUILD_TESTING.md b/BUILD_TESTING.md new file mode 100644 index 0000000..0a8c500 --- /dev/null +++ b/BUILD_TESTING.md @@ -0,0 +1,48 @@ +# LED Controller - Build Testing + +This repository includes automated build testing on every commit. + +## Automated Build Testing + +### GitHub Actions (CI/CD) + +- **Trigger**: Runs on every push and pull request to any branch +- **Location**: `.github/workflows/build.yml` +- **What it does**: + - Checks out code + - Sets up PlatformIO environment + - Builds firmware for `megaatmega2560` target + - Uploads firmware artifact (`.hex` file) + - Caches dependencies for faster builds + +### Local Pre-commit Hook + +- **Trigger**: Runs automatically before each git commit +- **Location**: `.git/hooks/pre-commit` +- **What it does**: + - Runs `pio run` to build the project + - Blocks commit if build fails + - Allows commit to proceed if build succeeds + +## Build Status + +Check the **Actions** tab on GitHub to see build status for all commits. + +## Manual Testing + +To manually test the build: + +```bash +pio run +``` + +To skip the pre-commit hook (not recommended): + +```bash +git commit --no-verify +``` + +## Requirements + +- PlatformIO Core installed locally for pre-commit hooks +- GitHub Actions handles CI builds automatically (no local setup needed)