Skip to content

Commit

Permalink
try new infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
shyouhei committed Jul 19, 2024
1 parent c2510bc commit c28b134
Show file tree
Hide file tree
Showing 4 changed files with 521 additions and 254 deletions.
94 changes: 94 additions & 0 deletions .github/actions/compilers/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Compiles ruby in a container
description: >-
Makes ruby using a dedicated container
inputs:
tag:
required: false
default: clang-18
description: >-
container image tag to use in this run.
with_gcc:
required: false
description: >-
override compiler path & flags.
CFLAGS:
required: false
description: >-
C compiler flags to override.
CXXFLAGS:
required: false
description: >-
C++ compiler flags to override.
optflags:
required: false
# -O1 is faster than -O3 in our tests... Majority of time are consumed trying
# to optimize binaries. Also GitHub Actions run on relatively modern CPUs
# compared to, say, GCC 4 or Clang 3. We don't specify `-march=native`
# because compilers tend not understand what the CPU is.
default: '-O1'
description: >-
Compiler flags for optimisations.
cppflags:
required: false
description: >-
Additional preprocessor flags.
append_configure:
required: false
default: >-
--without-valgrind
--without-jemalloc
--without-gmp
description: >-
flags to append to configure.
enable_shared:
required: false
default: true
description: >-
Whether to build libruby.so.
check:
required: false
default: ''
description: >-
Whether to run `make check`
static_exts:
required: false
description: >-
whitespace separated list of extensions that need be linked statically.
runs:
using: composite
steps:
- shell: bash
run: docker pull --quiet 'ghcr.io/ruby/ruby-ci-image:${{ inputs.tag }}'

- name: compile
shell: bash
run: >-
docker run
--rm
--user=root
--volume '${{ github.workspace }}:/github/workspace:ro'
--workdir=/github/workspace
--entrypoint=/github/workspace/.github/actions/compilers/entrypoint.sh
--env CI
--env GITHUB_ACTION
--env INPUT_WITH_GCC='${{ inputs.with_gcc || inputs.tag }}'
--env INPUT_CFLAGS='${{ inputs.CFLAGS }}'
--env INPUT_CXXFLAGS='${{ inputs.CXXFLAGS }}'
--env INPUT_OPTFLAGS='${{ inputs.OPTFLAGS }}'
--env INPUT_CPPFLAGS='${{ inputs.cppflags }}'
--env INPUT_APPEND_CONFIGURE='${{ inputs.append_configure }}'
--env INPUT_CHECK='${{ inputs.check }}'
--env INPUT_ENABLE_SHARED='${{ inputs.enable_shared }}'
--env INPUT_STATIC_EXTS='${{ inputs.static_exts }}'
'ghcr.io/ruby/ruby-ci-image:${{ inputs.tag }}'
90 changes: 90 additions & 0 deletions .github/actions/compilers/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#! /bin/bash

# Copyright (c) 2024 Ruby developers. All rights reserved.
#
# This file is a part of the programming language Ruby. Permission is hereby
# granted, to either redistribute and/or modify this file, provided that the
# conditions mentioned in the file COPYING are met. Consult the file for
# details.

grouped()
{
echo "::group::${@}"
"${@}"
echo "::endgroup::"
}

set -e
set -u
set -o pipefail

srcdir="/github/workspace/src"
builddir="$(mktemp -dt)"

export GITHUB_WORKFLOW='Compilations'
export CONFIGURE_TTY='never'
export RUBY_DEBUG='ci rgengc'
export RUBY_TESTOPTS='-q --color=always --tty=no'
export RUBY_DEBUG_COUNTER_DISABLE='1'
export GNUMAKEFLAGS="-j$((1 + $(nproc --all)))"

case "x${INPUT_ENABLE_SHARED}" in
x | xno | xfalse )
enable_shared='--disable-shared'
;;
*)
enable_shared='--enable-shared'
;;
esac

pushd ${builddir}

grouped ${srcdir}/configure \
-C \
--with-gcc="${INPUT_WITH_GCC}" \
--enable-debug-env \
--disable-install-doc \
--with-ext=-test-/cxxanyargs,+ \
${enable_shared} \
${INPUT_APPEND_CONFIGURE} \
CFLAGS="${INPUT_CFLAGS}" \
CXXFLAGS="${INPUT_CXXFLAGS}" \
optflags="${INPUT_OPTFLAGS}" \
cppflags="${INPUT_CPPFLAGS}" \
debugflags='-ggdb3' # -g0 disables backtraces when SEGV. Do not set that.

popd

if [[ -n "${INPUT_STATIC_EXTS}" ]]; then
echo "::group::ext/Setup"
set -x
mkdir ${builddir}/ext
(
for ext in ${INPUT_STATIC_EXTS}; do
echo "${ext}"
done
) >> ${builddir}/ext/Setup
set +x
echo "::endgroup::"
fi

pushd ${builddir}

case "${INPUT_APPEND_CONFIGURE}" in
*--with-shared-gc*)
export RUBY_GC_LIBRARY='librubygc.default.so'
mkdir -p /home/runner/shared-gc
grouped make shared-gc SHARED_GC=default
;;
esac

grouped make showflags
grouped make all
grouped make test

[[ -z "${INPUT_CHECK}" ]] && exit 0

grouped make install
grouped make test-tool
grouped make test-all TESTS='-- ruby -ext-'
grouped env CHECK_LEAKS=true make test-spec
2 changes: 1 addition & 1 deletion .github/actions/setup/directories/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ runs:
- if: steps.which.outputs.autoreconf
shell: bash
working-directory: ${{ inputs.srcdir }}
run: ./autogen.sh
run: ./autogen.sh --install

# This is for MinGW.
- if: runner.os == 'Windows'
Expand Down
Loading

0 comments on commit c28b134

Please sign in to comment.