diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2023-06-29 10:02:23 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2023-06-30 11:18:06 +0900 |
commit | e8d629ed76cab8b17f82f024b6b5f7eddb71ab51 (patch) | |
tree | 2a169331e6109a58f441be9477fe3b3f543b7e9e /.github | |
parent | d3ff43852b22f5463d22aab390ef340d9ebe4b06 (diff) | |
download | ruby-e8d629ed76cab8b17f82f024b6b5f7eddb71ab51.tar.gz |
refactor extract apt-get
Use composite action to reduce copy & paste.
Diffstat (limited to '.github')
-rw-r--r-- | .github/actions/setup/ubuntu/action.yml | 53 | ||||
-rw-r--r-- | .github/workflows/baseruby.yml | 2 | ||||
-rw-r--r-- | .github/workflows/bundled_gems.yml | 5 | ||||
-rw-r--r-- | .github/workflows/check_dependencies.yml | 8 | ||||
-rw-r--r-- | .github/workflows/codeql-analysis.yml | 9 | ||||
-rw-r--r-- | .github/workflows/rjit-bindgen.yml | 13 | ||||
-rw-r--r-- | .github/workflows/rjit.yml | 16 | ||||
-rw-r--r-- | .github/workflows/ubuntu.yml | 18 | ||||
-rw-r--r-- | .github/workflows/yjit-ubuntu.yml | 6 |
9 files changed, 68 insertions, 62 deletions
diff --git a/.github/actions/setup/ubuntu/action.yml b/.github/actions/setup/ubuntu/action.yml new file mode 100644 index 0000000000..a9e5b41951 --- /dev/null +++ b/.github/actions/setup/ubuntu/action.yml @@ -0,0 +1,53 @@ +name: Setup ubuntu environment +description: >- + At the beginning there was no way but to copy & paste `apt-get` + everywhere. But now that we have composite actions, it seems better + merge them into one. + +inputs: + arch: + required: false + default: '' + description: >- + Architecture. Because we run this on a GitHub-hosted runner + acceptable value for this input is very limited. + +outputs: + arch: + value: ${{ steps.uname.outputs.uname }} + description: >- + Actual architecture. This could be different from the one + passed to the `inputs.arch`. For instance giving `i386` to this + action yields `i686`. + +runs: + using: composite + + steps: + - name: set SETARCH + shell: bash + run: echo "SETARCH=${setarch}" >> "$GITHUB_ENV" + env: + setarch: ${{ inputs.arch && format('setarch {0} --', inputs.arch) }} + + - id: uname + name: uname + shell: bash + run: | + echo uname=`${SETARCH} uname -m` >> "$GITHUB_OUTPUT" + echo dpkg=`${SETARCH} uname -m | sed s/686/386/` >> "$GITHUB_OUTPUT" + + - name: apt-get + shell: bash + env: + arch: ${{ inputs.arch && format(':{0}', steps.uname.outputs.dpkg) || '' }} + run: | + set -x + ${arch:+sudo dpkg --add-architecture ${arch#:}} + sudo apt-get update -qq || : + sudo apt-get install --no-install-recommends -qq -y -o=Dpkg::Use-Pty=0 \ + ${arch:+cross}build-essential${arch/:/-} \ + libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \ + zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \ + autoconf ruby + sudo apt-get install -qq -y pkg-config${arch} || : diff --git a/.github/workflows/baseruby.yml b/.github/workflows/baseruby.yml index 12be397834..c86da2ca12 100644 --- a/.github/workflows/baseruby.yml +++ b/.github/workflows/baseruby.yml @@ -56,7 +56,7 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler: none - run: echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV - - run: sudo apt-get install build-essential autoconf libyaml-dev + - uses: ./.github/actions/setup/ubuntu - run: ./autogen.sh - run: ./configure --disable-install-doc - run: make common-srcs diff --git a/.github/workflows/bundled_gems.yml b/.github/workflows/bundled_gems.yml index e00de382e7..3998f86f80 100644 --- a/.github/workflows/bundled_gems.yml +++ b/.github/workflows/bundled_gems.yml @@ -73,10 +73,7 @@ jobs: continue-on-error: true - name: Install libraries - run: | - set -x - sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev autoconf ruby + uses: ./.gituhb/actions/setup/ubuntu if: ${{ steps.diff.outcome == 'failure' }} - name: Build diff --git a/.github/workflows/check_dependencies.yml b/.github/workflows/check_dependencies.yml index 6e3dee2a5e..a24c649361 100644 --- a/.github/workflows/check_dependencies.yml +++ b/.github/workflows/check_dependencies.yml @@ -40,12 +40,6 @@ jobs: steps: - name: Install libraries run: | - set -x - sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev autoconf ruby - if: ${{ contains(matrix.os, 'ubuntu') }} - - name: Install libraries - run: | brew upgrade brew install gmp libffi openssl@1.1 zlib autoconf automake libtool readline if: ${{ contains(matrix.os, 'macos') }} @@ -54,6 +48,8 @@ jobs: git config --global advice.detachedHead 0 git config --global init.defaultBranch garbage - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: ./.github/actions/setup/ubuntu + if: ${{ contains(matrix.os, 'ubuntu') }} - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: .downloaded-cache diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 300ed85819..8efbaa1ed8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -47,15 +47,12 @@ jobs: language: [ 'cpp', 'ruby' ] steps: - - name: Install libraries - run: | - set -x - sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev autoconf ruby - - name: Checkout repository uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Install libraries + uses: ./.github/actions/setup/ubuntu + - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: .downloaded-cache diff --git a/.github/workflows/rjit-bindgen.yml b/.github/workflows/rjit-bindgen.yml index 3d2e4111a2..3d767e72c0 100644 --- a/.github/workflows/rjit-bindgen.yml +++ b/.github/workflows/rjit-bindgen.yml @@ -44,17 +44,6 @@ jobs: - name: Set ENV run: | echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV - - name: Install libraries - run: | - set -x - sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y \ - build-essential \ - libssl-dev libyaml-dev libreadline6-dev \ - zlib1g-dev libncurses5-dev libffi-dev \ - libclang1-10 \ - autoconf - sudo apt-get install -q -y pkg-config || : - name: Set up Ruby uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0 with: @@ -66,6 +55,8 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: path: src + - name: Install libraries + uses: ./src/.github/actions/setup/ubuntu - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: src/.downloaded-cache diff --git a/.github/workflows/rjit.yml b/.github/workflows/rjit.yml index e1cc70b222..1b64a1c102 100644 --- a/.github/workflows/rjit.yml +++ b/.github/workflows/rjit.yml @@ -53,20 +53,6 @@ jobs: - name: Set ENV run: | echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV - - name: Install libraries - env: - arch: ${{matrix.arch}} - run: | - set -x - arch=${arch:+:${arch/i[3-6]86/i386}} - ${arch:+sudo dpkg --add-architecture ${arch#:}} - sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y \ - ${arch:+cross}build-essential${arch/:/-} \ - libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \ - zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \ - autoconf ruby libcapstone-dev - sudo apt-get install -q -y pkg-config${arch} || : - name: git config run: | git config --global advice.detachedHead 0 @@ -74,6 +60,8 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.1.0 with: path: src + - name: Install libraries + uses: ./src/.github/actions/setup/ubuntu - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.0.11 with: path: src/.downloaded-cache diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 5beba1a97d..07c97ed9d8 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -51,7 +51,6 @@ jobs: env: GITPULLOPTIONS: --no-tags origin ${{github.ref}} RUBY_DEBUG: ci - SETARCH: ${{ matrix.arch && format('setarch {0}', matrix.arch) }} runs-on: ubuntu-20.04 if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }} steps: @@ -60,20 +59,6 @@ jobs: - name: Set ENV run: | echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV - - name: Install libraries - env: - arch: ${{matrix.arch}} - run: | - set -x - arch=${arch:+:${arch/i[3-6]86/i386}} - ${arch:+sudo dpkg --add-architecture ${arch#:}} - sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y \ - ${arch:+cross}build-essential${arch/:/-} \ - libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \ - zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \ - autoconf ruby - sudo apt-get install -q -y pkg-config${arch} || : - name: git config run: | git config --global advice.detachedHead 0 @@ -81,6 +66,9 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: path: src + - uses: ./src/.github/actions/setup/ubuntu + with: + arch: ${{matrix.arch}} - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: src/.downloaded-cache diff --git a/.github/workflows/yjit-ubuntu.yml b/.github/workflows/yjit-ubuntu.yml index 2dd34470ce..8747b82588 100644 --- a/.github/workflows/yjit-ubuntu.yml +++ b/.github/workflows/yjit-ubuntu.yml @@ -99,11 +99,6 @@ jobs: steps: - run: mkdir build working-directory: - - name: Install libraries - run: | - set -x - sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev autoconf ruby - name: Install Rust if: ${{ matrix.rust_version }} run: rustup install ${{ matrix.rust_version }} --profile minimal @@ -114,6 +109,7 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: path: src + - uses: ./src/.github/actions/setup/ubuntu - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: src/.downloaded-cache |