Skip to content

Commit 862ece0

Browse files
ivoanjoeregon
authored andcommitted
Reuse 3.4-asan builds automatically
**What does this PR do?:** This PR takes the build reuse support added in #14 and makes it trigger automatically for 3.4-asan builds. Specifically, since 3.4-asan builds are done from release tags (e.g. v3_4_2), and releases are far and far between, we can reuse a build instead of redoing it. **Motivation:** Reduce CI work. **Additional Notes:** There's a bit of a complexity trade-off here: we need to add a bit more branching logic. **How to test the change?** I've tested the three code paths: * Previous build can be reused => https://github.com/DataDog/ruby-dev-builder/actions/runs/13411682947/job/37463131435 * Previous built **can't** be reused => https://github.com/DataDog/ruby-dev-builder/actions/runs/13411767953/job/37463387098 * skip_slow was set => https://github.com/DataDog/ruby-dev-builder/actions/runs/13411781030/job/37463429665
1 parent 3dab5ec commit 862ece0

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

.github/workflows/build.yml

+20-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
outputs:
2020
should_build: ${{ steps.check_commit.outputs.should_build }}
21+
should_build_3_4_asan: ${{ steps.check_commit.outputs.should_build_3_4_asan }}
2122
commit: ${{ steps.latest_commit.outputs.commit }}
2223
commit_3_4_asan: ${{ steps.latest_commit_3_4_asan.outputs.commit }}
2324
previous_release: ${{ steps.check_commit.outputs.previous_release }}
@@ -50,30 +51,37 @@ jobs:
5051
const latest34ASan = "${{ steps.latest_commit_3_4_asan.outputs.commit }}"
5152
const { owner, repo } = context.repo
5253
let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo })
53-
const firstLine = release.body.split('\n')[0]
54-
const latestReleaseCommit = firstLine.split('@')[1]
54+
const latestReleaseCommit = release.body.split('\n')[0].split('@')[1].trim()
55+
// Entry in body may not exist, but if it doesn't the should_build_3_4_asan is still correct
56+
const latestRelease34ASanCommit = ((release.body.split('\n')[1] ?? "").split('@')[1] ?? "").trim()
5557
console.log(`Latest release commit: ${latestReleaseCommit}`)
58+
console.log(`Latest 3.4-asan release commit: ${latestRelease34ASanCommit}`)
5659
console.log(`Latest ruby commit: ${latestDevCommit}`)
5760
console.log(`Latest 3.4-asan: ${latest34ASan}`)
5861
core.setOutput('should_build', latestReleaseCommit !== latestDevCommit)
62+
core.setOutput('should_build_3_4_asan', latestRelease34ASanCommit !== latest34ASan)
5963
core.setOutput('previous_release', release.tag_name)
6064
- name: Compute build and reuse matrix
6165
uses: actions/github-script@v7
6266
id: matrix
6367
with:
6468
script: |
6569
const osList = ['ubuntu-20.04', 'ubuntu-22.04', 'ubuntu-24.04', 'ubuntu-22.04-arm', 'ubuntu-24.04-arm', 'macos-13', 'macos-14']
70+
const asanHead = { os: 'ubuntu-24.04', name: 'asan' }
71+
const asan34 = { os: 'ubuntu-24.04', name: '3.4-asan' }
6672
const skipSlow = "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.skip_slow == 'true' }}"
73+
const skip34ASan = "${{ steps.check_commit.outputs.should_build_3_4_asan == 'false' }}"
6774
const buildMatrix = JSON.stringify(
6875
skipSlow === 'false' ?
69-
{ os: osList, name: ['head', 'debug'], include: [{ os: 'ubuntu-24.04', name: 'asan' }, { os: 'ubuntu-24.04', name: '3.4-asan' }] } :
76+
{ os: osList, name: ['head', 'debug'], include: (skip34ASan === 'true' ? [asanHead] : [asanHead, asan34]) } :
7077
{ os: osList, name: ['head'] }
7178
)
7279
core.setOutput('build_matrix', buildMatrix)
80+
// Note: GitHub doesn't like having an empty matrix, so make sure at least noop is left
7381
const reuseMatrix = JSON.stringify(
7482
skipSlow === 'false' ?
75-
{ os: ['ubuntu-latest'], name: ['noop'] } : // GitHub doesn't like having an empty matrix, skips jobs that depend on reuse-slow
76-
{ os: osList, name: ['debug'], include: [{ os: 'ubuntu-24.04', name: 'asan' }, { os: 'ubuntu-24.04', name: '3.4-asan' }] }
83+
(skip34ASan === 'true' ? { include: [asan34] } : { os: ['ubuntu-latest'], name: ['noop'] }) :
84+
{ os: osList, name: ['debug'], include: [asanHead, asan34] }
7785
)
7886
core.setOutput('reuse_matrix', reuseMatrix)
7987
console.log(`build_matrix: ${buildMatrix}, reuse_matrix: ${reuseMatrix}`)
@@ -101,8 +109,13 @@ jobs:
101109
fi
102110
echo "tag=$tag" >> $GITHUB_OUTPUT
103111
- name: Set release description to built hash
104-
run: echo "ruby/ruby@${{ needs.prepare.outputs.commit }}" >> release-description.md
105-
- name: Append note if buils were reused
112+
run: echo "master ➜ ruby/ruby@${{ needs.prepare.outputs.commit }}" >> release-description.md
113+
- name: Set release description to 3.4-asan built hash
114+
run: echo "3.4-asan ➜ ruby/ruby@${{ needs.prepare.outputs.commit_3_4_asan }}" >> release-description.md
115+
- name: Append note if 3.4-asan build was reused
116+
if: ${{ needs.prepare.outputs.should_build_3_4_asan == 'false' }}
117+
run: echo "Skipped building and reused build from ${{ needs.prepare.outputs.previous_release }} for 3.4-asan ruby" >> release-description.md
118+
- name: Append note if builds were reused
106119
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.skip_slow == 'true' }}
107120
run: echo "Skipped building and reused builds from ${{ needs.prepare.outputs.previous_release }} for debug and asan rubies" >> release-description.md
108121
- name: Create Release

0 commit comments

Comments
 (0)