Skip to content

Commit d64603d

Browse files
authored
Merge pull request #246 from ruby-go-gem/doc
Update example for golangci-lint
2 parents 443b190 + f61e442 commit d64603d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

_gem/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ namespace :go do
8585
sh "which golangci-lint" do |ok, _|
8686
raise "golangci-lint isn't installed. See. https://golangci-lint.run/welcome/install/" unless ok
8787
end
88-
sh GoGem::RakeTask.build_env_vars, "golangci-lint run"
88+
89+
build_tag = GoGem::Util.ruby_minor_version_build_tag
90+
sh GoGem::RakeTask.build_env_vars, "golangci-lint run --build-tags #{build_tag}"
8991
end
9092
end
9193
end
@@ -101,12 +103,28 @@ jobs:
101103
- uses: actions/checkout@v4
102104
- uses: actions/setup-go@v5
103105
- uses: ruby/setup-ruby@v1
106+
with:
107+
bundler-cache: false
108+
109+
# FIXME: setup-go installs cache in `vendor/` and setup-ruby installs cache in `vendor/bundle/`
110+
# If we use the cache in setup-go and setup-ruby at the same time, this doesn't work well because they use the same directory.
111+
# Therefore, the installation location needs to be changed from the setup-ruby default.
112+
- name: bundle install
113+
run: |
114+
set -xe
115+
bundle config --local path ruby-vendor/bundle
116+
bundle install --jobs 4
104117
105118
- name: export CGO_CFLAGS for golangci-lint
106119
run: bundle exec rake go:build_envs[CGO_CFLAGS] >> $GITHUB_ENV
107120

121+
- name: export BUILD_TAG for golangci-lint
122+
run: echo "BUILD_TAG=$(bundle exec rake go:build_tag)" >> $GITHUB_ENV
123+
108124
- name: Run golangci-lint
109125
uses: golangci/golangci-lint-action@v6
126+
with:
127+
args: --build-tags ${{ env.BUILD_TAG }}
110128
```
111129
112130
#### Available configurations

_gem/lib/go_gem/rake_task.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ module GoGem
3838
# sh "which golangci-lint" do |ok, _|
3939
# raise "golangci-lint isn't installed. See. https://golangci-lint.run/welcome/install/" unless ok
4040
# end
41-
# sh GoGem::RakeTask.build_env_vars, "golangci-lint run"
41+
#
42+
# build_tag = GoGem::Util.ruby_minor_version_build_tag
43+
# sh GoGem::RakeTask.build_env_vars, "golangci-lint run --build-tags #{build_tag}"
4244
# end
4345
# end
4446
# end

0 commit comments

Comments
 (0)