From 25b1f80eab07e18bedb7f998dd3aeb849a35fc7f Mon Sep 17 00:00:00 2001 From: Sergio Ribera <56278796+SergioRibera@users.noreply.github.com> Date: Sun, 22 Sep 2024 20:53:41 -0400 Subject: [PATCH] ci: add check workflows --- .github/workflows/ci.yml | 178 +++++++++++++++++++++++++++++++++++++++ cargo-generate.toml | 2 +- 2 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f7ccd9d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,178 @@ +name: Check Template + +on: + workflow_dispatch: + push: + branches: [ 'main' ] + paths-ignore: + - "**.md" + +env: + CARGO_GEN_VERSION: "0.20.0" + +jobs: + theme-plugin: + name: Test Theme Plugin + runs-on: ubuntu-latest + env: + PROJECT_NAME: test-theme + steps: + - uses: actions/checkout@v4 + - name: Install cargo generate + run: | + curl --silent -L "https://github.com/cargo-generate/cargo-generate/releases/download/v$CARGO_GEN_VERSION/cargo-generate-v$CARGO_GEN_VERSION-x86_64-unknown-linux-musl.tar.gz" | tar xzv -C /usr/bin/ + - name: Generate Test + run: | + cargo-generate \ + --verbose \ + --path . \ + --name "${{ env.PROJECT_NAME }}" \ + -d license='all' \ + -d description='Theme Test Description' \ + -d plugin_name='Theme Test' \ + -d plugin_id='test-theme' \ + -d deploy_release=true \ + -d plugin_type='Theme' \ + -d theme_name='Theme Test' + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - run: | + mv $PROJECT_NAME ${{ runner.temp }}/ + cd ${{ runner.temp }}/$PROJECT_NAME + # Validaciones para el plugin de tema + if [ ! -f "themes/test-theme.json" ]; then + echo "Theme JSON file not generated" + exit 1 + fi + + slash-command-plugin: + name: Test Slash Command Plugin + runs-on: ubuntu-latest + env: + PROJECT_NAME: test-slash + steps: + - uses: actions/checkout@v4 + - name: Install cargo generate + run: | + curl --silent -L "https://github.com/cargo-generate/cargo-generate/releases/download/v$CARGO_GEN_VERSION/cargo-generate-v$CARGO_GEN_VERSION-x86_64-unknown-linux-musl.tar.gz" | tar xzv -C /usr/bin/ + - name: Generate Test + run: | + cargo-generate \ + --verbose \ + --path . \ + --name "${{ env.PROJECT_NAME }}" \ + --verbose + -d license='all' + -d description='Test Slash Command' + -d plugin_name='Slash Command Test' + -d plugin_id='test-slash-command' + -d deploy_release=true + -d plugin_type='Slash Command' + -d slash_command_name='test-slash' + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - run: | + mv $PROJECT_NAME ${{ runner.temp }}/ + cd ${{ runner.temp }}/$PROJECT_NAME + # Validaciones para el plugin de slash command + if [ ! -f "src/test-slash.rs" ]; then + echo "Slash command file not generated" + exit 1 + fi + cargo check + + language-plugin-no-ts: + name: Test Lang Plugin without TreeSitter + runs-on: ubuntu-latest + env: + PROJECT_NAME: test-lang + steps: + - uses: actions/checkout@v4 + - name: Install cargo generate + env: + CARGO_GEN_VERSION: "0.20.0" + run: | + curl --silent -L "https://github.com/cargo-generate/cargo-generate/releases/download/v$CARGO_GEN_VERSION/cargo-generate-v$CARGO_GEN_VERSION-x86_64-unknown-linux-musl.tar.gz" | tar xzv -C /usr/bin/ + - name: Generate Test + run: | + cargo-generate \ + --verbose \ + --path . \ + --name "${{ env.PROJECT_NAME }}" \ + -d license='all' \ + -d description='Lang LSP Test' \ + -d plugin_name='Language LSP Test Plugin' \ + -d plugin_id='test-lang' \ + -d deploy_release=true \ + -d plugin_type='Language Server' \ + -d lsp_name='test-lang-lsp' \ + -d language_name='Lang' \ + -d lsp_repo='RustLangES/test-lang-lsp-repo' \ + -d use_tree_sitter=false + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - run: | + mv $PROJECT_NAME ${{ runner.temp }}/ + cd ${{ runner.temp }}/$PROJECT_NAME + # Validaciones para el plugin de lenguaje sin TreeSitter + if [ ! -f "src/test-lang-lsp.rs" ]; then + echo "Language server file not generated" + exit 1 + fi + if grep -q "tree_sitter" extension.toml; then + echo "Unexpected TreeSitter configuration found" + exit 1 + fi + cargo check + + language-plugin-ts: + name: Test Lang Plugin with TreeSitter + runs-on: ubuntu-latest + env: + PROJECT_NAME: test-lang-ts + steps: + - uses: actions/checkout@v4 + - name: Install cargo generate + run: | + curl --silent -L "https://github.com/cargo-generate/cargo-generate/releases/download/v$CARGO_GEN_VERSION/cargo-generate-v$CARGO_GEN_VERSION-x86_64-unknown-linux-musl.tar.gz" | tar xzv -C /usr/bin/ + - name: Generate Test + run: | + cargo-generate \ + --verbose \ + --path . \ + --name "${{ env.PROJECT_NAME }}" \ + -d license='all' \ + -d description='Lang LSP Test with TS' \ + -d plugin_name='Language LSP Test Plugin with TS' \ + -d plugin_id='test-lang-ts' \ + -d deploy_release=true \ + -d plugin_type='Language Server' \ + -d lsp_name='test-lang-lsp-ts' \ + -d language_name='LangTs' \ + -d lsp_repo='RustLangES/test-lang-lsp-repo' \ + -d use_tree_sitter=true \ + -d ts_repo='RustLangES/test-lang-ts-repo' \ + -d ts_commit='433af5e21f3d2a1639a875c1b2df898c596c774e' + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - run: | + mv $PROJECT_NAME ${{ runner.temp }}/ + cd ${{ runner.temp }}/$PROJECT_NAME + # Validaciones para el plugin de lenguaje con TreeSitter + if [ ! -f "src/test-lang-lsp-ts.rs" ]; then + echo "Language server file not generated" + exit 1 + fi + if ! grep -q "tree_sitter" extension.toml; then + echo "TreeSitter configuration not found" + exit 1 + fi + if ! grep -q "433af5e21f3d2a1639a875c1b2df898c596c774e" extension.toml; then + echo "TreeSitter commit hash not found in configuration" + exit 1 + fi + cargo check diff --git a/cargo-generate.toml b/cargo-generate.toml index 9215d86..c787f51 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -56,7 +56,7 @@ ignore = ["themes"] [conditional.'plugin_type == "Slash Command"'.placeholders] slash_command_name = { type = "string", prompt = "Enter the name of your slash command" } -[conditional.'plugin_type != "Slash Command"'] +[conditional.'plugin_type == "Theme"'] ignore = ["src/{{slash_command_name}}.rs"] # License files