Skip to content

Merge pull request #337 from ruby-go-gem/dependabot/bundler/uri-1.0.4 #902

Merge pull request #337 from ruby-go-gem/dependabot/bundler/uri-1.0.4

Merge pull request #337 from ruby-go-gem/dependabot/bundler/uri-1.0.4 #902

Workflow file for this run

name: build
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
paths-ignore:
- ".github/labeler.yml"
- ".github/pages.yml"
- ".github/release.yml"
- ".github/workflows/labeler.yml"
- ".github/workflows/patch_for_go_gem.yml"
- ".github/workflows/rbs-collection-updater.yml"
- "_benchmark/**"
env:
GO_TEST_ARGS: -coverprofile coverage.out -covermode atomic
TEST_GEM_DIR: ruby/testdata/example/
# c.f. https://github.com/golangci/golangci-lint/blob/main/CHANGELOG.md
GOLANGCI_LINT_VERSION: v2.4
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v5
- id: set-matrix
run: echo "matrix=$(cat matrix.json | jq -c)" >> $GITHUB_OUTPUT
working-directory: .github/workflows/
build-and-test:
name: "build-and-test (Go ${{ matrix.go }}, Ruby ${{ matrix.ruby }}, Runner ${{ matrix.runner }})"
needs:
- generate-matrix
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
go: ${{ fromJSON(needs.generate-matrix.outputs.matrix).go }}
ruby: ${{ fromJSON(needs.generate-matrix.outputs.matrix).ruby }}
runner:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: build and test (Go)
run: |
set -xe
bundle exec rake go:test
bundle exec rake go:testrace
- name: build and test (Ruby)
run: bundle exec rake
working-directory: ${{ env.TEST_GEM_DIR }}
# FIXME: workaround for gcov2lcov warning
- run: rm -rf vendor/
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage.out
format: golang
continue-on-error: true # NOTE: secrets cannot be obtained with forked repository PR
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
matrix: ${{ toJson(matrix) }}
go-lint:
name: "go-lint (Ruby ${{ matrix.ruby }})"
needs:
- generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ${{ fromJSON(needs.generate-matrix.outputs.matrix).ruby }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: export CGO_CFLAGS for golangci-lint
run: bundle exec rake go:build_envs[CGO_CFLAGS] >> $GITHUB_ENV
- run: echo $CGO_CFLAGS
- name: export BUILD_TAG for golangci-lint
run: echo "BUILD_TAG=$(bundle exec rake go:build_tag)" >> $GITHUB_ENV
- run: echo $BUILD_TAG
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --build-tags ${{ env.BUILD_TAG }} --modules-download-mode=readonly
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
go-govulncheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- run: go install golang.org/x/vuln/cmd/govulncheck@latest
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true
- name: export CGO_CFLAGS for govulncheck
run: bundle exec rake go:build_envs[CGO_CFLAGS] >> $GITHUB_ENV
- run: echo $CGO_CFLAGS
- name: export BUILD_TAG for govulncheck
run: echo "BUILD_TAG=$(bundle exec rake go:build_tag)" >> $GITHUB_ENV
- run: echo $BUILD_TAG
# FIXME: Workaround for following error
#
# govulncheck: loading packages: err: exit status 1: stderr: go: inconsistent vendoring in /home/runner/work/go-gem-wrapper/go-gem-wrapper:
# github.com/stretchr/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
# github.com/davecgh/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
# github.com/pmezard/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
# gopkg.in/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
#
# To ignore the vendor directory, use -mod=readonly or -mod=mod.
# To sync the vendor directory, run:
# go mod vendor
- run: rm -rf vendor/
# FIXME: golang/govulncheck-action@v1 doesn't support `-tags` arg
# - uses: golang/govulncheck-action@v1
# with:
# go-version-file: go.mod
- run: govulncheck -format text -tags "${BUILD_TAG}" ./...
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
ruby-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true
- run: bundle exec rake ruby:rubocop
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
ruby-rbs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true
- run: bundle exec rbs collection install
- run: bundle exec rbs validate
- run: bundle exec steep check
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
go_gem:
name: "go_gem (Ruby ${{ matrix.ruby }})"
needs:
- generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ${{ fromJSON(needs.generate-matrix.outputs.matrix).ruby }}
steps:
- uses: actions/checkout@v5
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake go_gem:test
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
matrix: ${{ toJson(matrix) }}
notify:
needs:
- build-and-test
- go-lint
- go-govulncheck
- ruby-lint
- ruby-rbs
- go_gem
runs-on: ubuntu-latest
steps:
- name: Slack Notification (success)
uses: act10ns/slack@v2
if: always()
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}