|
| 1 | +name: rubyspec C-API extensions |
| 2 | + |
| 3 | +inputs: |
| 4 | + builddir: |
| 5 | + required: false |
| 6 | + default: '.' |
| 7 | + make: |
| 8 | + required: false |
| 9 | + default: 'make -s' |
| 10 | + |
| 11 | +outputs: |
| 12 | + key: |
| 13 | + value: >- |
| 14 | + ${{ |
| 15 | + !steps.restore.outputs.cache-hit && |
| 16 | + github.ref == 'refs/heads/master' && |
| 17 | + steps.config.outputs.key |
| 18 | + }} |
| 19 | +
|
| 20 | +runs: |
| 21 | + using: composite |
| 22 | + |
| 23 | + steps: |
| 24 | + - id: config |
| 25 | + shell: bash |
| 26 | + run: | |
| 27 | + eval $(grep -e '^arch *=' -e '^ruby_version *=' -e '^DLEXT *=' Makefile | |
| 28 | + sed 's/ *= */=/') |
| 29 | + case "${ruby_version}" in |
| 30 | + *+*) key=capiexts-${arch}-${ruby_version};; |
| 31 | + *) key=;; |
| 32 | + esac |
| 33 | + echo version=$ruby_version >> $GITHUB_OUTPUT |
| 34 | + echo key=$key >> $GITHUB_OUTPUT |
| 35 | + echo DLEXT=$DLEXT >> $GITHUB_OUTPUT |
| 36 | + working-directory: ${{ inputs.builddir }} |
| 37 | + |
| 38 | + - name: Restore previous CAPI extensions |
| 39 | + uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 |
| 40 | + id: cache |
| 41 | + with: |
| 42 | + path: ${{ inputs.builddir }}/spec/ruby/optional/capi/ext/ |
| 43 | + key: ${{ steps.config.outputs.key }} |
| 44 | + if: ${{ steps.config.outputs.key }} |
| 45 | + |
| 46 | + - name: Run test-spec with previous CAPI extension binaries |
| 47 | + id: check |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + touch spec/ruby/optional/capi/ext/*.$DLEXT |
| 51 | + [ ! -f spec/ruby/optional/capi/ext/\*.$DLEXT ] |
| 52 | + ${{ inputs.make }} SPECOPTS=optional/capi test-spec |
| 53 | + env: |
| 54 | + DLEXT: ${{ steps.config.outputs.DLEXT }} |
| 55 | + working-directory: ${{ inputs.builddir }} |
| 56 | + if: ${{ steps.cache.outputs.cache-hit }} |
| 57 | + |
| 58 | + - name: Strip CAPI extensions |
| 59 | + id: strip |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + rm -f spec/ruby/optional/capi/ext/*.c |
| 63 | + [ "$DLEXT" = bundle ] || # separated to .dSYM directories |
| 64 | + strip spec/ruby/optional/capi/ext/*.$DLEXT |
| 65 | + env: |
| 66 | + DLEXT: ${{ steps.config.outputs.DLEXT }} |
| 67 | + working-directory: ${{ inputs.builddir }} |
| 68 | + if: >- |
| 69 | + ${{true |
| 70 | + && ! steps.cache.outputs.cache-hit |
| 71 | + && github.ref_name == 'master' |
| 72 | + }} |
| 73 | +
|
| 74 | + - name: Save CAPI extensions |
| 75 | + uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 |
| 76 | + with: |
| 77 | + path: ${{ inputs.builddir }}/spec/ruby/optional/capi/ext/ |
| 78 | + key: ${{ steps.config.outputs.key }} |
| 79 | + if: ${{ steps.strip.outcome == 'success' }} |
| 80 | + |
| 81 | + - shell: bash |
| 82 | + run: | |
| 83 | + echo "::error::Change from ${prev} detected; bump up ABI version" |
| 84 | + env: |
| 85 | + prev: ${{ steps.config.outputs.version }} |
| 86 | + if: ${{ always() && steps.check.outcome == 'failure' }} |
0 commit comments