Skip to content

51.01-beta24

51.01-beta24 #672

name: Check type sizes
on: [pull_request]
jobs:
build-windows:
name: Process sizes (win64, ${{ matrix.desc }})
uses: DFHack/dfhack/.github/workflows/build-windows.yml@develop
with:
structures_repo: ${{ matrix.repo }}
structures_ref: ${{ matrix.ref }}
artifact-name: sizes-Windows-64-${{ matrix.desc }}
platform-files: false
common-files: false
xml-dump-type-sizes: true
strategy:
fail-fast: false
matrix:
include:
- desc: old
repo: ${{ format('{0}/{1}', github.event.pull_request.base.repo.owner.login, github.event.pull_request.base.repo.name) }}
ref: ${{ github.base_ref }}
- desc: new
repo: ${{ github.repository }}
ref: ${{ github.ref }}
secrets: inherit
build-linux:
name: Process sizes (linux64, ${{ matrix.desc }})
uses: DFHack/dfhack/.github/workflows/build-linux.yml@develop
with:
structures_repo: ${{ matrix.repo }}
structures_ref: ${{ matrix.ref }}
artifact-name: sizes-Linux-64-${{ matrix.desc }}
platform-files: false
common-files: false
xml-dump-type-sizes: true
strategy:
fail-fast: false
matrix:
include:
- desc: old
repo: ${{ format('{0}/{1}', github.event.pull_request.base.repo.owner.login, github.event.pull_request.base.repo.name) }}
ref: ${{ github.base_ref }}
- desc: new
repo: ${{ github.repository }}
ref: ${{ github.ref }}
secrets: inherit
compare:
name: ${{ matrix.os }} (${{ matrix.arch }}-bit)
needs:
- build-windows
- build-linux
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- windows
- ubuntu
arch:
- 64
steps:
- name: Set up environment
shell: bash
run: echo "GHA_OS_TAG=$(echo '${{ runner.os }}' | tr '[[:upper:]]' '[[:lower:]]')${{ matrix.arch }}" >> $GITHUB_ENV
- name: Install dependencies
run: pip install Jinja2
- name: Clone df-structures
uses: actions/checkout@v4
- name: Download type sizes artifact (old)
uses: actions/download-artifact@v4
with:
name: sizes-${{ runner.os }}-${{ matrix.arch }}-old
path: old
- name: Download type sizes artifact (new)
uses: actions/download-artifact@v4
with:
name: sizes-${{ runner.os }}-${{ matrix.arch }}-new
path: new
- name: Dump type sizes
shell: bash
run: |
for name in old new; do
cd ${name}
tar xjf sizes-${{ runner.os }}-${{ matrix.arch }}-${name}.tar.bz2
cd ..
done
old/xml-dump-type-sizes > sizes-old.txt
new/xml-dump-type-sizes > sizes-new.txt
- name: Generate report
run: python3 tools/compare-sizes.py --old sizes-old.txt --new sizes-new.txt --platform ${{ env.GHA_OS_TAG }} --output sizes-${{ env.GHA_OS_TAG }}.json
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: sizes-${{ env.GHA_OS_TAG }}
path: sizes-${{ env.GHA_OS_TAG }}.json
report:
needs: compare
runs-on: ubuntu-latest
steps:
- name: Clone df-structures
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: reports
- name: Generate comment
id: generate_comment
run: |
python tools/generate-type-size-comment.py \
--reports $(find reports -name '*.json') \
--template tools/type-size-comment.md.in \
--output tools/type-size-comment.md \
--github-actions >num_rows.txt
echo rows=$(cat num_rows.txt) >> $GITHUB_OUTPUT
- name: Generate comment data
run: |
jq --null-input \
--rawfile comment tools/type-size-comment.md \
--arg comment_search "<!--type-size-comment-->" \
--arg pr_number "${{ github.event.pull_request.number }}" \
--arg rows "${{ steps.generate_comment.outputs.rows }}" \
'{$comment, $comment_search, $pr_number, update_only:($rows|tonumber <= 0)}' > comment-info.json
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: comment-info.json
path: comment-info.json