Skip to content

Commit

Permalink
ci(lint) Add github actions. Fix #3
Browse files Browse the repository at this point in the history
- linters: go, markdown, dockerfile
- golang: dependencies, generated files
- kubernetes: crd, default and samples validation
- build: docker

Signed-off-by: Pierre Péronnet <pierre.peronnet@ovhcloud.com>
  • Loading branch information
holyhope committed Mar 17, 2020
1 parent 82d15bf commit d9c8192
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on: [push, pull_request]

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build dev
run: make docker-build IMG='goharbor/harbor-operator:${{ github.sha }}'
- run: docker tag goharbor/harbor-operator:${{ github.sha }} goharbor/harbor-operator:dev
if: github.head_ref == 'refs/heads/master'
# TODO Push image to the registry
- run: |
export REF="${{ github.ref }}"
docker tag 'goharbor/harbor-operator:${{ github.sha }}' "goharbor/harbor-operator:${REF##*/}"
if: github.head_ref != 'refs/heads/master'
# TODO Push image to the registry
35 changes: 35 additions & 0 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
pull_request:
branches:
- master

jobs:
go-dependencies:
runs-on: ubuntu-latest
name: Dependencies are up to date
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.13
- name: Checkout
uses: actions/checkout@v2
- run: go mod tidy
- run: go mod vendor
- run: go mod graph
- run: git status
- name: Check diff
run: test -z "$(git diff-index --diff-filter=d --name-only HEAD -- 'vendor' | grep -v 'vendor/modules.txt')"

generated-files:
runs-on: ubuntu-latest
name: Generated files are up to date
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.13
- name: Checkout
uses: actions/checkout@v2
- run: make generate
- name: Check diff
run: test -z "$(git diff-index --diff-filter=d --name-only HEAD -- 'vendor' | grep -v 'vendor/modules.txt')"

39 changes: 39 additions & 0 deletions .github/workflows/kubernetes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on: push

jobs:
crd:
runs-on: ubuntu-latest
name: ./config/crd validation
steps:
- run: sudo apt-get install -y bzr # Required to install controller-gen in make manifests
- uses: actions/checkout@v2
- run: make manifests
- uses: azure/k8s-bake@v1
with:
renderEngine: 'kustomize'
kustomizationPath: './config/crd'
kubectl-version: 'latest'

operator:
runs-on: ubuntu-latest
name: ./config/default validation
steps:
- run: sudo apt-get install -y bzr # Required to install controller-gen in make manifests
- uses: actions/checkout@v2
- run: make manifests
- uses: azure/k8s-bake@v1
with:
renderEngine: 'kustomize'
kustomizationPath: './config/default'
kubectl-version: 'latest'

samples:
runs-on: ubuntu-latest
name: ./config/samples validation
steps:
- uses: actions/checkout@v2
- uses: azure/k8s-bake@v1
with:
renderEngine: 'kustomize'
kustomizationPath: './config/samples'
kubectl-version: 'latest'
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
pull_request:
branches:
- master

jobs:
go-lint:
runs-on: ubuntu-latest
name: GoLint
steps:
- uses: actions/checkout@v2
- name: Run golangci-lint
uses: actions-contrib/golangci-lint@v1
with:
golangci_lint_version: 1.22.2

md-lint:
runs-on: ubuntu-latest
name: MdLint
steps:
- uses: actions/checkout@v2
- name: markdownlint-cli
uses: nosborn/github-action-markdown-cli@v1.1.1
with:
files: .
config_file: ".markdownlint.json"
ignore_files: "vendor"

docker-lint:
runs-on: ubuntu-latest
name: DockerLint
steps:
- name: Checkout
uses: actions/checkout@v2
- name: lint
uses: luke142367/Docker-Lint-Action@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET: Dockerfile

0 comments on commit d9c8192

Please sign in to comment.