Skip to content

Commit

Permalink
feat: initial GH action commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodore Georgomanolis committed Aug 10, 2022
1 parent 51ffa61 commit 348cfa6
Show file tree
Hide file tree
Showing 14 changed files with 305 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Exclude everything
*

# Allow
!entrypoint.sh
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text=auto

*.md text
*.yaml text
*.yml text
*.sh eol=lf
Dockerfile text
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These owners will be the default owners for everything in
# the repo.
#
* @theodore86
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--- Provide a general summary of your changes in the Title above -->
## Description
<!--- Describe your changes in detail -->

#### Related Issues
<!--- Does this relate to any issues? -->
Addresses
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: "Production release"
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
build:
name: 'Create Release'
runs-on: ubuntu-latest
steps:
- name: 'Checkout code'
uses: 'actions/[email protected]'

- name: 'Produce release body'
id: 'git_log'
uses: 'beatlabs/[email protected]'
with:
tag_regex: "v[0-9]+.[0-9]+.[0-9]+"

- name: 'Create release'
id: 'create_release'
uses: 'actions/[email protected]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.git_log.outputs.release_body }}
draft: false
prerelease: false
...
13 changes: 13 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Shellcheck
on:
pull_request:
paths:
- '**.sh'

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/[email protected]
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team members (@hwoarang).
All complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Contributing to this project

- Create your feature branch.
- Make your changes
- Open a pull request.
- Make sure that CI tests are passing.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM quay.io/coreos/po-tooling:release-0.48
LABEL maintainer="[email protected]"

WORKDIR /app
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh

ENTRYPOINT ["/app/entrypoint.sh"]
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# prometheus-operator-github-action
# Prometheus Operator GitHub Action

## Introduction
This simple GitHub Action allows to run [po-lint](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/user-guides/linting.md) on kubernetes [prometheus operator](https://github.com/prometheus-operator/prometheus-operator) CRDs.

## Usage
```yaml
name: Check PrometheusRule CRDs
on:
pull_request:

jobs:
polint:
name: Prometheus operator lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: taxibeat/prometheus-operator-github-action@v1
with:
path: './rules'
exclude: '.*test.*'
```
30 changes: 30 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: 'Prometheus Operator (Lint) Github Action'
description: 'Run po-lint (linting) against PrometheusRules CRDs'
author: 'Theodore Georgomanolis'
inputs:
path:
description: 'Path to Prometheus operator rules'
required: false
default: './'
glob_pattern:
description: 'Rule file extension as glob pattern'
required: false
default: '*.y*ml'
exclude:
description: 'Regex to exclude files or folders from linting'
required: false
default: ''

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.path }}
- ${{ inputs.global_pattern }}
- ${{ inputs.exclude }}

branding:
icon: 'terminal'
color: 'blue'
...
73 changes: 73 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
set -o noglob

error() {
echo >&2 ":: [Error]: $*"
exit 1
}

info() {
echo >&1 ":: [Info]: $*"
return 0
}

_command() {
local _return cmd
cmd="$1"
_return=1
command -v "$cmd" >/dev/null && _return=0
return ${_return}
}

# shellcheck disable=SC2086
_find() {
local path="$1"
local glob_pattern="${2:-*.y*ml}"
local cmd="$path -name ${glob_pattern}"
local files
files="$(find $cmd)"
echo "$files"
}

_check() {
local files="$1"
local exclude="${2:-""}"
local errors=0
for file in $files; do
if [[ -n $exclude ]]; then
if echo "$file" | grep -Eq "$exclude"; then
info "Skipping file: $file"
continue
fi
fi
info "Checking file: $file"
if ! '/go/bin/po-lint' "$file"; then
((errors+=1))
fi
done
return $errors
}

lint() {
local path="$1"
local glob_pattern="${2:-*.y*ml}"
local exclude="${3:-""}"
_command '/go/bin/po-lint' || error "'po-lint' linter not installed"
local files
files=$(_find "$path" "${glob_pattern}")
info "Linting '${glob_pattern}' files in '${path}' directory"
_check "$files" "$exclude"
}

main() {
local path="$1"
local glob_pattern="${2:-*.y*ml}"
local exclude="${3:-""}"
[[ ! -d $path ]] && error "$path directory not found"
if ! lint "$path" "${glob_pattern}" "$exclude"; then
error "Linting failed"
fi
info "Linting succeded"
}

main "$@"

0 comments on commit 348cfa6

Please sign in to comment.