perf(docker): multi-stage build to drop npm + add .dockerignore #153
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/ci.yml | |
| name: Node.js CI | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| pull_request: | |
| branches: [ "main", "master" ] | |
| jobs: | |
| version-sync: | |
| name: package.json / config.yaml version sync | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| - name: Verify versions match | |
| run: | | |
| pkg_version=$(node -p "require('./package.json').version") | |
| cfg_version=$(grep -E '^version:' homeassistant-addon/config.yaml | sed -E 's/^version:[[:space:]]*"?([^"]+)"?$/\1/') | |
| echo "package.json version: ${pkg_version}" | |
| echo "config.yaml version: ${cfg_version}" | |
| if [[ "${pkg_version}" != "${cfg_version}" ]]; then | |
| echo "::error::package.json version (${pkg_version}) does not match homeassistant-addon/config.yaml version (${cfg_version})." | |
| echo "::error::Bump both files together before pushing (see CLAUDE.md release process)." | |
| exit 1 | |
| fi | |
| test: | |
| name: Lint, Test & Coverage | |
| runs-on: ubuntu-latest | |
| needs: version-sync | |
| strategy: | |
| matrix: | |
| node-version: [20.x, 22.x] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Lint | |
| run: npm run lint -- --max-warnings=0 | |
| - name: Unit tests with coverage | |
| run: npm test -- --coverage --coverageReporters=text --coverageReporters=lcov | |
| # Jest enforces the thresholds defined in package.json (≥80% statements/lines globally). | |
| # PRs that drop coverage below those thresholds will fail here. | |
| - name: Upload coverage report | |
| if: matrix.node-version == '22.x' | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: coverage-report | |
| path: coverage/lcov.info | |
| retention-days: 7 | |
| integration: | |
| name: Integration test (C-Gate) | |
| runs-on: ubuntu-latest | |
| # Only run on push to main branches — not on PRs — to avoid long waits during review. | |
| if: github.event_name == 'push' | |
| timeout-minutes: 20 | |
| needs: test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| - name: Use Node.js 20.x | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5 | |
| with: | |
| node-version: 20.x | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install podman-compose | |
| run: pip3 install podman-compose | |
| - name: Set up managed-download test options | |
| run: cp test-env/options-managed-download.json test-env/active-options.json | |
| - name: Run integration test (managed mode - downloads C-Gate) | |
| run: node test-env/integration-test.js | |
| timeout-minutes: 15 |