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

Rename to codeowners, extend configuration capabilities, add pre-commit-hook support #199

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
**

# Allow binary
!/codeowners-validator
!/codeowners
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
scripts/
.idea
codeowners-validator
/codeowners
dist/
tmp/
bin/
Expand Down
26 changes: 13 additions & 13 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
builds:
- id: codeowners-validator
- id: codeowners
env:
- CGO_ENABLED=0
goos:
Expand Down Expand Up @@ -35,15 +35,15 @@ archives:
dockers:
- dockerfile: Dockerfile
ids:
- codeowners-validator
- codeowners
image_templates:
- "ghcr.io/mszostok/codeowners-validator:stable"
- "ghcr.io/mszostok/codeowners-validator:{{ .Tag }}"
- "ghcr.io/mszostok/codeowners-validator:v{{ .Major }}.{{ .Minor }}"
- "ghcr.io/mszostok/codeowners-validator:v{{ .Major }}"
- "mszostok/codeowners-validator:latest"
- "mszostok/codeowners-validator:{{ .Tag }}"
- "mszostok/codeowners-validator:v{{ .Major }}.{{ .Minor }}"
- "ghcr.io/mszostok/codeowners:stable"
- "ghcr.io/mszostok/codeowners:{{ .Tag }}"
- "ghcr.io/mszostok/codeowners:v{{ .Major }}.{{ .Minor }}"
- "ghcr.io/mszostok/codeowners:v{{ .Major }}"
- "mszostok/codeowners:latest"
- "mszostok/codeowners:{{ .Tag }}"
- "mszostok/codeowners:v{{ .Major }}.{{ .Minor }}"

checksum:
name_template: 'checksums.txt'
Expand All @@ -68,11 +68,11 @@ release:
# Default is extracted from the origin remote URL or empty if its private hosted.
github:
owner: mszostok
name: codeowners-validator
name: codeowners

brews:
- name: codeowners-validator
homepage: https://github.com/mszostok/codeowners-validator
- name: codeowners
homepage: https://github.com/mszostok/codeowners
description: Ensures the correctness of your CODEOWNERS file.
license: "Apache License 2.0"
tap:
Expand All @@ -82,4 +82,4 @@ brews:
name: Mateusz Szostok
email: [email protected]
test: |
system "#{bin}/codeowners-validator -v --short"
system "#{bin}/codeowners -v --short"
6 changes: 6 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- id: codeowners
name: Validate CODEOWNERS file
description: Ensures the correctness of your CODEOWNERS file.
language: golang
# TODO: types: hardcode expected file location?
entry: codeowners validate
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ This document contains contribution guidelines for this repository. Read it befo

## Contributing

Before proposing or adding changes, check the [existing issues](https://github.com/mszostok/codeowners-validator/issues) and make sure the discussion/work has not already been started to avoid duplication.
Before proposing or adding changes, check the [existing issues](https://github.com/mszostok/codeowners/issues) and make sure the discussion/work has not already been started to avoid duplication.

If you'd like to see a new feature implemented, use this [feature request template](https://github.com/mszostok/codeowners-validator/issues/new?assignees=&labels=&template=feature_request.md) to create an issue.
If you'd like to see a new feature implemented, use this [feature request template](https://github.com/mszostok/codeowners/issues/new?assignees=&labels=&template=feature_request.md) to create an issue.

Similarly, if you spot a bug, use this [bug report template](https://github.com/mszostok/codeowners-validator/issues/new?assignees=mszostok&labels=bug&template=bug_report.md) to let us know!
Similarly, if you spot a bug, use this [bug report template](https://github.com/mszostok/codeowners/issues/new?assignees=mszostok&labels=bug&template=bug_report.md) to let us know!

### Ready for action? Start developing!

To start contributing, follow these steps:

1. Fork the `codeowners-validator` repository.
1. Fork the `codeowners` repository.

2. Clone the repository locally.

> **TIP:** This project uses Go modules, so you can check it out locally wherever you want. It doesn't need to be checked out in `$GOPATH`.

3. Set the `codeowners-validator` repository as upstream:
3. Set the `codeowners` repository as upstream:

```bash
git remote add upstream [email protected]:mszostok/codeowners-validator.git
git remote add upstream [email protected]:mszostok/codeowners.git
```

4. Fetch all the remote branches for this repository:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ RUN apk --no-cache add ca-certificates git

FROM scratch

LABEL org.opencontainers.image.source=https://github.com/mszostok/codeowners-validator
LABEL org.opencontainers.image.source=https://github.com/mszostok/codeowners

COPY ./codeowners-validator /codeowners-validator
COPY ./codeowners /codeowners

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

ENTRYPOINT ["/codeowners-validator"]
ENTRYPOINT ["/codeowners"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ all: build-race test-unit test-integration test-lint
# When running integration tests on windows machine
# it cannot execute binary without extension.
# It needs to be parametrized, so we can override it on CI.
export BINARY_PATH = $(ROOT_DIR)/codeowners-validator$(BINARY_EXT)
export BINARY_PATH = $(ROOT_DIR)/codeowners$(BINARY_EXT)

############
# Building #
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

## Codeowners Validator
<a href="/LICENSE"><img alt="Software License" src="https://img.shields.io/badge/license-Apache-brightgreen.svg?style=flat-square"/></a>
<a href="https://goreportcard.com/report/github.com/mszostok/codeowners-validator"><img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/mszostok/codeowners-validator?style=flat-square"/></a>
<a href="https://goreportcard.com/report/github.com/mszostok/codeowners"><img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/mszostok/codeowners?style=flat-square"/></a>
<a href="https://twitter.com/m_szostok"><img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/m_szostok?color=a&label=Follow%20%40m_szostok%20for%20updates&style=social"></a>

The Codeowners Validator project validates the GitHub [CODEOWNERS](https://help.github.com/articles/about-code-owners/) file based on [specified checks](#checks). It supports public and private GitHub repositories and also GitHub Enterprise installations.
Expand All @@ -29,7 +29,7 @@ docker run --rm -v $(pwd):/repo -w /repo \
-e GITHUB_ACCESS_TOKEN="$GH_TOKEN" \
-e EXPERIMENTAL_CHECKS="notowned" \
-e OWNER_CHECKER_REPOSITORY="org-name/rep-name" \
mszostok/codeowners-validator:v0.7.4
mszostok/codeowners:v0.7.4
```

#### Command line
Expand All @@ -40,13 +40,13 @@ env REPOSITORY_PATH="." \
GITHUB_ACCESS_TOKEN="$GH_TOKEN" \
EXPERIMENTAL_CHECKS="notowned" \
OWNER_CHECKER_REPOSITORY="org-name/rep-name" \
codeowners-validator
codeowners
```

#### GitHub Action

```yaml
- uses: mszostok/codeowners-validator@v0.7.4
- uses: mszostok/[email protected]
with:
checks: "files,owners,duppatterns,syntax"
experimental_checks: "notowned,avoid-shadowing"
Expand All @@ -62,44 +62,44 @@ Check the [Configuration](#configuration) section for more info on how to enable

## Installation

It's highly recommended to install a fixed version of `codeowners-validator`. Releases are available on the [releases page](https://github.com/mszostok/codeowners-validator/releases).
It's highly recommended to install a fixed version of `codeowners`. Releases are available on the [releases page](https://github.com/mszostok/codeowners/releases).

### macOS & Linux

`codeowners-validator` is available via [Homebrew](https://brew.sh/index_pl).
`codeowners` is available via [Homebrew](https://brew.sh/index_pl).

#### Homebrew

| Install | Upgrade |
|--------------------------------------------------|--------------------------------------------------|
| `brew install mszostok/tap/codeowners-validator` | `brew upgrade mszostok/tap/codeowners-validator` |
| `brew install mszostok/tap/codeowners` | `brew upgrade mszostok/tap/codeowners` |

#### Install script

```bash
# binary installed into ./bin/
curl -sfL https://raw.githubusercontent.com/mszostok/codeowners-validator/main/install.sh | sh -s v0.7.4
curl -sfL https://raw.githubusercontent.com/mszostok/codeowners/main/install.sh | sh -s v0.7.4

# binary installed into $(go env GOPATH)/bin/codeowners-validator
curl -sfL https://raw.githubusercontent.com/mszostok/codeowners-validator/main/install.sh | sh -s -- -b $(go env GOPATH)/bin v0.7.4
# binary installed into $(go env GOPATH)/bin/codeowners
curl -sfL https://raw.githubusercontent.com/mszostok/codeowners/main/install.sh | sh -s -- -b $(go env GOPATH)/bin v0.7.4

# In alpine linux (as it does not come with curl by default)
wget -O - -q https://raw.githubusercontent.com/mszostok/codeowners-validator/main/install.sh | sh -s v0.7.4
wget -O - -q https://raw.githubusercontent.com/mszostok/codeowners/main/install.sh | sh -s v0.7.4

# Print version. Add `--oshort` to print just the version number.
codeowners-validator version
codeowners version
```

You can also download [latest version](https://github.com/mszostok/codeowners-validator/releases/latest) from release page manually.
You can also download [latest version](https://github.com/mszostok/codeowners/releases/latest) from release page manually.

#### From Sources

<!--- You can install `codeowners-validator` with `go install go.szostok.io/codeowners-validator@v0.7.5`. --->
You can install `codeowners-validator` with `go install github.com/mszostok/codeowners-validator@v0.7.4`.
<!--- You can install `codeowners` with `go install go.szostok.io/[email protected]`. --->
You can install `codeowners` with `go install github.com/mszostok/[email protected]`.

> NOTE: please use Go 1.16 or greater.

This will put `codeowners-validator` in `$(go env GOPATH)/bin`.
This will put `codeowners` in `$(go env GOPATH)/bin`.

## Checks

Expand Down Expand Up @@ -165,6 +165,6 @@ Contributions are greatly appreciated! The project follows the typical GitHub pu

## Roadmap

The [codeowners-validator roadmap uses GitHub milestones](https://github.com/mszostok/codeowners-validator/milestone/1) to track the progress of the project.
The [codeowners roadmap uses GitHub milestones](https://github.com/mszostok/codeowners/milestone/1) to track the progress of the project.

They are sorted with priority. First are most important.
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "GitHub CODEOWNERS Validator"
name: "GitHub CODEOWNERS"
description: "GitHub action to ensure the correctness of your CODEOWNERS file."
author: "[email protected]"

Expand All @@ -8,7 +8,7 @@ inputs:
required: false

github_app_id:
description: "Github App ID for authentication. This replaces the GITHUB_ACCESS_TOKEN. Instruction for creating a Github App can be found here: https://github.com/mszostok/codeowners-validator/blob/main/docs/gh-token.md"
description: "Github App ID for authentication. This replaces the GITHUB_ACCESS_TOKEN. Instruction for creating a Github App can be found here: https://github.com/mszostok/codeowners/blob/main/docs/gh-token.md"
required: false

github_app_installation_id:
Expand Down Expand Up @@ -80,7 +80,7 @@ inputs:

runs:
using: 'docker'
image: 'docker://ghcr.io/mszostok/codeowners-validator:v0.7.4'
image: 'docker://ghcr.io/mszostok/codeowners:v0.7.4'
env:
ENVS_PREFIX: "INPUT"

Expand Down
Loading