mirror of
https://github.com/hadolint/hadolint-action.git
synced 2024-08-16 10:09:53 +02:00
feat: first commit
This commit is contained in:
commit
0c77515c56
12 changed files with 260 additions and 0 deletions
25
.editorconfig
Normal file
25
.editorconfig
Normal file
|
@ -0,0 +1,25 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[{Dockerfile,Dockerfile.template.erb,Dockerfile.sample}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
81
.github/workflows/ci.yml
vendored
Normal file
81
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
name: "CI"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
TEST_IMAGE_NAME: hadolint-action:${{github.sha}}
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
container: pipelinecomponents/hadolint:latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Run hadolint
|
||||
run: hadolint Dockerfile
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ['lint']
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Build Docker image
|
||||
run: docker build -t $TEST_IMAGE_NAME .
|
||||
|
||||
- name: Save Docker image artifact
|
||||
run: docker save -o action.tar $TEST_IMAGE_NAME
|
||||
|
||||
- name: Upload image artifact
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: action-image
|
||||
path: action.tar
|
||||
|
||||
test:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Pull Image artifact
|
||||
uses: actions/download-artifact@master
|
||||
with:
|
||||
name: action-image
|
||||
|
||||
- name: Load image into docker context
|
||||
run: docker load -i action-image/action.tar
|
||||
|
||||
- name: Get Image Name
|
||||
id: image_name
|
||||
run: echo "##[set-output name=image;]$(echo $TEST_IMAGE_NAME)"
|
||||
|
||||
- name: Run Structure tests
|
||||
uses: brpaz/structure-tests-action@master
|
||||
with:
|
||||
image: ${{ steps.image_name.outputs.image }}
|
||||
|
||||
integration:
|
||||
name: Integration Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: ./
|
||||
with:
|
||||
dockerfile: testdata/Dockerfile
|
||||
|
||||
release:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: integraiton
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Semantic Release
|
||||
uses: brpaz/action-semantic-release@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
5
.hadolint.yml
Normal file
5
.hadolint.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Hadolint configuration file
|
||||
|
||||
# configure ignore rules
|
||||
# see https://github.com/hadolint/hadolint#rules for a list of available rules.
|
||||
ignored: []
|
12
.pre-commit-config.yaml
Normal file
12
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
- repo: local
|
||||
hooks:
|
||||
- id: lint-dockerfile
|
||||
name: Lint Dockerfile
|
||||
entry: make lint-dockerfile
|
||||
language: system
|
||||
files: \.yml$
|
||||
- id: lint-yaml
|
||||
name: Lint YAML
|
||||
entry: make lint-yaml
|
||||
language: system
|
||||
files: \.yml$
|
8
.yamllint
Normal file
8
.yamllint
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends: default
|
||||
|
||||
rules:
|
||||
# 80 chars should be enough, but don't fail if a line is longer
|
||||
line-length:
|
||||
max: 80
|
||||
level: warning
|
||||
document-start: disable
|
5
Dockerfile
Normal file
5
Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
|||
FROM hadolint/hadolint:v1.17.2
|
||||
|
||||
COPY LICENSE README.md /
|
||||
|
||||
CMD ["hadolint"]
|
22
LICENSE
Normal file
22
LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Bruno Paz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
25
Makefile
Normal file
25
Makefile
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
IMAGE_NAME:=hadolint-action
|
||||
|
||||
lint-dockerfile: ## Runs hadoint against application dockerfile
|
||||
@docker run --rm -v "$(PWD):/data" -w "/data" hadolint/hadolint hadolint Dockerfile
|
||||
|
||||
lint-yaml: ## Lints yaml configurations
|
||||
@docker run --rm -v "$(PWD):/yaml" sdesbure/yamllint yamllint .
|
||||
|
||||
build: ## Builds the docker image
|
||||
@docker build . -t $(IMAGE_NAME)
|
||||
|
||||
test: build ## Runs a test in the image
|
||||
@docker run -i --rm \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v ${PWD}:/test zemanlx/container-structure-test:v1.8.0-alpine \
|
||||
test \
|
||||
--image $(IMAGE_NAME) \
|
||||
--config test/structure-tests.yaml
|
||||
|
||||
help:
|
||||
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
.PHONY: lint build test help
|
51
README.md
Normal file
51
README.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
# hadolint-action Action
|
||||
|
||||
> Action that runs [Hadolint](https://github.com/hadolint/hadolint) Dockerfile linting tool.
|
||||
|
||||
[![GitHub Action](https://img.shields.io/badge/GitHub-Action-blue?style=for-the-badge)](https://github.com/features/actions)
|
||||
[![License](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](LICENSE)
|
||||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge)](http://commitizen.github.io/cz-cli/)
|
||||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge)](https://github.com/semantic-release/semantic-release?style=for-the-badge)
|
||||
|
||||
[![GitHub Actions](https://github.com/brpaz/hadolint-action/workflows/CI/badge.svg?style=for-the-badge)](https://github.com/brpaz/hadolint-action/actions)
|
||||
|
||||
## Usage
|
||||
|
||||
```yml
|
||||
steps:
|
||||
uses: brpaz/hadolint-action@master
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
**`dockerfile`**
|
||||
|
||||
The path to the Dockerfile to be tested. By default it will look for a Dockerfile in the current directory.
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
||||
|
||||
1. Fork the Project
|
||||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
||||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
||||
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
||||
5. Open a Pull Request
|
||||
|
||||
## Useful Resources
|
||||
|
||||
* [Building actions - GitHub Help](https://help.github.com/en/articles/building-actions)
|
||||
* [actions/toolkit: The GitHub ToolKit for developing GitHub Actions.](https://github.com/actions/toolkit)
|
||||
|
||||
## Author
|
||||
|
||||
👤 **Bruno Paz**
|
||||
|
||||
* Website: [https://github.com/brpaz](https://github.com/brpaz)
|
||||
* Github: [@brpaz](https://github.com/brpaz)
|
||||
|
||||
## 📝 License
|
||||
|
||||
Copyright © 2019 [Bruno Paz](https://github.com/brpaz).
|
||||
|
||||
This project is [MIT](LICENSE) licensed.
|
15
action.yml
Normal file
15
action.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
name: 'Hadolint'
|
||||
description: 'Action that runs Hadolint Dockerfile linting tool'
|
||||
author: 'Bruno Paz'
|
||||
inputs:
|
||||
dockerfile:
|
||||
description: 'The path to the Dockerfile to lint'
|
||||
default: 'Dockerfile'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.dockerfile }}
|
||||
branding:
|
||||
icon: 'layers'
|
||||
color: 'purple'
|
8
structure-tests.yaml
Normal file
8
structure-tests.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
schemaVersion: 2.0.0
|
||||
|
||||
commandTests:
|
||||
- name: "Check hadolint is installed"
|
||||
command: hadolint
|
||||
args: ['-v']
|
||||
expectedOutput: ["Haskell Dockerfile Linter"]
|
||||
exitCode: 0
|
3
testdata/Dockerfile
vendored
Normal file
3
testdata/Dockerfile
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
FROM alpine:3.10
|
||||
|
||||
RUN echo "Hello"
|
Loading…
Reference in a new issue