From d758ff1cd4c02e94e6d172c303e2a251e5c39c21 Mon Sep 17 00:00:00 2001 From: Laurent Demailly Date: Fri, 22 Mar 2024 12:19:20 -0700 Subject: [PATCH] Switch to shared workflow and update dependencies (#124) * Switch to shared workflow and update dependencies * update to latest cli --- .github/workflows/codecov.yml | 22 ---- .github/workflows/codeql-analysis.yml | 67 ---------- .github/workflows/include.yml | 32 +++++ .github/workflows/releaser.yml | 40 ------ .gitignore | 3 + .golangci.yml | 173 -------------------------- .goreleaser.yaml | 85 ------------- Makefile | 8 ++ go.mod | 14 +-- go.sum | 30 ++--- 10 files changed, 65 insertions(+), 409 deletions(-) delete mode 100644 .github/workflows/codecov.yml delete mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/include.yml delete mode 100644 .github/workflows/releaser.yml delete mode 100644 .golangci.yml delete mode 100644 .goreleaser.yaml create mode 100644 Makefile diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index e4487b6..0000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: "Code Coverage" - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/setup-go@v5 - with: - go-version: '1.20' - check-latest: true - - name: Run test coverage - run: go test -race -coverprofile=coverage.out -covermode=atomic - - uses: codecov/codecov-action@v3 - with: - files: coverage.out diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index a6b0aac..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,67 +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 ] - schedule: - - cron: '42 20 * * 3' - -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://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # pin@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. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - # 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@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # pin@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # pin@v2 diff --git a/.github/workflows/include.yml b/.github/workflows/include.yml new file mode 100644 index 0000000..f95829a --- /dev/null +++ b/.github/workflows/include.yml @@ -0,0 +1,32 @@ +# Remember to change/update `description` below when copying +# this include +name: "Shared cli/server fortio workflows" +on: + push: + branches: [ main ] + tags: + # so a vX.Y.Z-test1 doesn't trigger build + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-pre*' + pull_request: + branches: [ main ] + +jobs: + call-gochecks: + uses: fortio/workflows/.github/workflows/gochecks.yml@main + call-codecov: + uses: fortio/workflows/.github/workflows/codecov.yml@main + call-codeql: + uses: fortio/workflows/.github/workflows/codeql-analysis.yml@main + permissions: + actions: read + contents: read + security-events: write + call-releaser: + uses: fortio/workflows/.github/workflows/releaser.yml@main + with: + description: "Fortio delta tool" + secrets: + GH_PAT: ${{ secrets.GH_PAT }} + DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} + DOCKER_USER: ${{ secrets.DOCKER_USER }} diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml deleted file mode 100644 index 5f6a6e9..0000000 --- a/.github/workflows/releaser.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Release - -on: - push: - tags: - # so a vX.Y.Z-test1 doesn't trigger build - - 'v[0-9]+.[0-9]+.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+-pre*' - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3 - with: - fetch-depth: 0 - - uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # pin@v1 - - uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # pin@v1 - - name: Set up Go - uses: actions/setup-go@v5 # pin@v3 - with: - go-version: '1.20' - check-latest: true - - name: Log in to Docker Hub - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # pin@v2 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: "GoReleaser Action" - uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # pin@v4.3.0 - with: - distribution: goreleaser - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.gitignore b/.gitignore index 2d83068..a87837c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +.goreleaser.yaml +.golangci.yml coverage.out +delta diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index 60a872c..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,173 +0,0 @@ -# Config for golanglint-ci - -# output configuration options - -# all available settings of specific linters -linters-settings: - gocritic: - disabled-checks: - - ifElseChain - dupl: - # tokens count to trigger issue, 150 by default - threshold: 100 - exhaustive: - # indicates that switch statements are to be considered exhaustive if a - # 'default' case is present, even if all enum members aren't listed in the - # switch - default-signifies-exhaustive: false - funlen: - lines: 140 - statements: 70 - gocognit: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 42 - nestif: - # minimal complexity of if statements to report, 5 by default - min-complexity: 4 - gocyclo: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 30 - godot: - # check all top-level comments, not only declarations - check-all: false - govet: - # report about shadowed variables - check-shadowing: true - # settings per analyzer - settings: - printf: # analyzer name, run `go tool vet help` to see all analyzers - funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Printf - enable-all: true - disable-all: false - depguard: - list-type: blacklist - include-go-root: false - packages: - - github.com/sirupsen/logrus - packages-with-error-message: - # specify an error message to output when a blacklisted package is used - - github.com/sirupsen/logrus: "logging is allowed only by fortio.log" - lll: - # max line length, lines longer will be reported. Default is 120. - # '\t' is counted as 1 character by default, and can be changed with the tab-width option - line-length: 132 - # tab width in spaces. Default to 1. - tab-width: 1 - misspell: - # Correct spellings using locale preferences for US or UK. - # Default is to use a neutral variety of English. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - locale: US - ignore-words: - - fortio - nakedret: - # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 - max-func-lines: 30 - nolintlint: - require-specific: true - whitespace: - multi-if: false # Enforces newlines (or comments) after every multi-line if statement - multi-func: false # Enforces newlines (or comments) after every multi-line function signature - gofumpt: - # Choose whether or not to use the extra rules that are disabled - # by default - extra-rules: false - - -linters: - disable: - # Deprecated ones: - - scopelint - - golint - - interfacer - - maligned - - varcheck - - structcheck - - nosnakecase - - deadcode - # Weird/bad ones: - - wsl - - nlreturn - - gochecknoinits - - gochecknoglobals - - gomnd - - testpackage - - wrapcheck - - exhaustivestruct - - tagliatelle - - nonamedreturns - - varnamelen - - exhaustruct # seems like a good idea at first but actually a pain and go does have zero values for a reason. -# TODO consider putting these back, when they stop being bugged (ifshort, wastedassign,...) - - paralleltest - - thelper - - forbidigo - - ifshort - - wastedassign - - cyclop - - forcetypeassert - - ireturn - enable-all: true - disable-all: false - # Must not use fast: true in newer golangci-lint or it'll just skip a bunch of linter instead of doing caching like before (!) - fast: false - - -issues: - # Excluding configuration per-path, per-linter, per-text and per-source - exclude-rules: - # Exclude some linters from running on tests files. - - path: _test\.go - linters: - - gocyclo - - errcheck - - dupl - - gosec - - gochecknoinits - - gochecknoglobals - - forcetypeassert - - nosnakecase - - noctx - - # Exclude lll issues for long lines with go:generate - - linters: - - lll - source: "^//go:generate " - - linters: - - goerr113 - text: "do not define dynamic errors" - - linters: - - govet - text: "fieldalignment:" - - linters: - - godox - text: "TODO" - - linters: - - nosnakecase - text: "grpc_|_SERVING|O_" - - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-issues-per-linter: 0 - - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. - max-same-issues: 0 - -severity: - # Default value is empty string. - # Set the default severity for issues. If severity rules are defined and the issues - # do not match or no severity is provided to the rule this will be the default - # severity applied. Severities should match the supported severity names of the - # selected out format. - # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity - # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity - # - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message - default-severity: error - - # The default value is false. - # If set to true severity-rules regular expressions become case sensitive. - case-sensitive: false diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index 7c870d2..0000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,85 +0,0 @@ -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 -checksum: - name_template: "checksums.txt" -snapshot: - name_template: "{{ incpatch .Version }}-next" -changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" -gomod: - proxy: true - mod: mod -dockers: - - image_templates: ["fortio/{{ .ProjectName }}:{{ .Version }}-amd64"] - use: buildx - goarch: amd64 - build_flag_templates: - - --platform=linux/amd64 - - image_templates: ["fortio/{{ .ProjectName }}:{{ .Version }}-arm64"] - use: buildx - goarch: arm64 - build_flag_templates: - - --platform=linux/arm64 -docker_manifests: -- - name_template: fortio/{{ .ProjectName }}:{{ .Version }} - image_templates: - - fortio/{{ .ProjectName }}:{{ .Version }}-amd64 - - fortio/{{ .ProjectName }}:{{ .Version }}-arm64 -- - name_template: fortio/{{ .ProjectName }}:latest - image_templates: - - fortio/{{ .ProjectName }}:{{ .Version }}-amd64 - - fortio/{{ .ProjectName }}:{{ .Version }}-arm64 -release: - prerelease: auto - mode: append -# .goreleaser.yaml -brews: - - - # GitHub/GitLab repository to push the formula to - tap: - owner: fortio - name: homebrew-tap - - # Git author used to commit to the repository. - # Defaults are shown. - commit_author: - name: goreleaserbot - email: bot@goreleaser.com - - # The project name and current git tag are used in the format string. - commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" - - # Folder inside the repository to put the formula. - # Default is the root folder. - folder: Formula - - # Your app's homepage. - # Default is empty. - homepage: "https://fortio.org/" - - # Template of your app's description. - # Default is empty. - description: "Fortio delta tool" - - # SPDX identifier of your app's license. - # Default is empty. - license: "Apache-2.0" - - # So you can `brew test` your formula. - # Default is empty. - test: | - assert_match version.to_s, shell_output("#{bin}/{{ .ProjectName }} -version") diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7cf022c --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ + +lint: .golangci.yml + golangci-lint run + +.golangci.yml: Makefile + curl -fsS -o .golangci.yml https://raw.githubusercontent.com/fortio/workflows/main/golangci.yml + +.PHONY: lint diff --git a/go.mod b/go.mod index 04909a3..fff28dd 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,16 @@ module github.com/fortio/delta go 1.18 require ( - fortio.org/cli v1.5.1 - fortio.org/log v1.12.0 - fortio.org/sets v1.0.3 + fortio.org/cli v1.5.2 + fortio.org/log v1.12.1 + fortio.org/sets v1.0.4 fortio.org/testscript v0.3.1 ) require ( fortio.org/struct2env v0.4.0 // indirect - fortio.org/version v1.0.3 // indirect - golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/tools v0.8.0 // indirect + fortio.org/version v1.0.4 // indirect + golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/tools v0.19.0 // indirect ) diff --git a/go.sum b/go.sum index 4a1bb55..372b697 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,19 @@ -fortio.org/assert v1.1.4 h1:Za1RaG+OjsTMpQS3J3UCvTF6wc4+IOHCz+jAOU37Y4o= -fortio.org/cli v1.5.1 h1:lqPvkxRVSajsVwLfblaN62BPAICPp05Oab+yjRvI3DU= -fortio.org/cli v1.5.1/go.mod h1:Tp7AypudP1mJomTUN/J/vlOTlZDWTMsok09MMyA99ow= -fortio.org/log v1.12.0 h1:5Yg4pL9Pp0jcWeJYixm2xikMCldVaSDMgDFDmQJZfho= -fortio.org/log v1.12.0/go.mod h1:1tMBG/Elr6YqjmJCWiejJp2FPvXg7/9UAN0Rfpkyt1o= -fortio.org/sets v1.0.3 h1:HzewdGjH69YmyW06yzplL35lGr+X4OcqQt0qS6jbaO4= -fortio.org/sets v1.0.3/go.mod h1:QZVj0r6KP/ZD9ebySW9SgxVNy/NjghUfyHW9NN+WU+4= +fortio.org/assert v1.2.1 h1:48I39urpeDj65RP1KguF7akCjILNeu6vICiYMEysR7Q= +fortio.org/cli v1.5.2 h1:MfEcHAhYyIkwG04/K1YJL946Y8/jyAjmF9WeR5ZG/5E= +fortio.org/cli v1.5.2/go.mod h1:SdQufh5PLd6oX2EtvtzLFw++gw8zVoejD1WlwGXAvYw= +fortio.org/log v1.12.1 h1:8JNdFqOFbtifrdbqKkQZchGAoooLLr1J/tD2lYl1ZaI= +fortio.org/log v1.12.1/go.mod h1:1tMBG/Elr6YqjmJCWiejJp2FPvXg7/9UAN0Rfpkyt1o= +fortio.org/sets v1.0.4 h1:z5+qleG+9lpbpjGHvRGhfd+E5pJGsLetYl/w4pMc5MM= +fortio.org/sets v1.0.4/go.mod h1:3W7rRfGhnRubPZsjvaZ2MiepcvWe5rSeHzcOG/mTfMw= fortio.org/struct2env v0.4.0 h1:k5alSOTf3YHiB3MuacjDHQ3YhVWvNZ95ZP/a6MqvyLo= fortio.org/struct2env v0.4.0/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410= fortio.org/testscript v0.3.1 h1:MmRO64AsmzaU1KlYMzAbotJIMKRGxD1XXssJnBRiMGQ= fortio.org/testscript v0.3.1/go.mod h1:7OJ+U4avooRNqc7p/VHKJadYgj9fA6+N0SbGU8FVWGs= -fortio.org/version v1.0.3 h1:5gJ3plj6isAOMq52cI5ifo4cC+QHmJF76Wevc5Cp4x0= -fortio.org/version v1.0.3/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +fortio.org/version v1.0.4 h1:FWUMpJ+hVTNc4RhvvOJzb0xesrlRmG/a+D6bjbQ4+5U= +fortio.org/version v1.0.4/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0= +golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 h1:6R2FC06FonbXQ8pK11/PDFY6N6LWlf9KlzibaCapmqc= +golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=