diff --git a/.github/workflows/test-job.yaml b/.github/workflows/test-job.yaml index eab8265c4c2..0120955e7e8 100644 --- a/.github/workflows/test-job.yaml +++ b/.github/workflows/test-job.yaml @@ -12,18 +12,6 @@ jobs: name: Lint (pre-commit) runs-on: ubuntu-22.04 steps: - - name: Install golangci-lint - run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.60.3 - mv ./bin/golangci-lint /usr/local/bin/golangci-lint - shell: bash - - - name: Install kubeconform - run: | - curl -L https://github.com/yannh/kubeconform/releases/download/v0.6.7/kubeconform-linux-amd64.tar.gz -o kubeconform.tar.gz - tar -xzf kubeconform.tar.gz - mv kubeconform /usr/local/bin/ - - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 087c7c2101b..5ae71127263 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,48 +29,25 @@ repos: - repo: local hooks: - - id: check-golangci-lint-version - name: golangci-lint version check - entry: bash -c 'version="1.60.3"; [ "$(golangci-lint --version | awk "/version/ {print \$4}" | sed "s/^v//")" = "$version" ] || { echo "golangci-lint version is not $version"; exit 1; }' - language: system - always_run: true - fail_fast: true - pass_filenames: false - - - repo: local - hooks: - - id: golangci-lint-ray-operator - name: golangci-lint (ray-operator) - entry: bash -c 'cd ray-operator && golangci-lint run --fix --exclude-files _generated.go --timeout 10m0s; status=$?; cd ..; exit $status' + - id: golangci-lint + name: golangci-lint + entry: ./scripts/lint.sh types: [ go ] language: golang require_serial: true - files: ^ray-operator/ - - - repo: local - hooks: - - id: golangci-lint-kubectl-plugin - name: golangci-lint (kubectl-plugin) - entry: bash -c 'cd kubectl-plugin && golangci-lint run --fix --timeout 10m0s; status=$?; cd ..; exit $status' - types: [ go ] - language: golang - require_serial: true - files: ^kubectl-plugin/ - - - repo: local - hooks: - - id: check-kubeconform-version - name: kubeconform version check - entry: bash -c 'version="0.6.7"; [ "$(kubeconform -v | awk -F"v" "{print \$2}")" = "$version" ] || { echo "kubeconform version is not $version"; exit 1; }' - language: system always_run: true - fail_fast: true pass_filenames: false + additional_dependencies: + - github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3 - repo: local hooks: - id: validate-helm-charts name: validate helm charts with kubeconform entry: bash scripts/validate-helm.sh - language: system + language: golang + require_serial: true + always_run: true pass_filenames: false + additional_dependencies: + - github.com/yannh/kubeconform/cmd/kubeconform@v0.6.7 diff --git a/ray-operator/DEVELOPMENT.md b/ray-operator/DEVELOPMENT.md index 386ea793d59..4ea817ec4be 100644 --- a/ray-operator/DEVELOPMENT.md +++ b/ray-operator/DEVELOPMENT.md @@ -203,10 +203,8 @@ helm uninstall kuberay-operator; helm install kuberay-operator --set image.repos ## pre-commit hooks -1. Install [golangci-lint](https://github.com/golangci/golangci-lint/releases). -2. Install [kubeconform](https://github.com/yannh/kubeconform/releases). -3. Install [pre-commit](https://pre-commit.com/). -4. Run `pre-commit install` to install the pre-commit hooks. +1. Install [pre-commit](https://pre-commit.com/). +2. Run `pre-commit install` to install the pre-commit hooks. ## CI/CD diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100755 index 00000000000..f24d61cf92f --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +dirs_to_lint="ray-operator kubectl-plugin" + +for dir in $dirs_to_lint; do + pushd $dir + golangci-lint run --fix --exclude-files _generated.go --timeout 10m0s + popd +done