From 6ecdf269d5894eef3d24d0867b72b32f954788e6 Mon Sep 17 00:00:00 2001 From: Alex Masi Date: Wed, 20 Sep 2023 18:18:42 -0700 Subject: [PATCH] add common github workflow (#432) --- .github/workflows/go.yml | 36 ++++++----------- .github/workflows/golangci-lint.yml | 60 ----------------------------- .github/workflows/linter.yml | 44 --------------------- 3 files changed, 11 insertions(+), 129 deletions(-) delete mode 100644 .github/workflows/golangci-lint.yml delete mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index db6b8dda..5455136e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -8,28 +8,14 @@ on: branches: [main] jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - name: Build - run: go build -v ./... - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2.1.3 - with: - go-version: 1.20.x - - run: | - # shellcheck disable=2046 - go test -v -coverprofile=profile.cov $(go list ./... | grep -v /cloudbuild) # ignore cloudbuild tests - - name: Send coverage - uses: shogo82148/actions-goveralls@v1 - with: - path-to-profile: profile.cov + go: + uses: openconfig/common-ci/.github/workflows/go.yml@c2294c3c86c90e75e58c24a40d6f7f3364bbae9d + with: + coverage-excludes-regex: /cloudbuild + tests-excludes-regex: /cloudbuild + race-tests-excludes-regex: /cloudbuild + skip-race-tests: true + go-versions: "['1.20']" + + linter: + uses: openconfig/common-ci/.github/workflows/linter.yml@c2294c3c86c90e75e58c24a40d6f7f3364bbae9d diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index c2d42d80..00000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: golangci-lint -on: - push: - tags: - - v* - branches: - - main - pull_request: -permissions: - contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - # pull-requests: read -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v3.2.0 - with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: latest - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - # args: --issues-exit-code=0 - args: --config=.github/linters/.golangci.yml - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true - - # Optional: if set to true then the all caching functionality will be complete disabled, - # takes precedence over all other caching options. - # skip-cache: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true \ No newline at end of file diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index e7191290..00000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Lint Code Base - -on: - push: - branches: [main] - # Remove the line above to run when pushing to master - pull_request: - branches: [main] - -jobs: - build: - name: Lint Code Base - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Lint Code Base - uses: github/super-linter/slim@v4 - env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_GO: false - VALIDATE_HTML: false - VALIDATE_KUBERNETES_KUBEVAL: false - VALIDATE_JSCPD: false - IGNORE_GENERATED_FILES: true - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}