Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up action for the initial version #4

Merged
merged 2 commits into from
Dec 13, 2024
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
32 changes: 0 additions & 32 deletions .github/workflows/build-and-publish.yml

This file was deleted.

72 changes: 72 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# In JavaScript actions, `dist/` is a special directory. When you reference
# an action with the `uses:` property, `dist/index.js` is the code that will be
# run. For this project, the `dist/index.js` file is transpiled from other
# source files. This workflow ensures the `dist/` directory contains the
# expected transpiled code.
#
# If this workflow is run from a feature branch, it will act as an additional CI
# check and fail if the checked-in `dist/` directory does not match what is
# expected from the build.
name: Check Transpiled JavaScript

on:
pull_request:
branches:
- main
push:
branches:
- main

permissions:
contents: read

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
id: install
run: npm ci

- name: Build dist/ Directory
id: build
run: npm run package

# This will fail the workflow if the `dist/` directory is different than
# expected.
- name: Compare Directories
id: diff
run: |
if [ ! -d dist/ ]; then
echo "Expected dist/ directory does not exist. See status below:"
ls -la ./
exit 1
fi
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi

# If `dist/` was different than expected, upload the expected version as a
# workflow artifact.
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
2 changes: 1 addition & 1 deletion .github/workflows/eslint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "21"
node-version-file: .node-version

- name: Install dependencies
run: npm install
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ 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 }}
node-version-file: .node-version

- name: Install dependencies
run: npm install

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/validate-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:

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

- name: Install dependencies
run: npm ci
run: npm install

- name: Run JSON File Action
uses: ./ # Assuming the action is in the root directory
with:
json-file-path: "tests/test.json"
json-file-path: "__tests__/test.json"
example-app: "sample-app-1"
build-script: "tests/build_script.sh"
build-script: "__tests__/build_script.sh"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.7.2
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Default codeowners for the repository
* @SiliconLabsSoftware/matter
File renamed without changes.
20 changes: 20 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Unit tests for the action's entrypoint, src/index.js
*/

const { run } = require('../src/main')

// Mock the action's entrypoint
jest.mock('../src/main', () => ({
run: jest.fn()
}))

describe('index', () =>
{
it('calls run when imported', async () =>
{
require('../src/index')

expect(run).toHaveBeenCalled()
})
})
2 changes: 1 addition & 1 deletion tests/index.test.js → __tests__/main.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const core = require('@actions/core');
const fs = require('fs');
const { execSync } = require('child_process');
const { run } = require('../index.js');
const { run } = require('../src/main.js');

jest.mock('@actions/core');
jest.mock('@actions/github');
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: 'Run GN example build'
description: 'Build Silabs example app using the GN build system based on the provided arguments'
author: 'Silicon Labs'

inputs:
example-app:
description: 'Example app to build'
Expand All @@ -10,6 +12,7 @@ inputs:
build-script:
description: 'Build script to be executed for the provided example app'
required: true

runs:
using: 'node20'
main: 'index.js'
main: dist/index.js
Loading
Loading