@@ -20,11 +20,12 @@ concurrency:
2020 cancel-in-progress : true
2121
2222jobs :
23- changed-files :
23+ changed-dirs :
2424 runs-on : ubuntu-latest
2525 outputs :
2626 any_changed : ${{ steps.changed-files.outputs.any_changed }}
2727 all_changed_files : ${{ steps.changed-files.outputs.all_changed_files }}
28+ dirs : ${{ steps.set-dirs.outputs.dirs }}
2829
2930 steps :
3031 - uses : actions/checkout@v4
@@ -42,60 +43,25 @@ jobs:
4243 models/**
4344 recipes/**
4445
46+ - id : set-dirs
47+ run : |
48+ DIRS=$(ls -d recipes/*/ models/*/ | jq -R -s -c 'split("\n")[:-1]')
49+ echo "dirs=$DIRS" >> $GITHUB_OUTPUT
4550 - name : Show output
4651 run : |
4752 echo '${{ toJSON(steps.changed-files.outputs) }}'
4853 shell :
4954 bash
5055
51- build-image :
52- needs :
53- - changed-files
54- runs-on : linux-amd64-cpu16
55- if : needs.changed-files.outputs.any_changed == 'true'
56- steps :
57- - name : Login to Docker Hub
58- uses : docker/login-action@v3
59- with :
60- username : ${{ vars.DOCKER_USERNAME }}
61- password : ${{ secrets.DOCKER_PASSWORD }}
62-
63- - name : Checkout repository
64- uses : actions/checkout@v4
65- with :
66- submodules : " recursive"
67-
68- - name : Set up Docker Buildx
69- uses : docker/setup-buildx-action@v3
70-
71- - name : Docker Metadata
72- id : metadata
73- uses : docker/metadata-action@v5
74- with :
75- images : svcbionemo023/bionemo-framework
76- tags : |
77- type=schedule
78- type=ref,event=branch
79- type=ref,event=tag
80- type=ref,event=pr
81- type=raw,value=${{ github.run_id }}
82-
83- # This action sets up our cache-from and cache-to flags appropriately; see the README of this action for more
84- # info. It doesn't seem to cache correctly for merge_group events, so we need to add that as an extra argument in
85- # the step below. There's probably a slight optimization to be had here by caching from the pr- caches for
86- # merge_group events. See https://github.com/int128/docker-build-cache-config-action/issues/1005 for more info.
87- - uses : int128/docker-build-cache-config-action@v1
88- id : cache
89- with :
90- image : svcbionemo023/bionemo-build-cache
56+ per-folder-test :
57+ needs : changed-dirs
58+ runs-on : ubuntu-latest
59+ strategy :
60+ matrix :
61+ dir : ${{ fromJson(needs.changed-dirs.outputs.dirs) }}
9162
92- - name : Build and push
93- uses : docker/build-push-action@v5
94- with :
95- push : true
96- tags : ${{ steps.metadata.outputs.tags }}
97- labels : ${{ steps.metadata.outputs.labels }}
98- cache-from : |
99- ${{ steps.cache.outputs.cache-from }}
100- type=registry,ref=svcbionemo023/bionemo-build-cache:main
101- cache-to : ${{ steps.cache.outputs.cache-to }}
63+ steps :
64+ - name : Run tests
65+ if : contains(needs.changed-dirs.outputs.all_changed_files, matrix.dir)
66+ run : |
67+ echo "Running tests for ${{ matrix.dir }}"
0 commit comments