From bd09fd3d6ec954e6d2c8d01e51050faf5677d422 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:01:22 -0400 Subject: [PATCH] chore(ci): cleanup CI flows (#595) * chore: cleanup CI flows - remove codeql - pin 3rd-party action versions Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> * run linter only if go files changed Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> * run build/test only if go files changed Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 78 --------------------------- .github/workflows/golangci-lint.yml | 15 +++++- .github/workflows/publish.yml | 4 +- .github/workflows/release-please.yml | 2 +- .github/workflows/test.yml | 35 +++++++++--- 5 files changed, 44 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index efe3c16d2..000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,78 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] - paths-ignore: - - '**/*.md' - - '**/*.tf' - - 'example/**' - - '.github/**' - - 'docs/**' - - 'Makefile' - schedule: - - cron: '30 9 * * 6' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'go' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index adb013d34..a7617065c 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,17 +9,30 @@ on: permissions: contents: read pull-requests: read + jobs: + golangci: name: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 + + - uses: dorny/paths-filter@v2.2.1 + id: filter + with: + filters: | + go: + - '**/*.go' + - uses: actions/setup-go@v4 + if: steps.filter.outputs.go == 'true' with: go-version-file: 'go.mod' + - name: golangci-lint + if: steps.filter.outputs.go == 'true' run: | go run -modfile=tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run -v --timeout 5m diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 30ecbce5f..2b8c6bfa5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,14 +28,14 @@ jobs: - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@v6 + uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef #v6.0.0 with: git_user_signingkey: true gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5.0.0 + uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 #v5.0.0 with: version: latest args: release --rm-dist diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 0d84ce4f8..d2d9071ee 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v3 + - uses: google-github-actions/release-please-action@4c5670f886fe259db4d11222f7dff41c1382304d #v3.7.12 with: token: ${{ secrets.BOT_TOKEN }} release-type: go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ec9fc9d9..02936c156 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,16 +1,12 @@ name: Tests on: - pull_request: - paths-ignore: - - 'README.md' + pull_request: {} push: branches: - main - "release/**" - paths-ignore: - - 'README.md' jobs: - # ensure the code builds... + build: name: Build runs-on: ubuntu-latest @@ -19,16 +15,28 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - uses: dorny/paths-filter@v2.2.1 + id: filter + with: + filters: | + go: + - '**/*.go' - name: Set up Go + if: steps.filter.outputs.go == 'true' uses: actions/setup-go@v4 with: go-version-file: 'go.mod' - name: Get dependencies + if: steps.filter.outputs.go == 'true' run: go mod download - name: Build + if: steps.filter.outputs.go == 'true' run: go vet . && go build -v . test: @@ -37,18 +45,29 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - uses: dorny/paths-filter@v2.2.1 + id: filter + with: + filters: | + go: + - '**/*.go' - name: Set up Go + if: steps.filter.outputs.go == 'true' uses: actions/setup-go@v4 with: go-version-file: 'go.mod' - name: Get dependencies + if: steps.filter.outputs.go == 'true' run: go mod download - name: Unit tests + if: steps.filter.outputs.go == 'true' timeout-minutes: 10 run: go test -v -cover ./...