Skip to content
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

Stencil module consumption not working #144

Open
rblin081 opened this issue Aug 30, 2024 · 5 comments
Open

Stencil module consumption not working #144

rblin081 opened this issue Aug 30, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@rblin081
Copy link

Following the instructions from https://stencil.rgst.io/guide/basic-module.html, here's my notes from each step.

Step 1 - Create the stencil module

mkdir helloworld; cd helloworld
helloworld % stencil create module github.com/yourorg/helloworld
INFO stencil 0.9.0
INFO Fetching dependencies
INFO Loading native extensions
INFO Rendering templates
INFO Writing template(s) to disk
INFO Running post-run command(s)
helloworld % ls
stencil.lock    stencil.yaml

Between steps 1 and 2 I'd expect the templates directory to be created automatically, I can't think of a scenario where there wouldn't be templates for a module. Moving on...

Step 2 - Create a template in the module

mkdir templates
helloworld % echo 'print("Hello World")' > hello_world.py
helloworld % ls  
hello_world.py  stencil.lock    stencil.yaml

Step 3 - Create the consuming application

% mkdir testapp; cd testapp
testapp % cat >stencil.yaml <<EOF
name: testapp
modules:
  - name: github.com/yourorg/helloworld

replacements:
  # Replace ../helloworld with the path to your module.
  github.com/yourorg/helloworld: ../helloworld
EOF
testapp % stencil
INFO stencil 0.9.0
INFO Fetching dependencies
ERRO failed to run error="open ../helloworld/manifest.yaml: no such file or directory"

Again I'd expect a manifest.yaml to be generated from stencil create module. Constructing a simplified manifest using https://github.com/rgst-io/stencil-golang/blob/e2ea9a1980f765f668d4a42d1f9108db777bf86d/manifest.yaml as an example

helloworld/manifest.yaml

# yaml-language-server: $schema=https://raw.githubusercontent.com/rgst-io/stencil/main/schemas/manifest.jsonschema.json
name: github.com/yourorg/helloworld
type: templates,extension

Trying again...

testapp % stencil
INFO stencil 0.9.0
INFO Fetching dependencies
INFO  -> github.com/yourorg/helloworld 
INFO Loading native extensions
ERRO failed to run error="failed to load extensions from module \"github.com/yourorg/helloworld\": failed to create connection to extension: fork/exec ../helloworld/bin/plugin: no such file or directory"

This is where I'm unsure to progress. rgst-io/stencil-goloang GitHub doesn't have a /bin and I'm unsure how it's generated

@jaredallard
Copy link
Member

Sorry for the trouble again 😭

stencil create module used to create everything, butttt as we forked it parts got cleaned up as we separated from Outreach.

The issue here right now is type being set to both templates,extension. Since you're not writing a native extension right now, you can actually remove the type field altogether. That should resolve this problem

@jaredallard
Copy link
Member

As for the bin directory, for the local development process of a stencil native extension, it will look for bin/plugin as the binary to run.

That used to be created automatically with the plugin framework we had (and will be again when I get that created on the rgst-io org).

So, if you end up implementing a native extension (following these docs), you'll end up compiling the binary (via go build, if using Go) to bin/plugin.

@jaredallard jaredallard added the bug Something isn't working label Aug 30, 2024
@rblin081
Copy link
Author

rblin081 commented Aug 30, 2024

Hmm unfortunately still not seeing this work.

After modifying helloworld/manifest.yaml to

# yaml-language-server: $schema=https://raw.githubusercontent.com/rgst-io/stencil/main/schemas/manifest.jsonschema.json
name: github.com/yourorg/helloworld

with a directory structure of

helloworld/
   templates/
        hello_world.py
   manifest.yaml
   stencil.yaml
   stencil.lock

From test-app

testapp % ls
stencil.lock    stencil.yaml
testapp % stencil
INFO stencil 0.9.0
INFO Fetching dependencies
INFO  -> github.com/yourorg/helloworld 
INFO Loading native extensions
INFO Rendering templates
INFO Writing template(s) to disk
INFO Running post-run command(s)
testapp % ls
stencil.lock    stencil.yamltestapp % 

Not receiving an error anymore (yay) but also not seeing an files be rendered from the template(s).

@jaredallard
Copy link
Member

jaredallard commented Aug 30, 2024

Aha, you need the .tpl extension on hello_world.py (e.g., hello_world.py.tpl)

@jaredallard
Copy link
Member

@rblin081 I'm assuming from your other issue that you got past this, am I right? 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants