|
| 1 | +name: Cross compile |
| 2 | +on: |
| 3 | + push: |
| 4 | + paths-ignore: |
| 5 | + - 'doc/**' |
| 6 | + - '**/man/*' |
| 7 | + - '**.md' |
| 8 | + - '**.rdoc' |
| 9 | + - '**/.document' |
| 10 | + - '.*.yml' |
| 11 | + pull_request: |
| 12 | + # Do not use paths-ignore for required status checks |
| 13 | + # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks |
| 14 | + merge_group: |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }} |
| 18 | + cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }} |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +jobs: |
| 24 | + make: |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - host: aarch64-linux-gnu |
| 29 | + arch: arm64 |
| 30 | + fail-fast: false |
| 31 | + |
| 32 | + env: |
| 33 | + GITPULLOPTIONS: --no-tags origin ${{ github.ref }} |
| 34 | + |
| 35 | + runs-on: ubuntu-24.04 |
| 36 | + |
| 37 | + if: >- |
| 38 | + ${{!(false |
| 39 | + || contains(github.event.head_commit.message, '[DOC]') |
| 40 | + || contains(github.event.pull_request.title, '[DOC]') |
| 41 | + || contains(github.event.pull_request.labels.*.name, 'Documentation') |
| 42 | + || (github.event.pull_request.user.login == 'dependabot[bot]') |
| 43 | + )}} |
| 44 | +
|
| 45 | + steps: |
| 46 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 47 | + with: |
| 48 | + sparse-checkout-cone-mode: false |
| 49 | + sparse-checkout: /.github |
| 50 | + persist-credentials: false |
| 51 | + |
| 52 | + - uses: ./.github/actions/setup/directories |
| 53 | + with: |
| 54 | + srcdir: src |
| 55 | + builddir: build |
| 56 | + makeup: true |
| 57 | + |
| 58 | + - name: Install cross-compilation toolchain |
| 59 | + run: | |
| 60 | + sudo dpkg --add-architecture ${{ matrix.arch }} |
| 61 | + # Restrict existing sources to amd64to avoid 404 on arm64 |
| 62 | + sudo sed -i '/^Architectures:/d' /etc/apt/sources.list.d/ubuntu.sources |
| 63 | + sudo sed -i '/^Types:/a Architectures: amd64 i386' /etc/apt/sources.list.d/ubuntu.sources |
| 64 | + # Add arm64 sources from ports.ubuntu.com |
| 65 | + printf '%s\n' \ |
| 66 | + "Types: deb" \ |
| 67 | + "URIs: http://ports.ubuntu.com/" \ |
| 68 | + "Suites: noble noble-updates noble-security" \ |
| 69 | + "Components: main universe" \ |
| 70 | + "Architectures: ${{ matrix.arch }}" \ |
| 71 | + | sudo tee /etc/apt/sources.list.d/ports-${{ matrix.arch }}.sources |
| 72 | + sudo apt-get update -qq |
| 73 | + sudo apt-get install --no-install-recommends -qq -y \ |
| 74 | + crossbuild-essential-${{ matrix.arch }} \ |
| 75 | + libssl-dev:${{ matrix.arch }} \ |
| 76 | + libyaml-dev:${{ matrix.arch }} \ |
| 77 | + zlib1g-dev:${{ matrix.arch }} \ |
| 78 | + libffi-dev:${{ matrix.arch }} \ |
| 79 | + libreadline-dev:${{ matrix.arch }} \ |
| 80 | + libncurses-dev:${{ matrix.arch }} \ |
| 81 | + autoconf ruby |
| 82 | +
|
| 83 | + - name: Build baseruby |
| 84 | + run: | |
| 85 | + mkdir ../baseruby |
| 86 | + cd ../baseruby |
| 87 | + ../src/configure --prefix=$PWD/install --disable-install-doc |
| 88 | + make |
| 89 | + make install |
| 90 | +
|
| 91 | + - name: Run configure |
| 92 | + run: >- |
| 93 | + ../src/configure -C --disable-install-doc |
| 94 | + --prefix=/usr |
| 95 | + --build=x86_64-linux-gnu |
| 96 | + --host=${{ matrix.host }} |
| 97 | + --with-baseruby=$PWD/../baseruby/install/bin/ruby |
| 98 | +
|
| 99 | + - run: make |
| 100 | + |
| 101 | + - run: make install DESTDIR=$PWD/install |
| 102 | + |
| 103 | + - name: Verify cross-compiled binary |
| 104 | + run: | |
| 105 | + file install/usr/bin/ruby |
| 106 | + file install/usr/bin/ruby | grep -q '${{ matrix.host }}\|aarch64' |
| 107 | +
|
| 108 | + - uses: ./.github/actions/slack |
| 109 | + with: |
| 110 | + label: cross ${{ matrix.host }} |
| 111 | + SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot |
| 112 | + if: ${{ failure() }} |
| 113 | + |
| 114 | +defaults: |
| 115 | + run: |
| 116 | + working-directory: build |
0 commit comments