From 8c9930953a1c1cafc3ac593643ffb56c0c85a355 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Tue, 20 Dec 2022 12:12:03 +0100 Subject: [PATCH 1/6] Add CI workflow to check Typescript packaging On every push and pull request that affects relevant files, check the project's Typescript packaging. --- .../check-packaging-ncc-typescript-npm.yml | 52 +++++++++++++++++++ README.md | 1 + 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/check-packaging-ncc-typescript-npm.yml diff --git a/.github/workflows/check-packaging-ncc-typescript-npm.yml b/.github/workflows/check-packaging-ncc-typescript-npm.yml new file mode 100644 index 00000000..bca774a8 --- /dev/null +++ b/.github/workflows/check-packaging-ncc-typescript-npm.yml @@ -0,0 +1,52 @@ +name: Check Packaging + +env: + # See: https://github.com/actions/setup-node/#readme + NODE_VERSION: 16.x + +on: + push: + paths: + - ".github/workflows/check-packaging-ncc-typescript-npm.ya?ml" + - "lerna.json" + - "package.json" + - "package-lock.json" + - "Taskfile.ya?ml" + - "tsconfig.json" + - "**.[jt]sx?" + pull_request: + paths: + - ".github/workflows/check-packaging-ncc-typescript-npm.ya?ml" + - "lerna.json" + - "package.json" + - "package-lock.json" + - "Taskfile.ya?ml" + - "tsconfig.json" + - "**.[jt]sx?" + workflow_dispatch: + repository_dispatch: + +jobs: + check-packaging: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install dependencies + run: npm install + + - name: Build project + run: | + npm run 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 diff --git a/README.md b/README.md index b9777489..257fd135 100644 --- a/README.md +++ b/README.md @@ -10,6 +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) This action makes the `protoc` compiler available to Workflows. From ceb7b42b4be2853e0901344f90e6d466fe0c89c7 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 24 May 2023 10:16:35 +0200 Subject: [PATCH 2/6] Reformat commands in contributor guide The commands were prefixed by "#", evidently to indicate a command prompt. But that is the shell comment syntax, so it is very unintuitive. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 257fd135..b941efe9 100644 --- a/README.md +++ b/README.md @@ -66,14 +66,14 @@ pass the default token with the `repo-token` variable: To work on the codebase you have to install all the dependencies: -```sh -# npm install +``` +npm install ``` To run the tests: -```sh -# npm run test +``` +npm run test ``` ## Enable verbose logging for a pipeline From 2183ab8180d09f130c0eb9a9dcfe79498b8a337f Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 24 May 2023 10:22:09 +0200 Subject: [PATCH 3/6] Use ordered list for development section of contributor guide The development process for contributors follows a reasonably linear set of distinct steps, so this is an appropriate way of organizing the information. --- README.md | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b941efe9..8f83ab2f 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,18 @@ pass the default token with the `repo-token` variable: ``` -## Development +## Development workflow + +### 1. Install tools + +#### Node.js + +[**npm**](https://www.npmjs.com/) is used for dependency management. + +Follow the installation instructions here:
+https://nodejs.dev/en/download + +### 2. Install dependencies To work on the codebase you have to install all the dependencies: @@ -70,20 +81,35 @@ To work on the codebase you have to install all the dependencies: npm install ``` +### 3. Coding + +Now you're ready to work some [TypeScript](https://www.typescriptlang.org/) magic! + +Make sure to write or update tests for your work when appropriate. + +### 4. Format code + +Format the code to follow the standard style for the project: + +``` +npm run format +``` + +### 5. Run tests + To run the tests: ``` npm run test ``` -## Enable verbose logging for a pipeline -Additional log events with the prefix ::debug:: can be enabled by setting the secret `ACTIONS_STEP_DEBUG` to `true`. - -See [step-debug-logs](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#step-debug-logs) for reference. +### 6. Commit +Everything is now ready to make your contribution to the project, so commit it to the repository and submit a pull request. +Thanks! -## Release +## Release workflow 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 @@ -104,6 +130,11 @@ Action the workflow should be the following: If no branch exists for the release's major version, create one. +## Enable verbose logging for a pipeline +Additional log events with the prefix ::debug:: can be enabled by setting the secret `ACTIONS_STEP_DEBUG` to `true`. + +See [step-debug-logs](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#step-debug-logs) for reference. + ## Security From f6ba02082455c3dedca2afde38fcb0408ccb1bf2 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 24 May 2023 10:24:17 +0200 Subject: [PATCH 4/6] Change development policy to repackaging on every code change The previous development policy was to only repackage on each release. This prevented contributors from doing casual beta testing by simply referencing the action as `arduino/arduino-lint-action@main` in a workflow. --- README.md | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8f83ab2f..f970f273 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,34 @@ To run the tests: npm run test ``` -### 6. Commit +### 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: + +``` +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 +``` + +### 7. Commit Everything is now ready to make your contribution to the project, so commit it to the repository and submit a pull request. @@ -111,17 +138,8 @@ Thanks! ## Release workflow -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`. To release a new version of the -Action the workflow should be the following: - -1. `npm install` to add all the dependencies, included development. -1. `npm run test` to see everything works as expected. -1. `npm run build` to build the Action under the `./lib` folder. -1. `rm -rf node_modules` to remove all the dependencies. -1. `npm install --production` to add back **only** the runtime dependencies. -1. `git add lib node_modules` to check in the code that matters. +To release a new version of the Action the workflow should be the following: + 1. If the release will increment the major version, update the action refs in the examples in README.md (e.g., `uses: arduino/setup-protoc@v1` -> `uses: arduino/setup-protoc@v2`). 1. open a PR and request a review. @@ -143,3 +161,4 @@ If you think you found a vulnerability or other security-related bug in this pro Thank you! e-mail contact: security@arduino.cc + From 3714f910daaaffc9214de7977aa31f0ac2eef00b Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 24 May 2023 11:12:00 +0200 Subject: [PATCH 5/6] Move development and release sections to CONTRIBUTING.md --- .github/CONTRIBUTING.md | 84 +++++++++++++++++++++++++++++++++++++ README.md | 91 +++-------------------------------------- 2 files changed, 89 insertions(+), 86 deletions(-) create mode 100644 .github/CONTRIBUTING.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..7c40dcc8 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,84 @@ +## Development workflow + +### 1. Install tools + +#### Node.js + +[**npm**](https://www.npmjs.com/) is used for dependency management. + +Follow the installation instructions here:
+https://nodejs.dev/en/download + +### 2. Install dependencies + +To work on the codebase you have to install all the dependencies: + +``` +npm install +``` + +### 3. Coding + +Now you're ready to work some [TypeScript](https://www.typescriptlang.org/) magic! + +Make sure to write or update tests for your work when appropriate. + +### 4. Format code + +Format the code to follow the standard style for the project: + +``` +npm run format +``` + +### 5. Run tests + +To run the tests: + +``` +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: + +``` +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 +``` + +### 7. Commit + +Everything is now ready to make your contribution to the project, so commit it to the repository and submit a pull request. + +Thanks! + +## Release workflow + +To release a new version of the Action the workflow should be the following: + +1. If the release will increment the major version, update the action refs in the examples in README.md + (e.g., `uses: arduino/setup-protoc@v1` -> `uses: arduino/setup-protoc@v2`). +1. open a PR and request a review. +1. After PR is merged, create a release, following the `vX.X.X` tag name convention. +1. After the release, rebase the release branch for that major version (e.g., `v1` branch for the v1.x.x tags) on the tag. + If no branch exists for the release's major version, create one. diff --git a/README.md b/README.md index f970f273..dabf53b2 100644 --- a/README.md +++ b/README.md @@ -62,92 +62,6 @@ pass the default token with the `repo-token` variable: ``` -## Development workflow - -### 1. Install tools - -#### Node.js - -[**npm**](https://www.npmjs.com/) is used for dependency management. - -Follow the installation instructions here:
-https://nodejs.dev/en/download - -### 2. Install dependencies - -To work on the codebase you have to install all the dependencies: - -``` -npm install -``` - -### 3. Coding - -Now you're ready to work some [TypeScript](https://www.typescriptlang.org/) magic! - -Make sure to write or update tests for your work when appropriate. - -### 4. Format code - -Format the code to follow the standard style for the project: - -``` -npm run format -``` - -### 5. Run tests - -To run the tests: - -``` -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: - -``` -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 -``` - -### 7. Commit - -Everything is now ready to make your contribution to the project, so commit it to the repository and submit a pull request. - -Thanks! - -## Release workflow - -To release a new version of the Action the workflow should be the following: - -1. If the release will increment the major version, update the action refs in the examples in README.md - (e.g., `uses: arduino/setup-protoc@v1` -> `uses: arduino/setup-protoc@v2`). -1. open a PR and request a review. -1. After PR is merged, create a release, following the `vX.X.X` tag name convention. -1. After the release, rebase the release branch for that major version (e.g., `v1` branch for the v1.x.x tags) on the tag. - If no branch exists for the release's major version, create one. - - ## Enable verbose logging for a pipeline Additional log events with the prefix ::debug:: can be enabled by setting the secret `ACTIONS_STEP_DEBUG` to `true`. @@ -162,3 +76,8 @@ Thank you! e-mail contact: security@arduino.cc +## Contributing + +To report bugs or make feature requests, please submit an issue: https://github.com/arduino/setup-protoc/issues + +Pull requests are welcome! Please see the [contribution guidelines](.github/CONTRIBUTING.md) for information. From 6bcf32235c906988fe9cb3415df02a32f9ed8d99 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 24 May 2023 11:16:07 +0200 Subject: [PATCH 6/6] Run prettier on CONTRIBUTING.md and README.md --- .github/CONTRIBUTING.md | 2 +- README.md | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 7c40dcc8..d6c0b1a8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -41,7 +41,7 @@ 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`. +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: ``` diff --git a/README.md b/README.md index dabf53b2..b39663d5 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ If you want to pin a major or minor version you can use the `.x` wildcard: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - version: '3.x' + version: "3.x" ``` You can also require to include releases marked as `pre-release` in Github using the `include-pre-releases` flag (the dafault value for this flag is `false`) @@ -38,7 +38,7 @@ You can also require to include releases marked as `pre-release` in Github using - name: Install Protoc uses: arduino/setup-protoc@v1 with: - version: '3.x' + version: "3.x" include-pre-releases: true ``` @@ -48,7 +48,7 @@ To pin the exact version: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - version: '3.9.1' + version: "3.9.1" ``` The action queries the GitHub API to fetch releases data, to avoid rate limiting, @@ -61,13 +61,12 @@ pass the default token with the `repo-token` variable: repo-token: ${{ secrets.GITHUB_TOKEN }} ``` - ## Enable verbose logging for a pipeline + Additional log events with the prefix ::debug:: can be enabled by setting the secret `ACTIONS_STEP_DEBUG` to `true`. See [step-debug-logs](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#step-debug-logs) for reference. - ## Security If you think you found a vulnerability or other security-related bug in this project, please read our