Skip to content

Reuse 3.4-asan builds automatically #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check_commit.outputs.should_build }}
should_build_3_4_asan: ${{ steps.check_commit.outputs.should_build_3_4_asan }}
commit: ${{ steps.latest_commit.outputs.commit }}
commit_3_4_asan: ${{ steps.latest_commit_3_4_asan.outputs.commit }}
previous_release: ${{ steps.check_commit.outputs.previous_release }}
Expand Down Expand Up @@ -50,30 +51,37 @@ jobs:
const latest34ASan = "${{ steps.latest_commit_3_4_asan.outputs.commit }}"
const { owner, repo } = context.repo
let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo })
const firstLine = release.body.split('\n')[0]
const latestReleaseCommit = firstLine.split('@')[1]
console.log(`Latest release commit: ${latestReleaseCommit}`)
console.log(`Latest ruby commit: ${latestDevCommit}`)
console.log(`Latest 3.4-asan: ${latest34ASan}`)
const latestReleaseCommit = release.body.split('\n')[0].split('@')[1].trim()
// Entry in body may not exist, but if it doesn't the should_build_3_4_asan is still correct
const latestRelease34ASanCommit = ((release.body.split('\n')[1] ?? "").split('@')[1] ?? "").trim()
console.log(` Latest release commit: ${latestReleaseCommit}`)
console.log(` Latest ruby commit: ${latestDevCommit}`)
console.log(`Latest 3.4-asan release commit: ${latestRelease34ASanCommit}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this next to Latest 3.4-asan: so it's easier to compare, example from your build: https://github.com/DataDog/ruby-dev-builder/actions/runs/13411682947/job/37463108782#step:5:25

Could even align all 4 commits vertically to make it even easier.

console.log(` Latest 3.4-asan: ${latest34ASan}`)
core.setOutput('should_build', latestReleaseCommit !== latestDevCommit)
core.setOutput('should_build_3_4_asan', latestRelease34ASanCommit !== latest34ASan)
core.setOutput('previous_release', release.tag_name)
- name: Compute build and reuse matrix
uses: actions/github-script@v7
id: matrix
with:
script: |
const osList = ['ubuntu-20.04', 'ubuntu-22.04', 'ubuntu-24.04', 'ubuntu-22.04-arm', 'ubuntu-24.04-arm', 'macos-13', 'macos-14']
const asanHead = { os: 'ubuntu-24.04', name: 'asan' }
const asan34 = { os: 'ubuntu-24.04', name: '3.4-asan' }
const skipSlow = "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.skip_slow == 'true' }}"
const skip34ASan = "${{ steps.check_commit.outputs.should_build_3_4_asan == 'false' }}"
const buildMatrix = JSON.stringify(
skipSlow === 'false' ?
{ os: osList, name: ['head', 'debug'], include: [{ os: 'ubuntu-24.04', name: 'asan' }, { os: 'ubuntu-24.04', name: '3.4-asan' }] } :
{ os: osList, name: ['head', 'debug'], include: (skip34ASan === 'true' ? [asanHead] : [asanHead, asan34]) } :
{ os: osList, name: ['head'] }
)
core.setOutput('build_matrix', buildMatrix)
// Note: GitHub doesn't like having an empty matrix, so make sure at least noop is left
const reuseMatrix = JSON.stringify(
skipSlow === 'false' ?
{ os: ['ubuntu-latest'], name: ['noop'] } : // GitHub doesn't like having an empty matrix, skips jobs that depend on reuse-slow
{ os: osList, name: ['debug'], include: [{ os: 'ubuntu-24.04', name: 'asan' }, { os: 'ubuntu-24.04', name: '3.4-asan' }] }
(skip34ASan === 'true' ? { include: [asan34] } : { os: ['ubuntu-latest'], name: ['noop'] }) :
{ os: osList, name: ['debug'], include: [asanHead, asan34] }
)
core.setOutput('reuse_matrix', reuseMatrix)
console.log(`build_matrix: ${buildMatrix}, reuse_matrix: ${reuseMatrix}`)
Expand Down Expand Up @@ -101,8 +109,13 @@ jobs:
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Set release description to built hash
run: echo "ruby/ruby@${{ needs.prepare.outputs.commit }}" >> release-description.md
- name: Append note if buils were reused
run: echo "master ➜ ruby/ruby@${{ needs.prepare.outputs.commit }}" >> release-description.md
- name: Set release description to 3.4-asan built hash
run: echo "3.4-asan ➜ ruby/ruby@${{ needs.prepare.outputs.commit_3_4_asan }}" >> release-description.md
- name: Append note if 3.4-asan build was reused
if: ${{ needs.prepare.outputs.should_build_3_4_asan == 'false' }}
run: echo "Skipped building and reused build from ${{ needs.prepare.outputs.previous_release }} for 3.4-asan ruby" >> release-description.md
- name: Append note if builds were reused
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.skip_slow == 'true' }}
run: echo "Skipped building and reused builds from ${{ needs.prepare.outputs.previous_release }} for debug and asan rubies" >> release-description.md
- name: Create Release
Expand Down Expand Up @@ -262,13 +275,13 @@ jobs:
echo "platform=$platform" >> $GITHUB_OUTPUT
- name: Download binaries from previous release
run: gh release download "${{ needs.prepare.outputs.previous_release }}" --pattern "ruby-${{ matrix.name }}-${{ steps.platform.outputs.platform }}.tar.gz"
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.skip_slow == 'true' }}
if: matrix.name != 'noop'
- name: Re-upload Binaries
run: gh release upload "${{ needs.release.outputs.tag }}" "ruby-${{ matrix.name }}-${{ steps.platform.outputs.platform }}.tar.gz"
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.skip_slow == 'true' }}
if: matrix.name != 'noop'
- name: (Empty step for when reuse is not applied)
run: echo "Not reusing binaries. This step is a no-op." # We can't skip the whole job as publish depends on it, but we skip the uploading
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.skip_slow == 'true') }}
if: matrix.name == 'noop'

publish:
name: Publish Release
Expand Down