feat: test build only on changed code #888
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Pull Request | |
on: [pull_request] | |
jobs: | |
check_file_changes: | |
name: Check file changes v2 | |
outputs: | |
has_csharp_changes: ${{ steps.check_files.outputs.has_csharp_changes }} | |
has_go_changes: ${{ steps.check_files.outputs.has_go_changes }} | |
has_java_changes: ${{ steps.check_files.outputs.has_java_changes }} | |
has_python_changes: ${{ steps.check_files.outputs.has_python_changes }} | |
has_typescript_changes: ${{ steps.check_files.outputs.has_typescript_changes }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Build | |
id: build | |
run: | | |
echo "========== categorization of changed files ==========" | |
buildpath="" | |
for file in $(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) | |
do | |
IFS="/" read path1 path2 path3 <<< $file | |
echo $path1 $path2 $path3 | |
if [[ "$buildpath" == "$path1/$path2" ]]; then | |
continue | |
fi | |
buildpath=$path1/$path2 | |
echo "Build Path ${buildpath}" | |
echo -n "$file => " | |
case $path1 in | |
csharp) | |
echo "C#" | |
echo "::set-output name=has_csharp_changes::true" | |
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-csharp.sh $path2" | |
;; | |
go) | |
echo "Go" | |
echo "::set-output name=has_go_changes::true" | |
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-go.sh $path2" | |
;; | |
java) | |
echo "Java" | |
echo "::set-output name=has_java_changes::true" | |
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-java.sh $path2" | |
;; | |
python) | |
echo "Python" | |
echo "::set-output name=has_python_changes::true" | |
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-python.sh $path2" | |
;; | |
typescript) | |
echo "TypeScript" | |
echo "::set-output name=has_typescript_changes::true" | |
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-typescript.sh $path2" | |
;; | |
*) | |
echo "<unmatched>" | |
;; | |
esac | |
done | |