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

Replace syntax checks with puppet-syntax #73

Merged
merged 2 commits into from
Jul 29, 2014
Merged

Replace syntax checks with puppet-syntax #73

merged 2 commits into from
Jul 29, 2014

Conversation

dcarley
Copy link
Contributor

@dcarley dcarley commented Jul 28, 2014

Use an external gem to check the syntax of Puppet manifests and templates
(and hiera YAML files, but these won't exist in most modules).

This gem has some additional features from the original checks:

  • Configurable exclude paths.
  • Catches logged warnings from Puppet and Ruby.
  • Outputs any errors encountered.
  • Test coverage (in addition to the parser face).

I wasn't previously aware that these checks were in puppetlabs_spec_helper
until we got a bug report in voxpupuli/puppet-syntax#13 to say that
PuppetSyntax.exclude_paths wasn't working correctly.

It turns out that Rake was running the :syntax tasks from both projects and
that psh, where you can't configure exclude paths and no error message is
printed, was returning a non-zero exit code.

The :syntax task has been replaced by a require for puppet-syntax and the
exclude paths setup to match puppet-lint. I haven't wrapped this in a task
like :lint because it behaves non-deterministically; if the task from
puppet-syntax is run before this one then exclude_paths won't be set
correctly.

The :validate task still checks Ruby files and then calls :syntax in place
of the shell commands it previously ran. There's quite a lot of overlap
between :validate and :syntax. In the future it might be worth adding Ruby
syntax checks for Puppet plugins to puppet-syntax and deprecating the
:validate task.


Also enabled support for the FUTURE_PARSER environment variable.


/cc @dalen @cmurphy who originally added these checks.
/cc @treydock who reported the error on puppet-syntax.

Use an external gem to check the syntax of Puppet manifests and templates
(and hiera YAML files, but these won't exist in most modules).

This gem has some additional features from the original checks:

- Configurable exclude paths.
- Catches logged warnings from Puppet and Ruby.
- Outputs any errors encountered.
- Test coverage (in addition to the parser face).

I wasn't previously aware that these checks were in puppetlabs_spec_helper
until we got a bug report in voxpupuli/puppet-syntax#13 to say that
`PuppetSyntax.exclude_paths` wasn't working correctly.

It turns out that Rake was running the :syntax tasks from both projects and
that psh, where you can't configure exclude paths and no error message is
printed, was returning a non-zero exit code.

The :syntax task has been replaced by a require for puppet-syntax and the
exclude paths setup to match puppet-lint. I haven't wrapped this in a task
like :lint because it behaves non-deterministically; if the task from
puppet-syntax is run before this one then `exclude_paths` won't be set
correctly.

The :validate task still checks Ruby files and then calls :syntax in place
of the shell commands it previously ran. There's quite a lot of overlap
between :validate and :syntax. In the future it might be worth adding Ruby
syntax checks for Puppet plugins to puppet-syntax and deprecating the
:validate task.
Enable puppet-syntax's future_parser option if the FUTURE_PARSER environment
variable, described in this project's README, is set to "yes".
hunner added a commit that referenced this pull request Jul 29, 2014
Replace syntax checks with puppet-syntax
@hunner hunner merged commit 9159d9f into puppetlabs:master Jul 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants