Skip to content

Commit

Permalink
Move matter codegen into separate workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
tecimovic committed Jul 8, 2023
1 parent a8b99ef commit 8bc07fa
Show file tree
Hide file tree
Showing 2 changed files with 240 additions and 50 deletions.
240 changes: 240 additions & 0 deletions .github/workflows/matter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
name: Matter code generation

permissions:
contents: write

on:
push:
pull_request:
workflow_dispatch:

env:
ZAP_TEST_TIMEOUT: 3600000
ZAP_TEMPSTATE: 1
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
TRUSTED_CERTIFICATE_BASE64: ${{ secrets.TRUSTED_CERTIFICATE_BASE64 }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KEYCHAIN_PASSWORD: silabs

jobs:
prepare-zap:
name: Prepare zap for Matter generation
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [18.x]
os: [ubuntu-22.04]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.0.0
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: sudo ./src-script/install-packages-ubuntu
- run: sudo apt-get install --fix-missing libxml2-utils
- run: node --version
- run: npm --version
- run: npm ci
- run: npm run metafile-check
- run: npm run version-stamp
- run: npm rebuild canvas --update-binary
- run: npm rebuild libxmljs --update-binary
- run: npm run lic
- run: npm run build-spa
- run: npm run lint
- run: npm run xml-validate
- run: npm run self-check
- run: npm run test:unit
- name: Upload code coverage artifacts
uses: actions/upload-artifact@v3
with:
name: jest-coverage
path: jest-coverage/coverage-final.json
- run: npm run test:gen

build-zap:
name: Build ZAP
needs: [prepare-zap]
runs-on: ${{ matrix.os }}

# Platforms to build on/for
strategy:
matrix:
os: [ubuntu-22.04]
fail-fast: false

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3.0.0
with:
node-version: 18.x
cache: 'npm'

- name: Prepare Linux build environment
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo ./src-script/install-packages-ubuntu
- name: Initialize...
run: |
npm rebuild canvas --update-binary
npm rebuild libxmljs --update-binary
npm ci
npm run version-stamp
- name: Building frontend / backend
run: |
npm run build
- name: Build & Release for Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
npm run pack:linux
npm run pkg:linux
ls ./dist/
npm run pack:cli:linux
mv dist/zap-linux-amd64.deb dist/zap-linux-x64.deb
mv dist/zap-linux-x86_64.rpm dist/zap-linux-x64.rpm
env:
GH_TOKEN: ${{ secrets.github_token }}
# macOS notarization API key
# CSC_LINK: ${{ secrets.api_key_id }}
# CSC_KEY_PASSWORD: ${{ secrets.api_key_issuer_id }}

- name: Verify zap-cli exists in Linux x64 .zip package
if: startsWith(matrix.os, 'ubuntu')
run: |
output=$(./node_modules/7zip-bin/linux/x64/7za l ./dist/zap-linux-x64.zip)
expression=zap-cli
if [[ $output == *"$expression"* ]]; then
echo "Output contains $expression"
else
echo "Output does not contain $expression"
exit 1
fi
- name: Verify zap-cli exists in Linux arm64 .zip package
if: startsWith(matrix.os, 'ubuntu')
run: |
output=$(./node_modules/7zip-bin/linux/x64/7za l ./dist/zap-linux-arm64.zip)
expression=zap-cli
if [[ $output == *"$expression"* ]]; then
echo "Output contains $expression"
else
echo "Output does not contain $expression"
exit 1
fi
- name: ZAP binary check (Linux) - unzip
if: startsWith(matrix.os, 'ubuntu')
run: unzip dist/zap-linux-x64.zip -d dist/zap-linux
- name: ZAP binary check (Linux) - check version is set
if: startsWith(matrix.os, 'ubuntu')
uses: GuillaumeFalourd/assert-command-line-output@v2.1
with:
command_line: ./dist/zap-linux/zap --version
contains: '0.0.0'
expected_result: FAILED
- name: ZAP binary check (Linux) - check version is set via CLI
if: startsWith(matrix.os, 'ubuntu')
uses: GuillaumeFalourd/assert-command-line-output@v2.1
with:
command_line: ./dist/zap-linux/zap-cli --version
contains: '0.0.0'
expected_result: FAILED
- name: ZAP binary check (Linux) - unzip cleanup
if: startsWith(matrix.os, 'ubuntu')
run: rm -rf dist/zap-linux
- name: Verify apack.json exists in package's base directory
if: startsWith(matrix.os, 'ubuntu')
uses: GuillaumeFalourd/assert-command-line-output@v2.1
with:
command_line: ./node_modules/7zip-bin/linux/x64/7za l ./dist/zap-linux-x64.zip | grep apack.json
contains: 'apack.json'
- name: Verify apack.json exists in package's app.asar archive
if: startsWith(matrix.os, 'ubuntu')
uses: GuillaumeFalourd/assert-command-line-output@v2.1
with:
command_line: npx asar l ./dist/linux-unpacked/resources/app.asar | grep apack.json
contains: 'apack.json'
- name: Archive Linux (x64) .zip file
uses: actions/upload-artifact@v3
if: startsWith(matrix.os, 'ubuntu')
with:
name: zap-linux-x64-zip
path: dist/zap-linux-x64.zip
- name: Archive Linux (arm64) .zip file
uses: actions/upload-artifact@v3
if: startsWith(matrix.os, 'ubuntu')
with:
name: zap-linux-arm64-zip
path: dist/zap-linux-arm64.zip
- name: Archive Linux .rpm file
uses: actions/upload-artifact@v3
if: startsWith(matrix.os, 'ubuntu')
with:
name: zap-linux-x64-rpm
path: dist/zap-linux-x64.rpm
- name: Archive Linux x64 .deb file
uses: actions/upload-artifact@v3
if: startsWith(matrix.os, 'ubuntu')
with:
name: zap-linux-x64-deb
path: dist/zap-linux-x64.deb

matter-sdk-codegen:
name: Test matter sdk codegen changes
needs: [build-zap]
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18.x]

# CHIP container required because clang-format version needs to match
container:
image: connectedhomeip/chip-build:0.6.11

steps:
- uses: actions/download-artifact@v3
with:
name: zap-linux-x64-zip

- name: Unpack linux artifact
run: |
mkdir zap-release && cd zap-release && unzip ../zap-linux-x64.zip
# Checkout without actions/checkout@v3 since that one uses a repository specific token
- name: Checkout Matter SDK
run: |
git clone --depth 1 https://github.com/project-chip/connectedhomeip.git chip_repo
- name: Ensure matter embedded zap is not available
run: |
rm -f /usr/bin/zap-cli
rm -rf /opt/zap-*
- name: Generate all
run: |
cd chip_repo
ZAP_INSTALL_PATH=$(pwd)/../zap-release scripts/run_in_build_env.sh scripts/tools/zap_regen_all.py
- name: Ensure git works in the chip repository checkout
run: git config --global --add safe.directory `pwd`/chip_repo

- name: Check for uncommited changes
run: |
cd chip_repo
git add .
# Show the full diff
git diff-index -p HEAD --
# Also show just the files that are different, to make it easy
# to tell at a glance what might be going on. And throw in
# --exit-code to make this job fail if there is a difference.
git diff-index --exit-code HEAD --
50 changes: 0 additions & 50 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -452,53 +452,3 @@ jobs:
generateReleaseNotes: true
prerelease: ${{ endsWith(github.ref, 'nightly') }}
artifacts: 'zap-linux-x64-deb/zap-linux-x64.deb, zap-linux-x64-rpm/zap-linux-x64.rpm, zap-linux-x64-zip/zap-linux-x64.zip, zap-linux-arm64-zip/zap-linux-arm64.zip, zap-mac-x64-zip/zap-mac-x64.zip, zap-win-x64-zip/zap-win-x64.zip, zap-win-arm64-zip/zap-win-arm64.zip'

matter-sdk-codegen:
name: Test matter sdk codegen changes
needs: [build-zap]
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18.x]

# CHIP container required because clang-format version needs to match
container:
image: connectedhomeip/chip-build:0.6.11

steps:
- uses: actions/download-artifact@v3
with:
name: zap-linux-x64-zip

- name: Unpack linux artifact
run: |
mkdir zap-release && cd zap-release && unzip ../zap-linux-x64.zip
# Checkout without actions/checkout@v3 since that one uses a repository specific token
- name: Checkout Matter SDK
run: |
git clone --depth 1 https://github.com/project-chip/connectedhomeip.git chip_repo
- name: Ensure matter embedded zap is not available
run: |
rm -f /usr/bin/zap-cli
rm -rf /opt/zap-*
- name: Generate all
run: |
cd chip_repo
ZAP_INSTALL_PATH=$(pwd)/../zap-release scripts/run_in_build_env.sh scripts/tools/zap_regen_all.py
- name: Ensure git works in the chip repository checkout
run: git config --global --add safe.directory `pwd`/chip_repo

- name: Check for uncommited changes
run: |
cd chip_repo
git add .
# Show the full diff
git diff-index -p HEAD --
# Also show just the files that are different, to make it easy
# to tell at a glance what might be going on. And throw in
# --exit-code to make this job fail if there is a difference.
git diff-index --exit-code HEAD --

0 comments on commit 8bc07fa

Please sign in to comment.