From 326dcc08a855a6be66c52df2d0b202184495d09e 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 | 40 ++++++++++++++++++++++++++++++++++ flake.nix | 1 + reflash.sh | 2 ++ 3 files changed, 43 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..1a59406 --- /dev/null +++ b/.github/workflows/compile.yaml @@ -0,0 +1,40 @@ +name: Compile ESPHome + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + compile: + runs-on: ubuntu-latest + 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 + # Some newer Ubuntu runners (24.04+) require this for bubblewrap/Nix FHS + run: | + sudo sysctl -w kernel.unprivileged_userns_clone=1 || true + # Apparmor can also block unprivileged userns on newer Ubuntu + sudo sh -c 'echo "kernel.unprivileged_userns_clone=1" > /etc/sysctl.d/99-userns.conf' + sudo sysctl -p /etc/sysctl.d/99-userns.conf || true + + - 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: Compile + # Use nix develop to run the script in the flake environment. + # This avoids direnv 'allow' issues and sudo environment scrubbing. + run: nix develop --command ./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}