diff options
Diffstat (limited to '.github/actions/compilers/action.yml')
| -rw-r--r-- | .github/actions/compilers/action.yml | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/.github/actions/compilers/action.yml b/.github/actions/compilers/action.yml new file mode 100644 index 0000000000..c700bbfe9e --- /dev/null +++ b/.github/actions/compilers/action.yml @@ -0,0 +1,164 @@ +name: Compiles ruby in a container +description: >- + Makes ruby using a dedicated container + +inputs: + tag: + required: false + default: clang-20 + 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` + + test_all: + required: false + default: '' + description: >- + Whether to run `make test-all` with options for test-all. + + test_spec: + required: false + default: '' + description: >- + Whether to run `make test-spec` with options for mspec. + + 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:${INPUT_TAG}" + env: + INPUT_TAG: ${{ inputs.tag }} + + - name: Enable Launchable conditionally + id: enable-launchable + run: echo "enable-launchable=true" >> $GITHUB_OUTPUT + shell: bash + if: >- + ${{ + github.repository == 'ruby/ruby' || + (github.repository != 'ruby/ruby' && env.LAUNCHABLE_TOKEN) + }} + + - 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 + --env INPUT_CFLAGS + --env INPUT_CXXFLAGS + --env INPUT_OPTFLAGS + --env INPUT_CPPFLAGS + --env INPUT_APPEND_CONFIGURE + --env INPUT_CHECK + --env INPUT_TEST_ALL + --env INPUT_TEST_SPEC + --env INPUT_ENABLE_SHARED + --env INPUT_STATIC_EXTS + --env LAUNCHABLE_ORGANIZATION + --env LAUNCHABLE_WORKSPACE + --env LAUNCHABLE_ENABLED + --env GITHUB_PR_HEAD_SHA + --env GITHUB_PULL_REQUEST_URL + --env GITHUB_REF + --env GITHUB_ACTIONS + --env GITHUB_RUN_ID + --env GITHUB_REPOSITORY + --env GITHUB_WORKFLOW + --env GITHUB_RUN_NUMBER + --env GITHUB_EVENT_NAME + --env GITHUB_SHA + --env GITHUB_HEAD_REF + --env GITHUB_SERVER_URL + "ghcr.io/ruby/ruby-ci-image:${INPUT_TAG}" + env: + INPUT_TAG: ${{ inputs.tag }} + INPUT_WITH_GCC: ${{ inputs.with_gcc || inputs.tag }} + INPUT_CFLAGS: ${{ inputs.CFLAGS }} + INPUT_CXXFLAGS: ${{ inputs.CXXFLAGS }} + INPUT_OPTFLAGS: ${{ inputs.OPTFLAGS }} + INPUT_CPPFLAGS: ${{ inputs.cppflags }} + INPUT_APPEND_CONFIGURE: ${{ inputs.append_configure }} + INPUT_CHECK: ${{ inputs.check }} + INPUT_TEST_ALL: ${{ inputs.test_all }} + INPUT_TEST_SPEC: ${{ inputs.test_spec }} + INPUT_ENABLE_SHARED: ${{ inputs.enable_shared }} + INPUT_STATIC_EXTS: ${{ inputs.static_exts }} + LAUNCHABLE_ORGANIZATION: ${{ github.repository_owner }} + LAUNCHABLE_WORKSPACE: ${{ github.event.repository.name }} + LAUNCHABLE_ENABLED: ${{ steps.enable-launchable.outputs.enable-launchable || false }} + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} + GITHUB_REF: ${{ github.ref }} + + # Clean up non-default docker images to save disk space. + # The default image (clang-20) is reused across multiple steps + # within the same job, so we keep it to avoid redundant pulls. + - name: clean up docker image + shell: bash + run: docker rmi "ghcr.io/ruby/ruby-ci-image:${INPUT_TAG}" || true + if: ${{ always() && inputs.tag != 'clang-20' }} + env: + INPUT_TAG: ${{ inputs.tag }} |
