Skip to content

Fix SEGV on alpine #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.bundle/
.gem_rbs_collection/
.git/
.yardoc/
doc/
vendor/
**/*.so
**/*.bundle
75 changes: 75 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,80 @@ jobs:
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
matrix: ${{ toJson(matrix) }}

build-and-test-alpine:
name: "build-and-test-alpine (Go ${{ matrix.go }}, Ruby ${{ matrix.ruby }})"

needs:
- generate-matrix

runs-on: ubuntu-latest

container: "ruby:${{ matrix.ruby }}-alpine"

strategy:
fail-fast: false

matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- run: apk update
- run: apk add git alpine-sdk libffi-dev

- name: bundle install
run: |
set -xe
bundle config --local path vendor/bundle/
bundle install --jobs 4

- name: Cache vendor/bundle
uses: actions/cache@v4
with:
path: vendor/bundle
key: v1-alpine-${{ matrix.ruby }}-${{ github.sha }}
restore-keys: |
v1-alpine-${{ matrix.ruby }}-

- 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: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1
with:
infile: coverage.out
outfile: coverage.lcov

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov
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 }})"

Expand Down Expand Up @@ -236,6 +310,7 @@ jobs:
notify:
needs:
- build-and-test
- build-and-test-alpine
- go-lint
- ruby-lint
- ruby-rbs
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ Run `bundle exec rake build_all`.

See `bundle exec rake -T` for more tasks.

### Build in docker container
e.g.

```bash
docker build --file=_dockerfiles/alpine.dockerfile -t go-gem-wrappper .
# or
docker build --file=_dockerfiles/alpine.dockerfile -t go-gem-wrappper --build-arg GO_VERSION=1.23 --build-arg RUBY_VERSION=3.4 .

docker run --rm -it go-gem-wrappper sh
```

Run `bundle exec rake build_all` in container.

### See `godoc` in local
```bash
go install golang.org/x/tools/cmd/godoc@latest
Expand Down
32 changes: 32 additions & 0 deletions _dockerfiles/alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG GO_VERSION=1.23
ARG RUBY_VERSION=3.4
ARG ALPINE_VERSION=3.21

FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golang

FROM ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION}

RUN apk update && \
apk add --no-cache git alpine-sdk libffi-dev \
gdb strace binutils valgrind # for debug in container

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=golang /go /go

ENV PATH=/go/bin:/usr/local/go/bin:$PATH \
GOPATH=/go \
GOLANGCI_LINT_VERSION=v1.60.3

RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s ${GOLANGCI_LINT_VERSION}

WORKDIR /app

COPY Gemfile Gemfile.lock ./
COPY _gem/go_gem.gemspec _gem/
COPY _gem/lib/go_gem/version.rb _gem/lib/go_gem/

RUN bundle config --local path vendor/bundle/ && \
bundle config --local deployment true && \
bundle install --jobs 4

COPY . .
2 changes: 1 addition & 1 deletion ruby/testdata/example/ext/example/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
append_cflags("-fvisibility=hidden")

############ Appended for go native extension
create_go_makefile("example/example")
create_go_makefile("example/example", go_build_args: "-gcflags='all=-N -l'")
############ Appended for go native extension
Loading