Skip to content

Commit

Permalink
Refactor action code + add CI to make sure it does the job correctly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Jun 20, 2024
1 parent 77e3617 commit 153c014
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 157 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI

on:
push:
branches:
- main
workflow_dispatch:
pull_request:
schedule:
- cron: "0 5 * * 1"

permissions:
contents: read

concurrency:
# yamllint disable-line rule:line-length
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build test configuration for esphome:${{ matrix.esphome-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
esphome-version:
- stable
- beta
- dev
steps:
- name: Checkout
uses: actions/[email protected]
- name: Run action
uses: ./
id: esphome-build
with:
yaml_file: tests/test.yaml
version: ${{ matrix.esphome-version }}
platform: linux/amd64
cache: true
release_summary: "Test release summary"
release_url: "https://github.com/esphome/build-action"
- name: Write version to file
run: echo ${{ steps.esphome-build.outputs.version }} > ${{ steps.esphome-build.outputs.name }}/version
- name: Upload ESPHome binary
uses: actions/[email protected]
with:
name: build-output-files-${{ matrix.esphome-version }}
path: ${{ steps.esphome-build.outputs.name }}

verify:
name: Verify output files for esphome:${{ matrix.esphome-version }}
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
esphome-version:
- stable
- beta
- dev
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download files
uses: actions/[email protected]
with:
name: build-output-files-${{ matrix.esphome-version }}

- name: List files
run: |-
ls -al
tree
- name: Validate json file matches manifest-template.json
run: |
jq -n --arg md5 "$(md5sum test-esp32.ota.bin | head -c 32)" -f tests/manifest-template.json > /tmp/manifest.json
diff <(jq --sort-keys . /tmp/manifest.json) <(jq --sort-keys . manifest.json)
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
.esphome
venv
*.bin
*.json
!/tests/manifest-template.json
config/
12 changes: 5 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,12 @@ runs:
--workdir /github/workspace \
-v "$(pwd)":"/github/workspace" -v "$HOME:$HOME" \
--user $(id -u):$(id -g) \
-e INPUT_YAML_FILE -e HOME \
-e INPUT_RELEASE_SUMMARY -e INPUT_RELEASE_URL \
-e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY \
-e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER \
-e GITHUB_ACTOR -e GITHUB_OUTPUT \
-e GITHUB_ACTIONS=true -e CI=true \
-e HOME \
esphome:${{ inputs.version }} \
${{ inputs.yaml_file }}
${{ inputs.yaml_file }} \
--release-summary "${{ inputs.release_summary }}" \
--release-url "${{ inputs.release_url }}" \
--outputs-file "$GITHUB_OUTPUT"
branding:
icon: "archive"
Expand Down
Loading

0 comments on commit 153c014

Please sign in to comment.