From 92f65be2f6898f78f0b147298c5f2381d5e07da0 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Fri, 19 Jul 2024 11:22:08 -0700 Subject: [PATCH] add github actions, update readme --- .github/dependabot.yml | 16 ++++++ .github/workflows/codecov.yml | 30 +++++++++++ .github/workflows/codeql-analysis.yml | 78 +++++++++++++++++++++++++++ .github/workflows/go.yml | 26 +++++++++ .github/workflows/golangci-lint.yml | 44 +++++++++++++++ README.md | 10 ++++ go.mod | 2 +- 7 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codecov.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/go.yml create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a07e9ab --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +# 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://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" + + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..9d3a37d --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,30 @@ +name: Test and coverage + +on: [push, pull_request] + +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c + with: + egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs + + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + fetch-depth: 2 + - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 + with: + go-version: '1.20' + - name: Run coverage + run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..52b0fa8 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,78 @@ +# 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 ] + schedule: + - cron: '20 3 * * 4' + +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +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', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 + with: + egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs + + - name: Checkout repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a + 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@cdcdbb579706841c47f7063dda365e292e5cad7a + + # ℹī¸ 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@cdcdbb579706841c47f7063dda365e292e5cad7a diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..ed5933e --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,26 @@ +on: [push, pull_request] +name: Unit Tests +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +jobs: + test: + strategy: + matrix: + go-version: [1.20.x, 1.21.x, 1.22.x] + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 + with: + egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs + + - name: Install Go + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - name: Test + run: go test ./... diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..2461b71 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,44 @@ +name: golangci-lint +on: [push ] +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +jobs: + golangci: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: read # for golangci/golangci-lint-action to fetch pull requests + name: lint + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 + with: + egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs + + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - name: golangci-lint + uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 + 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 + output: checkstyle + + # Optional: golangci-lint command line arguments. + # args: --issues-exit-code=0 + # args: --out-format checkstyle + + # 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 action will use pre-installed Go. + # skip-go-installation: 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 diff --git a/README.md b/README.md index 5029c6b..c1483bc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ +# errors - API for creating exceptions and alerting [![GoDoc](https://godoc.org/github.com/memsql/errors?status.svg)](https://pkg.go.dev/github.com/memsql/errors) +![unit tests](https://github.com/memsql/errors/actions/workflows/go.yml/badge.svg) +[![report card](https://goreportcard.com/badge/github.com/memsql/errors)](https://goreportcard.com/report/github.com/memsql/errors) +[![codecov](https://codecov.io/gh/memsql/errors/branch/main/graph/badge.svg)](https://codecov.io/gh/memsql/errors) + +Install: + + go get github.com/memsql/errors + +--- Package errors provides an API for creating exceptions and alerting. diff --git a/go.mod b/go.mod index 9811d9c..8ed7fa8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/memsql/errors -go 1.18 +go 1.20 require ( github.com/google/go-cmp v0.6.0