-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
177 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore everything | ||
** | ||
|
||
# Allow files and directories | ||
!/codeowners-validator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Get latest CA certs & git | ||
FROM alpine:latest as deps | ||
RUN apk --update add ca-certificates | ||
RUN apk --update add git | ||
|
||
FROM scratch | ||
|
||
ARG prefix="" | ||
ENV ENVS_PREFIX=${prefix} | ||
|
||
LABEL source=https://github.com/mszostok/codeowners-validator.git | ||
|
||
COPY ./codeowners-validator /codeowners-validator | ||
|
||
COPY --from=deps /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=deps /usr/bin/git /usr/bin/git | ||
COPY --from=deps /usr/bin/xargs /usr/bin/xargs | ||
COPY --from=deps /lib /lib | ||
COPY --from=deps /usr/lib /usr/lib | ||
|
||
CMD ["/codeowners-validator"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: "GitHub CODEOWNERS Validator" | ||
description: "Github action to ensure the correctness of your CODEOWNERS file." | ||
author: "[email protected]" | ||
|
||
inputs: | ||
github_access_token: | ||
description: "The GitHub access token. Instruction for creating a token can be found here. If not provided then validating owners functionality could not work properly, e.g. you can reach the API calls quota or if you are setting GitHub Enterprise base URL then an unauthorized error can occur." | ||
required: false | ||
|
||
github_base_url: | ||
description: "The GitHub base URL for API requests. Defaults to the public GitHub API, but can be set to a domain endpoint to use with GitHub Enterprise. Default: https://api.github.com/" | ||
required: false | ||
|
||
github_upload_url: | ||
description: "The GitHub upload URL for uploading files. It is taken into account only when the GITHUB_BASE_URL is also set. If only the GITHUB_BASE_URL is provided then this parameter defaults to the GITHUB_BASE_URL value. Default: https://uploads.github.com/" | ||
required: false | ||
|
||
experimental_checks: | ||
description: "The comma-separated list of experimental checks that should be executed. By default, all experimental checks are turned off. Possible values: notowned." | ||
default: "" | ||
required: false | ||
|
||
checks: | ||
description: "The list of checks that will be executed. By default, all checks are executed. Possible values: files,owners,duppatterns" | ||
required: false | ||
default: "" | ||
|
||
repository_path: | ||
description: "The repository path in which CODEOWNERS file should be validated." | ||
required: false | ||
default: "." | ||
|
||
check_failure_level: | ||
description: "Defines the level on which the application should treat check issues as failures. Defaults to warning, which treats both errors and warnings as failures, and exits with error code 3. Possible values are error and warning. Default: warning" | ||
required: false | ||
|
||
not_owned_checker_skip_patterns: | ||
description: "The comma-separated list of patterns that should be ignored by not-owned-checker. For example, you can specify * and as a result, the * pattern from the CODEOWNERS file will be ignored and files owned by this pattern will be reported as unowned unless a later specific pattern will match that path. It's useful because often we have default owners entry at the begging of the CODOEWNERS file, e.g. * @global-owner1 @global-owner2" | ||
required: false | ||
|
||
owner_checker_repository: | ||
description: "The owner and repository name. For example, gh-codeowners/codeowners-samples. Used to check if GitHub team is in the given organization and has permission to the given repository." | ||
required: false | ||
default: "${{ github.repository }}" | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'docker://mszostok/codeowners-validator@canary' | ||
env: | ||
ENVS_PREFIX: "INPUT" | ||
INPUT_USED_AS_GITHUB_ACTION: "true" | ||
|
||
branding: | ||
icon: "shield" | ||
color: "gray-dark" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# standard bash error handling | ||
set -o nounset # treat unset variables as an error and exit immediately. | ||
set -o errexit # exit immediately when a command fails. | ||
set -E # needs to be set if we want the ERR trap | ||
|
||
readonly CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
readonly ROOT_PATH=$( cd "${CURRENT_DIR}/../.." && pwd ) | ||
readonly GOLANGCI_LINT_VERSION="v1.23.8" | ||
|
||
source "${CURRENT_DIR}/utilities.sh" || { echo 'Cannot load CI utilities.'; exit 1; } | ||
|
||
# This will find all files (not symlinks) with the executable bit set: | ||
# https://apple.stackexchange.com/a/116371 | ||
binariesToCompress=$(find "${ROOT_PATH}/dist" -perm +111 -type f) | ||
|
||
shout "Staring compression for: \n$binariesToCompress" | ||
|
||
# Kudos for https://liam.sh/post/makefiles-for-go-projects | ||
command -v upx > /dev/null || { echo 'UPX binary not found, skipping compression.'; exit 1; } | ||
|
||
# I just do not like playing with xargs ¯\_(ツ)_/¯ | ||
for i in $binariesToCompress | ||
do | ||
upx --brute "$i" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package envconfig | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/vrischmann/envconfig" | ||
) | ||
|
||
// Init the given config. Supports also envs prefix if set. | ||
func Init(conf interface{}) error { | ||
envPrefix := os.Getenv("ENVS_PREFIX") | ||
return envconfig.InitWithPrefix(conf, envPrefix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters