Generate Ruby #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate Ruby | |
on: | |
workflow_call: null | |
workflow_run: | |
workflows: ["Build"] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
- release-* | |
paths: | |
- ".github/workflows/generate-ruby.yml" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby-version: [ | |
2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.6.6, 2.6.7, 2.6.8, 2.6.9, 2.6.10, | |
2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.7.5, 2.7.6, 2.7.7, 2.7.8, | |
3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, | |
3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, | |
3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0 | |
] | |
steps: | |
- name: Check out the code | |
uses: actions/[email protected] | |
- name: Install devbox | |
uses: jetpack-io/[email protected] | |
with: | |
enable-cache: true | |
- name: Setup devbox | |
run: devbox run -- echo "done!" | |
- name: Load devbox shellenv | |
uses: HatsuneMiku3939/direnv-action@v1 | |
with: | |
direnvVersion: 2.32.3 | |
- name: Set up Go tool cache | |
uses: actions/[email protected] | |
with: | |
path: ~/.devbox/go | |
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }} | |
- name: Build | |
run: make build | |
- name: Set up container image for generate | |
uses: ScribeMD/[email protected] | |
with: | |
key: docker-ruby-${{ runner.os }}-${{ runner.arch }} | |
- name: Set up Layout cache for generated files | |
uses: actions/[email protected] | |
with: | |
path: offsets-ruby | |
key: ruby-generated-${{ runner.os }}-${{ runner.arch }} | |
restore-keys: | | |
ruby-generated-${{ runner.os }}-${{ runner.arch }}-${{ matrix.ruby-version }} | |
ruby-generated-${{ runner.os }}-${{ runner.arch }} | |
- name: Generate Ruby Offsets for ${{ matrix.ruby-version }} | |
run: | | |
if ! ls "${PWD}"/ruby-binaries/${{ matrix.ruby-version }}/libruby.so.${{ matrix.ruby-version }} 1>/dev/null 2>&1; then | |
mkdir -p "${PWD}"/ruby-binaries/${{ matrix.ruby-version }} | |
docker run --rm -v "${PWD}"/ruby-binaries/${{ matrix.ruby-version }}:/tmp -w /tmp docker.io/library/ruby:${{ matrix.ruby-version }}-slim bash -c 'cp /usr/local/lib/libruby.so.${{ matrix.ruby-version }} /tmp' | |
fi | |
mkdir -p offsets-ruby | |
./structlayout -r ruby -v ${{ matrix.ruby-version }} -o offsets-ruby ruby-binaries/${{ matrix.ruby-version }}/libruby.so.${{ matrix.ruby-version }} | |
git add offsets-ruby | |
cp $(git diff --name-only --staged | xargs) offsets-ruby || echo "No new or modified files - offsets are up to date" | |
- name: Upload Offsets | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: ignore | |
name: ruby-${{ matrix.ruby-version }} | |
path: offsets-ruby | |
retention-days: 1 | |
merge-and-create-branch: | |
runs-on: ubuntu-latest | |
needs: generate | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Check out the code | |
uses: actions/[email protected] | |
- name: Install devbox | |
uses: jetpack-io/[email protected] | |
with: | |
enable-cache: true | |
- name: Setup devbox | |
run: devbox run -- echo "done!" | |
- name: Load devbox shellenv | |
uses: HatsuneMiku3939/direnv-action@v1 | |
with: | |
direnvVersion: 2.32.3 | |
- name: Set up Go tool cache | |
uses: actions/[email protected] | |
with: | |
path: ~/.devbox/go | |
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }} | |
- name: Build | |
run: make build | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: offsets-ruby | |
merge-multiple: true | |
- name: Print the layout files | |
run: tree offsets-ruby | |
- name: Merge the layout files | |
run: | | |
rm pkg/ruby/layout/* | |
./mergelayout -o pkg/ruby/layout offsets-ruby/layout/ruby_*.yaml | |
# If there are no changes (i.e. no diff exists with the checked-out base branch), | |
# no pull request will be created and the action exits silently. | |
- name: Create a pull-request | |
uses: peter-evans/create-pull-request@v6 | |
if: github.event_name != 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "chore: update ruby layouts" | |
title: "chore: Update Ruby layouts" | |
branch: update-ruby-offsets-${{ github.run_number }} | |
add-paths: pkg/ruby/layout | |
base: main | |
labels: chore | |
draft: false | |
delete-branch: true |