summaryrefslogtreecommitdiff
path: root/.github/actions/compilers/action.yml
blob: ff060ce2e0bebd2920050cfd906b98915e4fdb2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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`

  mspecopt:
    required: false
    default: ''
    description: >-
      Additional 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:${{ 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='${{ 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_MSPECOPT='${{ inputs.mspecopt }}'
        --env INPUT_ENABLE_SHARED='${{ inputs.enable_shared }}'
        --env INPUT_STATIC_EXTS='${{ inputs.static_exts }}'
        --env LAUNCHABLE_ORGANIZATION='${{ github.repository_owner }}'
        --env LAUNCHABLE_WORKSPACE='${{ github.event.repository.name }}'
        --env LAUNCHABLE_ENABLED='${{ steps.enable-launchable.outputs.enable-launchable || false }}'
        --env GITHUB_PR_HEAD_SHA='${{ github.event.pull_request.head.sha || github.sha }}'
        --env GITHUB_PULL_REQUEST_URL='${{ github.event.pull_request.html_url }}'
        --env GITHUB_REF='${{ 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
        'ghcr.io/ruby/ruby-ci-image:${{ inputs.tag }}'