diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..29b48ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,20 @@ +name: Bug Report +description: You encountered bug? Unexpected behavior? Open this one. +title: "[BUG]: " +labels: + - kind/bug +body: + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also, what did you expect to happen? + placeholder: Put your description here. + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: Text diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..6cbb71a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,42 @@ +name: Feature Request +description: You want to submit a feature request? Open this one. +title: "[FEATURE]: <title>" +labels: + - kind/feature +body: + - type: dropdown + id: contributor + attributes: + label: Are you interested in contributing to the development of this feature? + description: This will help us categorize the issue. + options: + - 'Yes' + - 'No' + validations: + required: true + - type: textarea + id: description + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. + validations: + required: true + - type: textarea + id: solution + attributes: + label: Describe the solution you'd like. + description: A clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Describe alternatives you've considered. + description: A clear and concise description of any alternative solutions or features you've considered. + validations: + required: true + - type: textarea + id: additional_info + attributes: + label: Additional Information + description: Any other relevant information about the feature request. diff --git a/.github/ISSUE_TEMPLATE/question.yaml b/.github/ISSUE_TEMPLATE/question.yaml new file mode 100644 index 0000000..8a0b90d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yaml @@ -0,0 +1,12 @@ +name: Question +description: Have a generic question? Open this one. +title: "[QUESTION]: <title>" +labels: + - kind/support +body: + - type: textarea + id: what-happened + attributes: + label: Ask a question! + validations: + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..3347509 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,21 @@ +## What this PR does / why we need it: +<!-- +What code changes are made? +What problem does this PR addresses, or what feature this PR adds? +--> +<!-- REPLACE WITH CONTENT --> + +## Which issue(s) this PR resolves: +<!-- +Usage: `Resolves #<issue number>`, or `Resolves <link to the issue>`. +If PR is about `failing-tests`, please post the related tests in a comment and do not use `Resolves` +--> +Resolves # + +## Special notes for your reviewer: +<!-- Do you think reviewers should focus on any particular parts of code? --> +<!-- REPLACE WITH CONTENT --> + +## Additional documentation e.g., enhancement proposals, usage docs, etc.: +<!-- This section can be blank if this pull request does not require a release note. --> +<!-- REPLACE WITH CONTENT --> diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..61c4006 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,43 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "fix" + include: "scope" + labels: + - "area/dependency" + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "fix" + include: "scope" + labels: + - "area/dependency" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "fix" + include: "scope" + labels: + - "area/dependency" + - package-ecosystem: "gomod" + directory: "/test" + schedule: + interval: "weekly" + commit-message: + prefix: "fix" + include: "scope" + labels: + - "area/dependency" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..df63c53 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,28 @@ +- name: good first issue + color: 7057ff + description: Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. +- name: help wanted + color: 006b75 + description: Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. + +- name: area/api + color: 0052cc + description: Indicates an issue on api area. +- name: area/dependency + color: 0052cc + description: Issues or PRs related to dependency changes +- name: area/example + color: 0052cc + +- name: kind/bug + color: e11d21 + description: Categorizes issue or PR as related to a bug. +- name: kind/documentation + color: c7def8 + description: Categorizes issue or PR as related to documentation. +- name: kind/feature + color: c7def8 + description: Categorizes issue or PR as related to a new feature. +- name: kind/support + color: d455d0 + description: Categorizes issue or PR as a support question. diff --git a/.github/workflows/00-labels-sync.yaml b/.github/workflows/00-labels-sync.yaml new file mode 100644 index 0000000..9fd7be9 --- /dev/null +++ b/.github/workflows/00-labels-sync.yaml @@ -0,0 +1,23 @@ +# This workflow is used to declaratively sync labels. +# It is supposed to be run on push to main. + +name: Sync labels + +on: + push: + branches: + - main + +permissions: write-all + +jobs: + sync: + name: Sync labels + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: shanduur/declarative-labels-sync-action@main + with: + owner: linode + repository: ${{ github.event.repository.name }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/00-semantic-pr.yaml b/.github/workflows/00-semantic-pr.yaml new file mode 100644 index 0000000..ad40526 --- /dev/null +++ b/.github/workflows/00-semantic-pr.yaml @@ -0,0 +1,24 @@ +# This workflow validate pull request title. +# It is supposed to be run only when the pull request changes it's state. + +name: Semantic pull request + +on: + pull_request_target: + types: + - opened + - reopened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: Validate pull request title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/10-k8s-linters.yaml b/.github/workflows/10-k8s-linters.yaml new file mode 100644 index 0000000..f7019a3 --- /dev/null +++ b/.github/workflows/10-k8s-linters.yaml @@ -0,0 +1,24 @@ +# This workflow run linters on kubernetes resources. +# It is supposed to be run on each push to main branch, as well as for each push in pull request. + +name: K8s Linters + +on: + pull_request: + branches: [ '*' ] + paths: + - 'helm/**' + +jobs: + linters: + name: Lint Kubernetes manifests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Scan repo with kube-linter + uses: stackrox/kube-linter-action@v1 + with: + directory: helm/ + config: helm/.kube-linter.yaml diff --git a/.github/workflows/10-linters-tests.yaml b/.github/workflows/10-linters-tests.yaml new file mode 100644 index 0000000..1556218 --- /dev/null +++ b/.github/workflows/10-linters-tests.yaml @@ -0,0 +1,95 @@ +# This workflow run linters and tests. +# It is supposed to be run on each push to main branch, as well as for each push in pull request. + +name: Linters + +on: + pull_request: + branches: [ '*' ] + +env: + GO_VERSION: "1.21" + IMAGE: linode/linode-cosi-driver + +permissions: + contents: read + +jobs: + commitlint: + name: Lint commit messages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: wagoid/commitlint-github-action@v5 + + golangci-lint: + name: Run golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + cache: false + - uses: golangci/golangci-lint-action@v3 + with: + version: latest + skip-cache: true + + shell-linter: + name: Run Shellcheck, Checkmake + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + cache: false + - name: Install Checkmake + run: go install github.com/mrtazz/checkmake/cmd/checkmake@latest + - name: Run Checkmake + run: checkmake Makefile + - name: Run Checkmake on tests + run: checkmake test/Makefile + + tests: + name: Run unit tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + cache: false + - run: | + make test + + docker: + name: Build dev image and run scans + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build image + uses: docker/build-push-action@v5 + with: + push: false + load: true + tags: ${{ env.IMAGE }}:${{ github.sha }} + target: runtime + - name: Scan image using Grype + uses: anchore/scan-action@v3 + with: + image: ${{ env.IMAGE }}:${{ github.sha }} + output-format: table + - name: Scan image using Trivy + uses: aquasecurity/trivy-action@master + with: + image-ref: ${{ env.IMAGE }}:${{ github.sha }} + format: table + exit-code: '1' + severity: 'CRITICAL,HIGH,MEDIUM' diff --git a/.github/workflows/99-release.yaml b/.github/workflows/99-release.yaml new file mode 100644 index 0000000..e9cc057 --- /dev/null +++ b/.github/workflows/99-release.yaml @@ -0,0 +1,32 @@ +# This workflow is used to run all necessary actions after the release. +# This should include building and pushing the image. +# It is supposed to be run on each new release. + +name: Release + +on: + push: + tags: + - 'v*' + +env: + REGISTRY: docker.io + +jobs: + docker: + name: Build dev image and run scans + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Build and push image + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.ref_name }} + target: runtime diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7e41f23 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.0.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + - repo: https://github.com/golangci/golangci-lint + rev: v1.55.2 + hooks: + - id: golangci-lint + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.9.0 + hooks: + - id: shellcheck + - repo: https://github.com/norwoodj/helm-docs + rev: v1.11.3 + hooks: + - id: helm-docs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b78f22..674dd6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,8 +6,8 @@ - [Issues](#issues) - [Reporting an Issue](#reporting-an-issue) - [Issue Lifecycle](#issue-lifecycle) + - [Pull Requests](#pull-requests) - [Developing](#developing) - - [Developing](#developing-1) - [Go Environment and Go Modules](#go-environment-and-go-modules) - [Code Linting with golangci-lint](#code-linting-with-golangci-lint) - [Installing golangci-lint via Homebrew (macOS)](#installing-golangci-lint-via-homebrew-macos) @@ -52,7 +52,10 @@ lets us merge or address your contributions quickly. the issue tracker clean. The issue is still indexed and available for future viewers, or can be re-opened if necessary. -## Developing +## Pull Requests + +Pull requests must always be opened from a fork of `linode-cosi-driver`, even if you have +commit rights to the repository so that all contributors follow the same process. ## Developing diff --git a/Dockerfile b/Dockerfile index 84d09e3..a8bb866 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,6 @@ RUN go mod download # Copy the go source. COPY cmd/ cmd/ -COPY internal/ internal/ COPY pkg/ pkg/ COPY Makefile Makefile diff --git a/githooks/.tools.brew b/githooks/.tools.brew new file mode 100644 index 0000000..1b0ebe9 --- /dev/null +++ b/githooks/.tools.brew @@ -0,0 +1,4 @@ +checkmake +helm +golangci-lint +norwoodj/tap/helm-docs diff --git a/githooks/install-hooks.sh b/githooks/install-hooks.sh new file mode 100755 index 0000000..de2abd9 --- /dev/null +++ b/githooks/install-hooks.sh @@ -0,0 +1,4 @@ +#!/bin/bash -aex + +pre-commit install --hook-type pre-commit +pre-commit install --hook-type commit-msg diff --git a/pkg/endpoint/endpoint_test.go b/pkg/endpoint/endpoint_test.go index d3a5399..be7eca5 100644 --- a/pkg/endpoint/endpoint_test.go +++ b/pkg/endpoint/endpoint_test.go @@ -20,7 +20,7 @@ import ( "net/url" "testing" - "github.com/linode/linode-cosi-driver/internal/testutils" + "github.com/linode/linode-cosi-driver/pkg/testutils" ) func TestEndpointListener(t *testing.T) { diff --git a/pkg/testutils/must_test.go b/pkg/testutils/must_test.go index 83f8347..79e7fbe 100644 --- a/pkg/testutils/must_test.go +++ b/pkg/testutils/must_test.go @@ -18,7 +18,7 @@ import ( "errors" "testing" - "github.com/linode/linode-cosi-driver/internal/testutils" + "github.com/linode/linode-cosi-driver/pkg/testutils" ) func TestDo(t *testing.T) { diff --git a/pkg/testutils/testcontext_test.go b/pkg/testutils/testcontext_test.go index 26535a8..bb1af4a 100644 --- a/pkg/testutils/testcontext_test.go +++ b/pkg/testutils/testcontext_test.go @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/linode/linode-cosi-driver/internal/testutils" + "github.com/linode/linode-cosi-driver/pkg/testutils" ) var DefaultTimeout = time.Second * 30