From 616f5c5aa399f091aff469300bd373ddd4204a0b Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Sun, 10 May 2026 16:10:53 +0000 Subject: [PATCH] github workflow to compile esphome files --- .github/workflows/compile.yaml | 45 ++++++++++++++++++++++++++++++++++ flake.nix | 1 + reflash.sh | 2 ++ 3 files changed, 48 insertions(+) create mode 100644 .github/workflows/compile.yaml diff --git a/.github/workflows/compile.yaml b/.github/workflows/compile.yaml new file mode 100644 index 0000000..cbe78d1 --- /dev/null +++ b/.github/workflows/compile.yaml @@ -0,0 +1,45 @@ +name: Compile ESPHome + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + compile: + # ubuntu-22.04 is more stable regarding unprivileged user namespaces than 24.04 + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v30 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Enable unprivileged user namespaces + run: | + # Standard fixes for bubblewrap in CI + sudo sysctl -w kernel.unprivileged_userns_clone=1 || true + # Fix for newer kernels/Ubuntu versions that restrict unprivileged userns via AppArmor + sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 || true + + - name: Install direnv + run: sudo apt-get update && sudo apt-get install -y direnv + + - name: Prepare secrets + run: | + if [ -f templates/secrets.yaml.sample ]; then + cp templates/secrets.yaml.sample secrets.yaml + elif [ -f secrets.yaml.sample ]; then + cp secrets.yaml.sample secrets.yaml + fi + + - name: Allow direnv + run: direnv allow . + + - name: Compile + # Using direnv exec as originally requested, now that environment issues are mitigated + run: direnv exec . ./reflash.sh compile '' diff --git a/flake.nix b/flake.nix index 49e9923..774f664 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,7 @@ esphome esptool cc2538-bsl + zsh ]; shellHook = '' diff --git a/reflash.sh b/reflash.sh index 594585f..941884e 100755 --- a/reflash.sh +++ b/reflash.sh @@ -96,7 +96,9 @@ for cmdline in "${flash[@]}"; do flash_result["$cmdline"]=OK else flash_result["$cmdline"]=FAIL + exit_code=1 fi done print_results_table +exit ${exit_code:-0}