Github Actions expressions grammar for tree-sitter
Project description
tree-sitter-gh-actions-expressions
Tree-sitter grammar for Github Actions expressions
[!IMPORTANT] ABI version:
15
Parser requirements
gitignore(optional): forhashFiles()functionjson(optional): forfromJSON()functionyaml: injection to itsblock_mapping_pairnode. Check theyamlinjection section for more information
Usage in Editors
Neovim
gh-actions.nvim: plugin that integrates this grammar to yourNeovimconfiguration
Helix
WIP
Emacs
WIP
In General
You can get the built files from the release branch. If you
have specific instructions for your editor, PR's are welcome.
Injection for yaml parser
Use the following query:
((block_mapping_pair
key: (flow_node) @_key
value: [
(block_node
(block_scalar) @_value)
(flow_node
[
(plain_scalar
(string_scalar) @_value)
(double_quote_scalar) @_value
])
]
(#lua-match? @_value "${{")) @injection.content
(#is-gh-actions-file? "") ; NOTE: NEW PREDICATE
(#set! injection.language "gh_actions_expressions")
(#set! injection.include-children))
((block_mapping_pair
key: (flow_node) @_key
(#eq? @_key "if")
value: (flow_node
(plain_scalar
(string_scalar) @_value)
(#not-lua-match? @_value "${{"))) @injection.content
(#is-gh-actions-file? "") ; NOTE: NEW PREDICATE
(#set! injection.language "gh_actions_expressions")
(#set! injection.include-children))
is-gh-actions-file predicate
To avoid injecting this grammar to files other than github actions, is
recommended to create a predicate named is-gh-actions-file.
[!NOTE] The creation of this directive varies for each editor
This predicate will be the responsible to allow injection to files that matches
the name pattern .github/workflows/*.ya?ml.
Implementations
gh-actions.nvim
Troubleshooting
AST errors within bash injections when using run key
To avoid these errors, is recommended to surround the expression within a
raw_string node, string with single quotes ', i.e.:
jobs:
dry-run:
name: dry-run
runs-on: ubuntu-latest
steps:
- name: dry-run
run: ./script.sh '${{ inputs.mode }}' --dry-run
What if I need it within a variable expansion?
Because variable expansion is done by using $ prefix, the ${{ and }} nodes
will cause an AST error. To avoid this declare an auxiliary bash variable or an
environment variable:
jobs:
dry-run:
name: dry-run
runs-on: ubuntu-latest
steps:
- name: dry-run
run: |
auxiliary_var='${{ inputs.mode }}'
./script.sh "$MY_VAR and $MODE" --dry-run
./script.sh "$MY_VAR and $auxiliary_var" --dry-run
env:
MODE: ${{ inputs.mode }}
References
Thanks
Thanks to @disrupted for creating tree-sitter-github-actions grammar, which is the base I used to create this grammar.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1.tar.gz.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bae5c466dcd547ccfe1dbec02df5ad31a8be49235c480caa50961137d92734a
|
|
| MD5 |
5ab200553a3555995ce897bfd9753a28
|
|
| BLAKE2b-256 |
a4389b2eecdaf7ac53c0a3434e1134a0668d1d5a4d8c5ee6c539c2b14310c6ae
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 17.2 kB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b113d8b4f1c26e35809adecd1479c401b59f6394fced795f0d33d1fb519b560
|
|
| MD5 |
48f1fb16761929dd1e1361988d922724
|
|
| BLAKE2b-256 |
74ef8b072508462672e446c73be554b0ec0664cf5a9e5de10e7f91a324dd7d3c
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 18.2 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f6359937e9db3a7692e97e9f75c2cbdada050a856b4ffc1fb3276213bb918ae
|
|
| MD5 |
44c947e49abef5e9e0177d00bb3f9e16
|
|
| BLAKE2b-256 |
8408ecdf4559a310fa2320c1b625a4adb50d460b5fcf174a90fbefcbb4362a89
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 27.8 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dcaf7feda4c28d86488559b8d28ecdfeea43f2e0d4f78fe2a3ff12fb892f1d3
|
|
| MD5 |
e2d1e8afa3806737f97915fccc5436cd
|
|
| BLAKE2b-256 |
c6998f712a3321e608fea4ce757cbf1cbc72f826f16228b1c59bce0a5dc773b2
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 29.3 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb07f57ee9b17a41ddf1710e3fb64596d4482826fd996eac2986277dc2490b0d
|
|
| MD5 |
8c93ec873728fce8d20a95e2f073187e
|
|
| BLAKE2b-256 |
d7dbe8d21150e63ecdcfb17a1235276215bf0dedbd385eff1d5c38ad56513c6a
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 30.2 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec4672b412e137748e91c702b47a461d1f2b388c31e7c1a95c80f501a520d512
|
|
| MD5 |
be9af0b90ff8807476582b988f405f96
|
|
| BLAKE2b-256 |
77a5978dbe36a0f0f62258344fbc65a94a57e2ccbc17df817ea00903b5e29293
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 28.0 kB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7af4b47783dbcf374ddd91e6d9df2520697ecbb90190b2498a252e38a77481a
|
|
| MD5 |
e806b7ad7272758c7bfc1bc2eb6941e3
|
|
| BLAKE2b-256 |
bdd6d90de2c3f668b2e02e98b719ee89f732d5ba2948514db0e10f4553fadb4e
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 16.6 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02aa6ae0c906f05efcb70c289fba6066e68a79ed6480d0c0733b4772fd6ba986
|
|
| MD5 |
3d7724c22fd6039167132af5e4281f80
|
|
| BLAKE2b-256 |
5da6f1818532635890c0b8cdeded492ce60844d7fab89a12c56c0376c0349798
|
File details
Details for the file tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_gh_actions_expressions-0.4.1-cp310-abi3-macosx_10_9_x86_64.whl
- Upload date:
- Size: 16.2 kB
- Tags: CPython 3.10+, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c420b3076d60d0d678374254df84d57f246e7c73861531a2af4276e31b48a1ab
|
|
| MD5 |
b1aa6d6c088418b3c3dedddf6f73994b
|
|
| BLAKE2b-256 |
c84e8e23c081035f5bba6ddf206b1af4a120bbb5dfd0fa082ab03b6e7dddee9a
|