Skip to content

Commit

Permalink
Revert incremental build (#875)
Browse files Browse the repository at this point in the history
* Revert "fix: github set-output deprecated (#871)"

This reverts commit b98918d.

* Revert "feat: test build only on changed code all commits (#869)"

This reverts commit 0cf785b.

* Revert "feat: test build only on changed code (#867)"

This reverts commit 8b650ce.
  • Loading branch information
kellertk authored Jun 30, 2023
1 parent b98918d commit 99c6f6e
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 60 deletions.
129 changes: 80 additions & 49 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,91 @@ name: Build Pull Request
on: [pull_request]

jobs:
build:
check_file_changes:
name: Check file changes
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: Runs docker builds with JSII superchain

- name: Check files
id: check_files
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#"
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"
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"
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"
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"
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
echo "========== categorization of changed files =========="
for file in $(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
do
echo -n "$file => "
case $file in
csharp/*)
echo "C#"
echo "::set-output name=has_csharp_changes::true"
;;
go/*)
echo "Go"
echo "::set-output name=has_go_changes::true"
;;
java/*)
echo "Java"
echo "::set-output name=has_java_changes::true"
;;
python/*)
echo "Python"
echo "::set-output name=has_python_changes::true"
;;
typescript/*)
echo "TypeScript"
echo "::set-output name=has_typescript_changes::true"
;;
*)
echo "<unmatched>"
;;
esac
done
build:
needs: check_file_changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Runs docker builds with JSII superchain
run: |
HAS_CSHARP_CHANGES="${{needs.check_file_changes.outputs.has_csharp_changes}}"
HAS_GO_CHANGES="${{needs.check_file_changes.outputs.has_go_changes}}"
HAS_JAVA_CHANGES="${{needs.check_file_changes.outputs.has_java_changes}}"
HAS_PYTHON_CHANGES="${{needs.check_file_changes.outputs.has_python_changes}}"
HAS_TYPESCRIPT_CHANGES="${{needs.check_file_changes.outputs.has_typescript_changes}}"
if [ "${HAS_CSHARP_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-csharp.sh"
fi
if [ "${HAS_GO_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-go.sh"
fi
if [ "${HAS_JAVA_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-java.sh"
fi
if [ "${HAS_PYTHON_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-python.sh"
fi
if [ "${HAS_TYPESCRIPT_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-typescript.sh"
fi
3 changes: 1 addition & 2 deletions scripts/build-csharp.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash
set -euxo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
modifieddir=$1

# install CDK CLI from npm, so that npx can find it later
cd $scriptdir/../csharp
npm install

# Find and build all CSharp projects
for projFile in $(find $scriptdir/../csharp/$modifieddir -name cdk.json | grep -v node_modules); do
for projFile in $(find $scriptdir/../csharp -name cdk.json | grep -v node_modules); do
(
echo "=============================="
echo "building project: $projFile"
Expand Down
3 changes: 1 addition & 2 deletions scripts/build-go.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash
set -euxo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
modifieddir=$1

# install CDK CLI from npm, so that npx can find it later
cd $scriptdir/../go
npm install

# Find and build all Go projects
for projFile in $(find $scriptdir/../go/$modifieddir -name cdk.json | grep -v node_modules); do
for projFile in $(find $scriptdir/../go -name cdk.json | grep -v node_modules); do
(
echo "=============================="
echo "building project: $projFile"
Expand Down
3 changes: 1 addition & 2 deletions scripts/build-java.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash
set -euxo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
modifieddir=$1

# install CDK CLI from npm, so that npx can find it later
cd $scriptdir/../java
npm install

# Find and build all Maven projects
for pomFile in $(find $scriptdir/../java/$modifieddir -name pom.xml | grep -v node_modules); do
for pomFile in $(find $scriptdir/../java -name pom.xml | grep -v node_modules); do
(
echo "=============================="
echo "building project: $(dirname $pomFile)"
Expand Down
8 changes: 5 additions & 3 deletions scripts/build-python.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
set -euxo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
modifieddir=$1

python3 -m venv /tmp/.venv

Expand All @@ -10,7 +9,7 @@ cd $scriptdir/../python
npm install

# Find and build all Python projects
for requirements in $(find $scriptdir/../python/$modifieddir -name requirements.txt -not -path "$scriptdir/../python/node_modules/*"); do
for requirements in $(find $scriptdir/../python -name requirements.txt -not -path "$scriptdir/../python/node_modules/*"); do
(
echo "=============================="
echo "building project: $requirements"
Expand All @@ -24,6 +23,9 @@ for requirements in $(find $scriptdir/../python/$modifieddir -name requirements.
pip install -r requirements.txt

$scriptdir/synth.sh


# It is critical that we clean up the pip venv before we build the next python project
# Otherwise, if anything gets pinned in a requirements.txt, you end up with a weird broken environment
pip freeze | xargs pip uninstall -y
)
done
3 changes: 1 addition & 2 deletions scripts/build-typescript.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash
set -euxo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
modifieddir=$1

# Find and build all NPM projects
for pkgJson in $(find $scriptdir/../typescript/$modifieddir -name cdk.json | grep -v node_modules | sort); do
for pkgJson in $(find typescript -name cdk.json | grep -v node_modules | sort); do
(
echo "=============================="
echo "building project: $(dirname $pkgJson)"
Expand Down

0 comments on commit 99c6f6e

Please sign in to comment.