Skip to content

feat(build): Parallelize the build step #932

feat(build): Parallelize the build step

feat(build): Parallelize the build step #932

name: Build Pull Request
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
language: ['csharp', 'go','python', 'java', 'typescript']
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Runs docker builds with JSII superchain
run: |
buildlang="${{ matrix.language }}"
langfiles=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep "^$buildlang" )
if [[ $langfiles == "" ]]; then
return
fi
echo "::group::Build changes for ${buildlang}"
echo "# Build summary for ${buildlang}" >> $GITHUB_STEP_SUMMARY
buildpath=""
# For each file that is in the changed set
for file in $(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep "^$buildlang" )
do
# Split the path into the language, example, and
IFS="/" read path1 path2 path3 <<< $file
if [[ $path1 != $buildlang ]]; then
continue
fi
if [[ "$buildpath" == "$path1/$path2" ]]; then
continue
fi
buildpath=$path1/$path2
echo "Build Path ${buildpath}"
case $path1 in
$buildlang)
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-${buildlang}.sh $path2"
if [[ $? == 0 ]; then
echo "- :o: $buildpath" >> $GITHUB_STEP_SUMMARY
else
echo "- :x: $buildpath" >> $GITHUB_STEP_SUMMARY
fi
;;
*) ;;
esac
done
echo "::endgroup::"