Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Publish Action

on:
workflow_run:
workflows: ["Validate Action", "Run unit tests", "ESLint Check"]
types:
- completed

jobs:
build:
if: github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Install dependencies
run: npm install

- name: Build action with ncc
run: npm run build

- name: Publish to GitHub
uses: actions/upload-artifact@v2
with:
name: action
path: dist
24 changes: 24 additions & 0 deletions .github/workflows/eslint-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ESLint Check

on: [pull_request]

jobs:
eslint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "21"

- name: Install dependencies
run: npm install

- name: Run ESLint
id: eslint
run: |
npx eslint .
25 changes: 25 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Run unit tests

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install

- name: Run tests
run: npm test
22 changes: 22 additions & 0 deletions .github/workflows/validate-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Validate Action"
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install dependencies
run: npm ci

- name: Run JSON File Action
uses: ./ # Assuming the action is in the root directory
with:
json-file-path: "tests/test.json"
example-app: "sample-app-1"
build-script: "tests/build_script.sh"
130 changes: 130 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"javascript.validate.enable": false, // Disable the built-in validation
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"eslint.alwaysShowStatus": true,
"editor.defaultFormatter": null,
"[shellscript]": {
"editor.defaultFormatter": "mkhl.shfmt"
} // Remove Prettier as the default formatter

}
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Matter GN Build Action

Source code is licensed to you under the terms of a default license
from Silicon Laboratories Inc. This default license and exceptions to this
default licensing are set forth below.

The default license is the Master Software License Agreement (MSLA)
(https://www.silabs.com/about-us/legal/master-software-license-agreement), which
applies unless otherwise noted.

Some files use different licensing terms. If so, they will be clearly marked in
the beginning of the file.

Library files (either in archived or object form) are distributed under the
terms of the MSLA.
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,97 @@
# matter-gn-build-action
Github Action used to build Matter examples with the GN build system

GitHub Action used to build Matter examples with the GN build system.

## Table of Contents

- [Usage](#usage)
- [Inputs](#inputs)
- [Outputs](#outputs)
- [Example Workflow](#example-workflow)
- [Setup and Testing](#setup-and-testing)
- [Testing GitHub Actions Locally](#testing-github-actions-locally)

## Usage

To use this action, include it in your workflow YAML file.

## Inputs

| Name | Description |
| -------------- | -------------------------------------------------------- |
| `example-app` | Example app to build |
| `json-content` | JSON content to be used as GN args |
| `build-script` | Build script to be executed for the provided example app |

## Outputs

This action does not produce any outputs.

## Example Workflow

npm test

```yaml
name: Build Matter Example

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build Matter Example
uses: ./ # Uses an action in the root directory
with:
example-app: "lighting-app"
json-content: "./path/to/json.json"
build-script: "./path/to/build_script.sh"

- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: out/examples/lighting-app
```

## Setup and Testing

To set up the repository and run the unit tests, follow these steps:

1. Clone the repository:

```
git clone https://github.com/your-username/matter-gn-build-action.git
cd matter-gn-build-action
```

2. Install dependencies:

```
npm install
```

Run the tests:

```
npm test
```

## Testing GitHub Actions Locally

You can use the `act` tool to test GitHub Actions locally.

1. Install `act`:

```
brew install act
```

2. Run the action locally:

```
act --container-architecture linux/amd64 -W .github/workflows/eslint-check.yml
```
15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Run GN example build'
description: 'Build Silabs example app using the GN build system based on the provided arguments'
inputs:
example-app:
description: 'Example app to build'
required: true
json-content:
description: 'JSON content to be used as GN args'
required: true
build-script:
description: 'Build script to be executed for the provided example app'
required: true
runs:
using: 'node20'
main: 'index.js'
Loading
Loading