Skip to content
name: Generate PR Golden Histograms
on:
release:
types: [released]
env:
LDMX_DOCKER_TAG: ldmx/dev:latest
LDMX_NUM_EVENTS: 10000
jobs:
compile-ldmx-sw:
runs-on: ubuntu-latest
outputs:
job_matrix: ${{steps.gen-mat.outputs.job_matrix}}
steps:
- name: Checkout ldmx-sw
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name : Install just
uses: extractions/setup-just@v2
with:
just-version: 1.26.0
- name: Compile and Install ldmx-sw
run: |
just install-denv init configure-force-error
just build
shell: bash
- name: Package ldmx-sw Into Artifact
run: tar cf ldmx-sw-package.tar install/ .github/
- name: Upload ldmx-sw Package
uses: actions/upload-artifact@v4
with:
name: ldmx-sw-build-${{ github.sha }}
path: ldmx-sw-package.tar
- name: Generate Job Matrix
id: gen-mat
uses: ./.github/actions/generate-matrix
generation:
needs: compile-ldmx-sw
runs-on: ubuntu-latest
env:
LDMX_RUN_NUMBER: ${{matrix.run}}
strategy:
matrix: ${{fromJson(needs.compile-ldmx-sw.outputs.job_matrix)}}
steps:
- name: Download ldmx-sw Package
uses: actions/download-artifact@v4
with:
name: ldmx-sw-build-${{ github.sha }}
- name: Unpack ldmx-sw Build
run: |
cd ${GITHUB_WORKSPACE}
tar xf ldmx-sw-package.tar
- name: Run Validation
id: validation
uses: ./.github/actions/validate
with:
sample: ${{matrix.sample}}
no_comp: true
- name: Upload New Golden Histograms
uses: actions/upload-artifact@v4
with:
name: ${{matrix.sample}}-new-gold
path: |
${{steps.validation.outputs.hists}}
${{steps.validation.outputs.log}}
pr-new-gold:
needs: [generation]
runs-on: ubuntu-latest
steps:
- name: Checkout ldmx-sw
uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: trunk
- name: Download All the Gold
id: download
uses: actions/download-artifact@v4
with:
path: '../'
# The BIG assumption we make here is that the artifacts
# containing the new gold are named '<sample>-new-gold'
- name: Update the Gold
id: update-gold
run: |
source ${GITHUB_WORKSPACE}/.github/actions/common.sh
start_group Update Gold Label
echo "Old Label: $(ldmx_gold_label)"
echo "${GITHUB_REF##refs/tags/}" > ${LDMX_GOLD_LABEL_FILE}
echo "New Label: $(ldmx_gold_label)"
git add ${LDMX_GOLD_LABEL_FILE}
end_group
start_group Copy over new Gold Histograms
artifacts_d=${{steps.download.outputs.download-path}}
echo ${artifacts_d}
if ! compgen -G "${artifacts_d}/*-new-gold" > /dev/null; then
error "No artifacts matching '${artifacts_d}/*-new-gold'."
exit 1
fi
for sample_d in ${artifacts_d}/*-new-gold; do
sample=$(basename ${sample_d})
sample=${sample%%-new-gold}
echo ${sample}
mv ${sample_d}/hist.root .github/validation_samples/${sample}/gold.root
mv ${sample_d}/output.log .github/validation_samples/${sample}/gold.log
done
git add .github/validation_samples/*/gold.*
end_group
start_group Set Outputs
set_output new-label $(ldmx_gold_label)
end_group
shell: bash
- name: Open PR for the New Gold
uses: peter-evans/create-pull-request@v7
with:
commit-message: 'Updated Gold for release ${{ steps.update-gold.outputs.new-label }}'
title: 'New Gold for Generated by release ${{ steps.update-gold.outputs.new-label }}'
body: 'Auto-generated updated gold histograms for new release.'
branch: new-gold-${{ steps.update-gold.outputs.new-label }}
delete-branch: true