Skip to content

Commit d6992b8

Browse files
committed
run gcc15 in different github actions workflow
1 parent c3558a1 commit d6992b8

File tree

2 files changed

+71
-77
lines changed

2 files changed

+71
-77
lines changed

.github/workflows/test-gcc15.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: GCC 15 Tests
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: gcc15-tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
test-gcc15:
11+
name: Ruby ${{ matrix.ruby }} with GCC 15
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
ruby: ['3.2', '3.3', '3.4', 'head']
17+
18+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Test with Ruby ${{ matrix.ruby }} and GCC 15
24+
run: |
25+
# Get the exact Ruby version tag for Docker
26+
RUBY_VERSION="${{ matrix.ruby }}"
27+
if [[ "$RUBY_VERSION" == "head" ]]; then
28+
RUBY_VERSION="rc"
29+
fi
30+
31+
# Create Dockerfile for Ruby with GCC 15
32+
cat > Dockerfile.gcc15 << EOF
33+
FROM ruby:${RUBY_VERSION}-alpine3.22
34+
35+
# Install GCC and other dependencies
36+
RUN apk add --no-cache \
37+
gcc \
38+
g++ \
39+
musl-dev \
40+
make \
41+
sqlite-dev \
42+
linux-headers \
43+
git
44+
45+
# Verify GCC version
46+
RUN gcc --version
47+
48+
WORKDIR /app
49+
EOF
50+
51+
# Build the custom image
52+
docker build -t ruby-gcc15-alpine -f Dockerfile.gcc15 .
53+
54+
# Run tests in the container
55+
docker run --rm -v ${{ github.workspace }}:/app ruby-gcc15-alpine sh -c "\
56+
gcc --version && \
57+
ruby --version && \
58+
bundle install && \
59+
bundle exec rake compile && \
60+
bundle exec rake test"

.github/workflows/test.yml

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -13,86 +13,20 @@ jobs:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest]
1515
ruby: ['3.2', '3.3', '3.4', 'head']
16-
gcc: [13, 14, 15, null]
17-
exclude:
18-
# No GCC versions for macOS
19-
- os: macos-latest
20-
gcc: 13
21-
- os: macos-latest
22-
gcc: 14
23-
- os: macos-latest
24-
gcc: 15
25-
# No null GCC for Ubuntu
26-
- os: ubuntu-latest
27-
gcc: null
2816

29-
name: ${{matrix.os}}, Ruby ${{matrix.ruby}}${{ matrix.gcc && format(' (GCC {0})', matrix.gcc) || '' }}
17+
name: ${{matrix.os}}, ${{matrix.ruby}}
3018

3119
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
3220

3321
runs-on: ${{matrix.os}}
3422
steps:
35-
- uses: actions/checkout@v4
36-
- uses: ruby/setup-ruby@v1
37-
with:
38-
ruby-version: ${{matrix.ruby}}
39-
bundler-cache: true
40-
apt-get: libsqlite3-dev
41-
42-
- name: Install GCC 13/14
43-
if: matrix.os == 'ubuntu-latest' && (matrix.gcc == '13' || matrix.gcc == '14')
44-
run: |
45-
sudo apt-get update
46-
sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
47-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100
48-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.gcc }} 100
49-
gcc --version
50-
51-
- name: Compile with GCC 15 using cplusplus-ci
52-
if: matrix.os == 'ubuntu-latest' && matrix.gcc == '15'
53-
run: |
54-
# Pull the pre-built GCC 15 image
55-
docker pull gcc:15
56-
57-
# Find Ruby and gem paths
58-
RUBY_PATH=$(dirname $(which ruby))
59-
GEM_PATH=$(dirname $(which gem))
60-
BUNDLE_PATH=$(dirname $(which bundle))
61-
62-
# Get Ruby lib directories
63-
RUBY_LIB=$(ruby -e 'puts RbConfig::CONFIG["libdir"]')
64-
RUBY_INCLUDE=$(ruby -e 'puts RbConfig::CONFIG["rubyhdrdir"]')
65-
RUBY_ARCH_INCLUDE=$(ruby -e 'puts RbConfig::CONFIG["rubyarchhdrdir"]')
66-
67-
# Install required libraries in the container
68-
docker run --rm gcc:15 apt-get update
69-
docker run --rm gcc:15 apt-get install -y libsqlite3-dev
70-
71-
# Compile the extension inside the container with GCC 15
72-
# Mount Ruby binaries, libraries, and include files
73-
docker run --rm \
74-
-v $PWD:/app \
75-
-v $RUBY_PATH:$RUBY_PATH \
76-
-v $GEM_PATH:$GEM_PATH \
77-
-v $BUNDLE_PATH:$BUNDLE_PATH \
78-
-v $RUBY_LIB:$RUBY_LIB \
79-
-v $RUBY_INCLUDE:$RUBY_INCLUDE \
80-
-v $RUBY_ARCH_INCLUDE:$RUBY_ARCH_INCLUDE \
81-
-e PATH=$PATH:$RUBY_PATH:$GEM_PATH:$BUNDLE_PATH \
82-
-e CC=gcc \
83-
-e RUBY_LIB=$RUBY_LIB \
84-
-e RUBY_INCLUDE=$RUBY_INCLUDE \
85-
-e RUBY_ARCH_INCLUDE=$RUBY_ARCH_INCLUDE \
86-
-w /app \
87-
gcc:15 bash -c "bundle exec rake compile"
88-
89-
- name: Compile on Ubuntu (non-GCC 15)
90-
if: matrix.os == 'ubuntu-latest' && matrix.gcc != '15'
91-
run: CC=gcc-${{ matrix.gcc }} bundle exec rake compile
92-
93-
- name: Compile on macOS
94-
if: matrix.os == 'macos-latest'
95-
run: bundle exec rake compile
96-
97-
- name: Run tests
98-
run: bundle exec rake test
23+
- uses: actions/checkout@v4
24+
- uses: ruby/setup-ruby@v1
25+
with:
26+
ruby-version: ${{matrix.ruby}}
27+
bundler-cache: true
28+
apt-get: libsqlite3-dev
29+
- name: Compile C-extension
30+
run: bundle exec rake compile
31+
- name: Run tests
32+
run: bundle exec rake test

0 commit comments

Comments
 (0)