From 81a9d891feb111569b82312137fa550851a9ceb7 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 23 Jan 2023 15:31:32 -0800 Subject: [PATCH 01/10] Move name first for the private package --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d28e7ac..04836ef 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "name": "actions-languageservices", "private": true, "workspaces": [ "./actions-expressions", @@ -9,6 +10,5 @@ ], "devDependencies": { "lerna": "^6.0.3" - }, - "name": "actions-languageservices" + } } From 95d7590889d7cba25f3a348c9605a7563729de20 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 23 Jan 2023 15:31:47 -0800 Subject: [PATCH 02/10] Add README for actions-expressions --- actions-expressions/README.md | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 actions-expressions/README.md diff --git a/actions-expressions/README.md b/actions-expressions/README.md new file mode 100644 index 0000000..5048e95 --- /dev/null +++ b/actions-expressions/README.md @@ -0,0 +1,65 @@ +# actions-expressions + +`actions-expressions` is a library to parse and evaluate GitHub Actions [expressions](https://docs.github.com/actions/learn-github-actions/expressions). + +## Installation + +The [package](https://www.npmjs.com/package/@github/actions-expressions) contains TypeScript types and compiled ECMAScript modules. + +```bash +npm install @github/actions-expressions +``` + +## Usage + +### Simple example + +```ts +import { Parser, Lexer, Evaluator, data } from '@actions/expressions'; + +const lexer = new Lexer("1 == 2"); +const lr = lexer.lex(); + +const parser = new Parser(lr.tokens, [], []); +const expr = parser.parse(); + +const evaluator = new Evaluator(expr, new data.Dictionary()); +const result = evaluator.evaluate(); + +console.log(result.coerceString()) // false +``` + +### With context data + +```ts +import { Parser, Lexer, Evaluator, data } from '@actions/expressions'; + +const lexer = new Lexer("'monalisa' == context.name"); +const lr = lexer.lex(); + +const parser = new Parser(lr.tokens, ["context"], []); +const expr = parser.parse(); + +const evaluator = new Evaluator(expr, new data.Dictionary([{ + key: "context" + value: new data.Dictionary([{ + key: "name" + value: new data.StringData("monalisa") + }]) +}])); +const result = evaluator.evaluate(); + +console.log(result.coerceString()) // true +``` + +## Contributing + +See also [CONTRIBUTING.md](../CONTRIBUTING.md) at the root of the repository. + +This project is just one of multiple implementations of the GitHub Actions Expressions language. We therefore cannot accept contributions that add new language features or significantly change the behavior or existing language features. If you would like to propose a change to the language itself, please use our [Community Forum](https://github.com/community/community/discussions/categories/actions-and-packages). + +If you do want to contribute, please run [prettier](https://prettier.io/) to format your code and add unit tests as appropriate before submitting your PR. [./testdata](./testdata) contains test cases that all implementations should pass, please also make sure those tests are still passing. + +## License + +This project is licensed under the terms of the MIT open source license. Please refer to [MIT](../LICENSE) for the full terms. \ No newline at end of file From 2b57aef27e7056e04d426cfc248c20d730c21cb1 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 23 Jan 2023 15:34:18 -0800 Subject: [PATCH 03/10] Add CONTRIBUTING --- CONTRIBUTING.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4593f13 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,46 @@ +## Contributing + +[fork]: https://github.com/github/actions-languageservices/fork +[pr]: https://github.com/github/actions-languageservices/compare +[code-of-conduct]: CODE_OF_CONDUCT.md + +Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. + +Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE.md). + +Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms. + +## Prerequisites for running and testing code + +These are one time installations required to be able to test your changes locally as part of the pull request (PR) submission process. + +1. Install [Node.js](https://nodejs.org/en/download/) for your platform +1. Install the dependencies. From the repository root run: +```bash +$ npm i +``` + +This repository contains multiple packages and uses [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) to manage the dependencies between them. + +## Submitting a pull request + +1. [Fork][fork] and clone the repository +1. Configure and install the dependencies: `npm i` +1. Create a new branch: `git checkout -b my-branch-name` +1. Make your change, add tests, and make sure the tests and linter still pass +1. Push to your fork and [submit a pull request][pr] + +Here are a few things you can do that will increase the likelihood of your pull request being accepted: + +- Format your code with [prettier](https://prettier.io/). +- Write tests. +- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. +- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). + +Please also look at the `README.md` files for each package for additional notes on contributing. + +## Resources + +- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) +- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) +- [GitHub Help](https://help.github.com) \ No newline at end of file From 5003237f65dbad209afaf7032c0837ee9178e5d1 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 23 Jan 2023 15:35:36 -0800 Subject: [PATCH 04/10] Add initial README for repo --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 39e6895..5818313 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,13 @@ # Language Services for GitHub Actions +This repository contains multiple npm packages for working with GitHub Actions workflow YAML files. + +- [actions-expressions](./actions-expressions) - Parser and evaluator for GitHub Actions [Expressions](https://docs.github.com/actions/learn-github-actions/expressions) +- [actions-workflow-parser](./actions-workflow-parser) - Parser for GitHub Actions [Workflows](https://docs.github.com/actions/learn-github-actions/workflow-syntax-for-github-actions) - [actions-languageservice](./actions-languageservice) - Language Service for GitHub Actions - [actions-languageserver](./actions-languageserver) - Language Server for GitHub Actions, hosting the language service for LSP-compatible editors +- [browser-playground](./browser-playground) - Browser-based playground for the language service + +## Contributing + +See [CONTRIBUTING.md](./CONTRIBUTING.md) \ No newline at end of file From 4509c67f0e012453e9dc1a9f34047e8fbca64799 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 23 Jan 2023 15:38:07 -0800 Subject: [PATCH 05/10] Add more commands --- actions-expressions/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/actions-expressions/README.md b/actions-expressions/README.md index 5048e95..e6d819d 100644 --- a/actions-expressions/README.md +++ b/actions-expressions/README.md @@ -60,6 +60,36 @@ This project is just one of multiple implementations of the GitHub Actions Expre If you do want to contribute, please run [prettier](https://prettier.io/) to format your code and add unit tests as appropriate before submitting your PR. [./testdata](./testdata) contains test cases that all implementations should pass, please also make sure those tests are still passing. +### Build + +```bash +$ npm run build +``` + +or to watch for changes + +```bash +$ npm run watch +``` + +### Test + +```bash +$ npm test +``` + +or to watch for changes and run tests: + +```bash +$ npm run test-watch +``` + +### Lint + +```bash +$ npm run format-check +``` + ## License This project is licensed under the terms of the MIT open source license. Please refer to [MIT](../LICENSE) for the full terms. \ No newline at end of file From 5523a36a655e990557cb1f76dd4ef87c00917478 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 23 Jan 2023 17:49:52 -0800 Subject: [PATCH 06/10] Fix typo --- actions-expressions/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions-expressions/README.md b/actions-expressions/README.md index e6d819d..2e1ec05 100644 --- a/actions-expressions/README.md +++ b/actions-expressions/README.md @@ -56,7 +56,7 @@ console.log(result.coerceString()) // true See also [CONTRIBUTING.md](../CONTRIBUTING.md) at the root of the repository. -This project is just one of multiple implementations of the GitHub Actions Expressions language. We therefore cannot accept contributions that add new language features or significantly change the behavior or existing language features. If you would like to propose a change to the language itself, please use our [Community Forum](https://github.com/community/community/discussions/categories/actions-and-packages). +This project is just one of multiple implementations of the GitHub Actions Expressions language. We therefore cannot accept contributions that add new language features or significantly change the behavior of existing language features. If you would like to propose a change to the language itself, please use our [Community Forum](https://github.com/community/community/discussions/categories/actions-and-packages). If you do want to contribute, please run [prettier](https://prettier.io/) to format your code and add unit tests as appropriate before submitting your PR. [./testdata](./testdata) contains test cases that all implementations should pass, please also make sure those tests are still passing. From d0524937cda73bd855df1d41bceed8ff9d16a7aa Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 23 Jan 2023 18:04:54 -0800 Subject: [PATCH 07/10] Use github package names --- actions-expressions/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions-expressions/README.md b/actions-expressions/README.md index 2e1ec05..7183a6f 100644 --- a/actions-expressions/README.md +++ b/actions-expressions/README.md @@ -15,7 +15,7 @@ npm install @github/actions-expressions ### Simple example ```ts -import { Parser, Lexer, Evaluator, data } from '@actions/expressions'; +import { Parser, Lexer, Evaluator, data } from '@github/actions-expressions'; const lexer = new Lexer("1 == 2"); const lr = lexer.lex(); @@ -32,7 +32,7 @@ console.log(result.coerceString()) // false ### With context data ```ts -import { Parser, Lexer, Evaluator, data } from '@actions/expressions'; +import { Parser, Lexer, Evaluator, data } from '@github/actions-expressions'; const lexer = new Lexer("'monalisa' == context.name"); const lr = lexer.lex(); From 6f311e2f6c8b21585f0f220f7e0c35e2aee61464 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Tue, 24 Jan 2023 08:15:27 -0800 Subject: [PATCH 08/10] Request issues before PRs --- CONTRIBUTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4593f13..e637b4e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,21 @@ Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. +We accept pull requests for bug fixes and features where we've discussed the approach in an issue and given the go-ahead for a community member to work on it. We'd also love to hear about ideas for new features as issues. + +Please do: + +* Check existing issues to verify that the [bug][bug issues] or [feature request][feature request issues] has not already been submitted. +* Open an issue if things aren't working as expected. +* Open an issue to propose a significant change. +* Open a pull request to fix a bug. +* Open a pull request to fix documentation about a command. +* Open a pull request for any issue labelled [`help wanted`][hw] or [`good first issue`][gfi]. + +Please avoid: + +* Opening pull requests for issues marked `needs-design`, `needs-investigation`, or `blocked`. + Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE.md). Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms. From ceb58b4f105f3bc303c9f5ecabf3889c0f45c9dd Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Tue, 24 Jan 2023 10:14:39 -0800 Subject: [PATCH 09/10] Use @actions package names --- actions-expressions/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions-expressions/README.md b/actions-expressions/README.md index 7183a6f..8aaf370 100644 --- a/actions-expressions/README.md +++ b/actions-expressions/README.md @@ -4,7 +4,7 @@ ## Installation -The [package](https://www.npmjs.com/package/@github/actions-expressions) contains TypeScript types and compiled ECMAScript modules. +The [package](https://www.npmjs.com/package/@actions/expressions) contains TypeScript types and compiled ECMAScript modules. ```bash npm install @github/actions-expressions @@ -15,7 +15,7 @@ npm install @github/actions-expressions ### Simple example ```ts -import { Parser, Lexer, Evaluator, data } from '@github/actions-expressions'; +import { Parser, Lexer, Evaluator, data } from '@actions/expressions'; const lexer = new Lexer("1 == 2"); const lr = lexer.lex(); @@ -32,7 +32,7 @@ console.log(result.coerceString()) // false ### With context data ```ts -import { Parser, Lexer, Evaluator, data } from '@github/actions-expressions'; +import { Parser, Lexer, Evaluator, data } from '@actions/expressions'; const lexer = new Lexer("'monalisa' == context.name"); const lr = lexer.lex(); From 21d6d6b0ec662d1c1c4396d1d0ed7f3d1043b031 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Tue, 24 Jan 2023 16:26:00 -0800 Subject: [PATCH 10/10] Specify node version --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e637b4e..ef64c42 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,15 +27,17 @@ Please note that this project is released with a [Contributor Code of Conduct][c ## Prerequisites for running and testing code +This repository contains multiple packages and uses [npm workspaces](https://docs.npmjs.com/cli/v9/using-npm/workspaces?v=true) to manage the dependencies between them. + These are one time installations required to be able to test your changes locally as part of the pull request (PR) submission process. -1. Install [Node.js](https://nodejs.org/en/download/) for your platform +1. Install [Node.js](https://nodejs.org/en/download/) for your platform (>= version 18). Ensure you also use a recent version of `npm` that supports workspaces (>= version 7). 1. Install the dependencies. From the repository root run: ```bash $ npm i ``` -This repository contains multiple packages and uses [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) to manage the dependencies between them. + ## Submitting a pull request