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

Install BASH to enable and support globstar (**) #6

Merged

Conversation

ahtierney
Copy link
Contributor

@ahtierney ahtierney commented Jun 5, 2020

Description

Q A
Bug fix? Yes
New feature? Kinda

Issue

globstar doesn't work with the current container setup.

Background

Node Alpine ships with ash as a default shell. The globbing behaviors for ash don't include globstar, which is handy linting many files. Globstar is supported in glob, upon which the underlying linter depends.

Repro steps

From my understanding in ash, ** is resolved as * and doesn't search recursively. You can observe this by creating a nested directory structure and the command over it:

my-files/
├── one/
│   └── linted.md
│   ├── two/
│   │   └── not-linted.md
$ docker run --rm \
    -v "$(pwd)/my-files:/my-files:ro" \
    avtodev/markdown-lint:v1 \
    '/my-files/**/*.md'

With the markdownlint-cli running on a more robust shell, the expected behavior is that both files would be linted, but with ash only the first is.

Proposed fix

  • install bash in the dockerfile via apk.
    • pass no-cache to keep the size small.
  • run the entrypoint with bash and enable globstar.

With these changes, the above example will lint both markdown files.

Cost

This increases container size by ~2MB from my tests.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (commit history)
  • I have made changes in CHANGELOG.md file

ahtierney added 2 commits June 5, 2020 11:25
-- pass no-cache to keep the package small
- change shell to bash and enable globstar
@tarampampam
Copy link
Contributor

@ahtierney did you test it locally?

@ahtierney
Copy link
Contributor Author

Hey @tarampampam ! I did test locally. You can also test my minimum reproducible example locally using the "Repro steps" above. You should see that the production container only lints the file one.md and if you build a container locally with these changes it will lint both one.md and two.md.

@tarampampam
Copy link
Contributor

@ahtierney Great!

@tarampampam tarampampam merged commit fa82252 into avto-dev:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants