|
| 1 | +# This workflow runs Data Morph on datasets and/or shapes that have |
| 2 | +# been added or modified. |
| 3 | +# |
| 4 | +# Author: Stefanie Molin, Daniel Schaefer |
| 5 | + |
| 6 | +name: Generate Morphs |
| 7 | + |
| 8 | +on: |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - 'src/**' |
| 12 | + - 'pyproject.toml' |
| 13 | + - '.github/workflows/generate-morphs.yml' |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + generate-morphs: |
| 21 | + name: Run Data Morph on new/altered datasets/shapes |
| 22 | + |
| 23 | + # Just generate on one operating system (they should all be the same) |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + defaults: |
| 27 | + run: |
| 28 | + shell: bash -e {0} |
| 29 | + |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 35 | + |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 |
| 38 | + with: |
| 39 | + python-version: "3.x" |
| 40 | + |
| 41 | + - name: Install Data Morph |
| 42 | + run: | |
| 43 | + python -m pip install --upgrade pip |
| 44 | + python -m pip install setuptools --upgrade |
| 45 | + python -m pip install . |
| 46 | +
|
| 47 | + # docs for this action: https://github.com/tj-actions/changed-files |
| 48 | + - name: Get all dataset and shape files that have changed |
| 49 | + id: changed-files-yaml |
| 50 | + uses: tj-actions/changed-files@4edd678ac3f81e2dc578756871e4d00c19191daf # v45.0.4 |
| 51 | + with: |
| 52 | + files_yaml: | |
| 53 | + dataset: |
| 54 | + - src/data_morph/data/starter_shapes/* |
| 55 | + shape: |
| 56 | + - src/data_morph/shapes/** |
| 57 | +
|
| 58 | + # If datasets were added or changed in this PR |
| 59 | + - name: Generate morphs from new or changed datasets |
| 60 | + if: steps.changed-files-yaml.outputs.dataset_any_changed == 'true' |
| 61 | + env: |
| 62 | + DATASET_ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.dataset_all_changed_files }} |
| 63 | + run: | |
| 64 | + echo "Detected changes to dataset(s): $DATASET_ALL_CHANGED_FILES" |
| 65 | + DATASET_ARGS=$(python bin/ci.py $DATASET_ALL_CHANGED_FILES) |
| 66 | + echo "Generating morphs for the following datasets: $DATASET_ARGS" |
| 67 | + parallel -j0 data-morph \ |
| 68 | + --start-shape $DATASET_ARGS \ |
| 69 | + --target-shape {} \ |
| 70 | + ::: bullseye heart rectangle star slant_up |
| 71 | +
|
| 72 | + # If shapes are added or modified in this PR |
| 73 | + - name: Generate morphs from new or changed shapes |
| 74 | + if: steps.changed-files-yaml.outputs.shape_any_changed == 'true' |
| 75 | + env: |
| 76 | + SHAPE_ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.shape_all_changed_files }} |
| 77 | + run: | |
| 78 | + echo "Detected changes to shape(s): $SHAPE_ALL_CHANGED_FILES" |
| 79 | + SHAPE_ARGS=$(python bin/ci.py $SHAPE_ALL_CHANGED_FILES) |
| 80 | + echo "Generating morphs for the following shapes: $SHAPE_ARGS" |
| 81 | + parallel -j0 data-morph \ |
| 82 | + --start-shape music \ |
| 83 | + --target-shape {} \ |
| 84 | + ::: $SHAPE_ARGS |
| 85 | +
|
| 86 | + # For core code changes, we want to do a couple morphs to see if they still look ok |
| 87 | + # Only need to run if neither of the previous two morphs ran |
| 88 | + - name: Morph shapes with core code changes |
| 89 | + if: steps.changed-files-yaml.outputs.dataset_any_changed != 'true' && steps.changed-files-yaml.outputs.shape_any_changed != 'true' |
| 90 | + run: | |
| 91 | + parallel -j0 data-morph \ |
| 92 | + --start-shape music \ |
| 93 | + --target-shape {} \ |
| 94 | + ::: bullseye heart rectangle star slant_up |
| 95 | +
|
| 96 | + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 |
| 97 | + with: |
| 98 | + name: morphed-data-pr${{ github.event.number }}-${{ github.sha }} |
| 99 | + path: morphed_data |
0 commit comments