Skip to content

Commit

Permalink
Merge pull request #894 from wakatime/develop
Browse files Browse the repository at this point in the history
Release v1.73.2
  • Loading branch information
gandarez authored Aug 4, 2023
2 parents c90f2ee + 0f41c3b commit 31016a9
Show file tree
Hide file tree
Showing 20 changed files with 181 additions and 71 deletions.
59 changes: 42 additions & 17 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,29 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
-
name: Unit tests
run: make test
-
-
name: Linter
run: make lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true
-
name: Vulnerability scan
run: make vulncheck
-
name: Coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
Expand All @@ -52,10 +56,11 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
Expand All @@ -76,19 +81,23 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
-
name: Unit tests
run: make test
-
-
name: Linter
run: make lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true

test-integration-windows:
name: Integration Tests Windows
Expand All @@ -98,10 +107,11 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
Expand All @@ -122,16 +132,23 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
-
name: Unit tests
run: make test
-
name: Linter
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true

test-integration-macos:
name: Integration Tests macOS
Expand All @@ -141,10 +158,11 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
Expand All @@ -171,6 +189,7 @@ jobs:
uses: ludeeus/action-shellcheck@master
with:
ignore_paths: 'bin/tests/libs'
ignore_names: govulncheck-with-excludes.sh
-
name: Setup bats
uses: mig4/setup-bats@v1
Expand Down Expand Up @@ -233,10 +252,11 @@ jobs:
uses: actions/checkout@v3
-
name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Build binaries
env:
Expand Down Expand Up @@ -273,10 +293,11 @@ jobs:
uses: actions/checkout@v3
-
name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Build binaries
env:
Expand Down Expand Up @@ -313,10 +334,11 @@ jobs:
uses: actions/checkout@v3
-
name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Build binaries
env:
Expand Down Expand Up @@ -353,10 +375,11 @@ jobs:
uses: actions/checkout@v3
-
name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Build binaries
env:
Expand Down Expand Up @@ -393,10 +416,11 @@ jobs:
uses: actions/checkout@v3
-
name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Build binaries
env:
Expand Down Expand Up @@ -433,10 +457,11 @@ jobs:
uses: actions/checkout@v3
-
name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Build binaries
env:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ lint: install-linter
.PHONY: vulncheck
vulncheck:
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
./bin/govulncheck-with-excludes.sh ./...

.PHONY: test
test:
Expand Down
2 changes: 2 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ssl_certs_file =
timeout = 30
hostname = machinename
log_file =
import_cfg = /path/to/another/wakatime.cfg

[projectmap]
projects/foo = new project name
Expand Down Expand Up @@ -82,6 +83,7 @@ some/submodule/name = new project name
| timeout | Connection timeout in seconds when communicating with the api. | _int_ | `120` |
| hostname | Optional name of local machine. By default, auto-detects the local machine’s hostname. | _string_ | |
| log_file | Optional log file path. | _filepath_ | `~/.wakatime/wakatime.log` |
| import_cfg | Optional path to another wakatime.cfg file to import. If set it will overwrite values loaded from $WAKATIME_HOME/.wakatime.cfg file. | _filepath_ | |

### Project Map Section

Expand Down
67 changes: 67 additions & 0 deletions bin/govulncheck-with-excludes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# a wrapper / replacement for "govulncheck" which allows for excluding vulnerabilities
# (https://github.com/golang/go/issues/59507)

excludeVulns="$(jq -nc '[
# https://pkg.go.dev/vuln/GO-2023-1987
"GO-2023-1987",
empty # trailing comma hack (makes diffs smaller)
]')"
export excludeVulns

if ! command -v govulncheck > /dev/null; then
govulncheck() {
local user; user="$(id -u):$(id -g)"
local args=(
--rm --interactive --init
--user "$user"
--env HOME=/tmp
--env GOPATH=/tmp/go
--volume govulncheck:/tmp
--env CGO_ENABLED=0
--mount "type=bind,src=$PWD,dst=/wd,ro"
--workdir /wd
"${GOLANG_IMAGE:-golang:latest}"
sh -euc '
go install golang.org/x/vuln/cmd/govulncheck@latest > /dev/null
exec "$GOPATH/bin/govulncheck" "$@"
' --
)
docker run "${args[@]}" "$@"
}
fi

if out="$(govulncheck "$@")"; then
printf '%s\n' "$out"
exit 0
fi

json="$(govulncheck -json "$@")"

vulns="$(jq <<<"$json" -cs 'map(select(has("osv")) | .osv)')"
if [ "$(jq <<<"$vulns" -r 'length')" -le 0 ]; then
printf '%s\n' "$out"
exit 1
fi

filtered="$(jq <<<"$vulns" -c '
(env.excludeVulns | fromjson) as $exclude
| map(select(
.id as $id
| $exclude | index($id) | not
))
')"

text="$(jq <<<"$filtered" -r 'map("- \(.id) (aka \(.aliases | join(", ")))\n\n\t\(.details | gsub("\n"; "\n\t"))") | join("\n\n")')"

if [ -z "$text" ]; then
printf 'No vulnerabilities found.\n'
exit 0
else
printf '%s\n' "$text"
exit 1
fi
2 changes: 1 addition & 1 deletion cmd/heartbeat/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/wakatime/wakatime-cli/pkg/project"
"github.com/wakatime/wakatime-cli/pkg/version"
"github.com/wakatime/wakatime-cli/pkg/windows"
"github.com/yookoala/realpath"

"github.com/gandarez/go-realpath"
"github.com/matishsiao/goInfo"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func setFlags(cmd *cobra.Command, v *viper.Viper) {
"Category of this heartbeat activity. Can be \"coding\","+
" \"building\", \"indexing\", \"debugging\", \"running tests\","+
" \"writing tests\", \"manual testing\", \"code reviewing\","+
" \"browsing\", or \"designing\". Defaults to \"coding\".",
" \"browsing\", \"translating\", or \"designing\". Defaults to \"coding\".",
)
flags.String("config", "", "Optional config file. Defaults to '~/.wakatime.cfg'.")
flags.String("internal-config", "", "Optional internal config file. Defaults to '~/.wakatime/wakatime-internal.cfg'.")
Expand Down
1 change: 1 addition & 0 deletions cmd/testdata/.wakatime.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[settings]
api_key = 00000000-0000-4000-8000-000000000002
debug = true
import_cfg = "testdata/.import.cfg"
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
github.com/dlclark/regexp2 v1.8.1
github.com/gandarez/go-olson-timezone v0.1.0
github.com/gandarez/go-realpath v1.0.0
github.com/juju/mutex v0.0.0-20180619145857-d21b13acf4bf
github.com/kevinburke/ssh_config v1.2.1-0.20220605204831-a56e914e7283
github.com/matishsiao/goInfo v0.0.0-20210923090445-da2e3fa8d45f
Expand All @@ -18,8 +19,7 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.1
github.com/yookoala/realpath v1.0.0
github.com/stretchr/testify v1.8.4
go.etcd.io/bbolt v1.3.7
golang.org/x/crypto v0.6.0
golang.org/x/net v0.7.0
Expand All @@ -45,6 +45,7 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/yookoala/realpath v1.0.0 // indirect
golang.org/x/sys v0.5.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
5 changes: 4 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/gandarez/go-olson-timezone v0.1.0 h1:cDRlHKQE0uC3mJNZyKoQIpAuvQtV8KXwIVj8bDEEyuo=
github.com/gandarez/go-olson-timezone v0.1.0/go.mod h1:+yV/cYNjgs2JqdGShznAD4R13r8lKMGR2XlWAJqa5Yo=
github.com/gandarez/go-realpath v1.0.0 h1:fhQBRDshH/MZNmDLWM9vbBameK2fxyLr+ctqkRwbHEU=
github.com/gandarez/go-realpath v1.0.0/go.mod h1:B5MPsYoZD8dUhGtNbTlOZGuaRD/jM0CnbBWXXD1rSk8=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -258,8 +260,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/wakatime/chroma v0.10.0-wakatime.1 h1:S3XwuOsibZY0hQlUyoJ9mak7K2kbrrfTh1X6XD2DK4c=
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/wakatime/wakatime-cli/pkg/project"
"github.com/wakatime/wakatime-cli/pkg/version"
"github.com/wakatime/wakatime-cli/pkg/windows"
"github.com/yookoala/realpath"

"github.com/gandarez/go-realpath"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
Loading

0 comments on commit 31016a9

Please sign in to comment.