Skip to content

Use ncc to compile the action #77

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

Merged
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
23 changes: 2 additions & 21 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,10 @@ npm run test

### 6. Build

It is necessary to compile the code before it can be used by GitHub Actions. We check in the `node_modules` to provide runtime dependencies to the system using the Action, so be careful not to `git add` all the development dependencies you might have under your local `node_modules`.
Remember to run these commands before committing any code changes:
It is necessary to compile the code before it can be used by GitHub Actions. Remember to run these commands before committing any code changes:

```
npm run build
```

remove all the dependencies:

```
rm -rf node_modules
```

add back **only** the runtime dependencies:

```
npm install --production
```

check in the code that matters:

```
git add lib node_modules
task build
```

### 7. Commit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm install
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Build project
run: |
npm run build
run: task ts:build

- name: Check packaging
# Ignoring CR because ncc's output has a mixture of line endings, while the repository should only contain
# Unix-style EOL.
run: git diff --ignore-cr-at-eol --color --exit-code lib
run: git diff --ignore-cr-at-eol --color --exit-code dist
4 changes: 2 additions & 2 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
push:
paths:
- ".github/workflows/test-integration.ya?ml"
- "lib/**"
- "dist/**"
- "action.yml"
pull_request:
paths:
- ".github/workflows/test-integration.ya?ml"
- "lib/**"
- "dist/**"
- "action.yml"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by external changes.
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/node_modules/
# Dependency directory
node_modules/

# Ignore built ts files
__tests__/runner/*
lib/**/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[![Check npm status](https://github.com/arduino/setup-protoc/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-npm-task.yml)
[![Check TypeScript status](https://github.com/arduino/setup-protoc/actions/workflows/check-typescript-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-typescript-task.yml)
[![Check tsconfig status](https://github.com/arduino/setup-protoc/actions/workflows/check-tsconfig-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-tsconfig-task.yml)
[![Check Packaging status](https://github.com/arduino/setup-protoc/actions/workflows/check-packaging-ncc-typescript-npm.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-packaging-ncc-typescript-npm.yml)
[![Check Packaging status](https://github.com/arduino/setup-protoc/actions/workflows/check-packaging-ncc-typescript-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-packaging-ncc-typescript-task.yml)

This action makes the `protoc` compiler available to Workflows.

Expand Down
14 changes: 14 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ vars:
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0

tasks:
build:
desc: Build the project
deps:
- task: ts:build

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-dependencies-task/Taskfile.yml
general:prepare-deps:
desc: Prepare project dependencies for license check
Expand Down Expand Up @@ -260,6 +265,15 @@ tasks:
else
echo "{{.RAW_PATH}}"
fi

ts:build:
desc: Build the action's TypeScript code.
deps:
- task: npm:install-deps
cmds:
- npx tsc
- npx ncc build

ts:lint:
desc: Lint TypeScript code
deps:
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
default: ''
runs:
using: 'node16'
main: 'lib/main.js'
main: 'dist/index.js'
branding:
icon: 'box'
color: 'green'
Loading