New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build only changed examples and do it parallel #559
Conversation
2f97bf4
to
3cb0e06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkurz Can you check/approve my idea so that I'm going to continue this work?
cmd: | | ||
./test.sh --netty | ||
changes: | ||
if: github.event_name == 'pull_request' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detect changes only for PR builds
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create named filter per example
|
||
finish: | ||
name: Finish | ||
if: github.event_name == 'pull_request' | ||
if: ${{ github.event_name == 'pull_request' && !failure() && !cancelled() }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Success if depends was skipped
Looking now. |
gradle-tests: | ||
name: Gradle Tests | ||
uses: playframework/.github/.github/workflows/cmd.yml@v3 | ||
java-chatroom: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So does this mean you have to duplicate this section for each samples, like 31 times? Each time basically the same except a different sample name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. Potentially, we can try to pass needs.changes.outputs.examples
array as another dimension for matrix job, but because I need to do that only once, currently I prefer duplicate jobs per example to have a full control of build logic for every example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a reasonable cost to me to get the target. But of course it's discussable 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking...
.github/workflows/build-test.yml
Outdated
find -name build.sbt | xargs sed -i 's/\/\/.enablePlugins(PlayNettyServer)/.enablePlugins(PlayNettyServer)/g' | ||
fi | ||
sbt ++$MATRIX_SCALA test | ||
./gradlew -Dscala.version="$MATRIX_SCALA" check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this needs to be duplicated 31 times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it isn't duplicate, it's a moving from scripts folder in every examples, that I want to delete in the future 😂 But technically, you're absolutely right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this introduced much more duplication, we have
find -name build.sbt | xargs sed -i 's/\/\/.enablePlugins(PlayNettyServer)/.enablePlugins(PlayNettyServer)/g'
just once in the test.sh file now, but now you have to add that (and the if condition) 31 times...
Sorry for the delay Sergey... So what about if we do following? #!/usr/bin/env bash
if [ -z "$MATRIX_SCALA" ]; then
echo "Error: the environment variable MATRIX_SCALA is not set"
exit 1
fi
# Initialize variables
netty=false
sample=""
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--netty) netty=true ;; # Set netty to true if --netty is passed
--sample=*) sample="${1#*=}" ;; # Extract the value right of the equal sign
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift # Move to next argument
done
if [ "$netty" = true ]; then
find -name build.sbt | xargs sed -i 's/\/\/.enablePlugins(PlayNettyServer)/.enablePlugins(PlayNettyServer)/g'
fi
if [ -n "$sample" ]; then
# Sample is set and not empty
pushd $sample && scripts/test-sbt && popd
else
# sample not set, therefore run all samples
pushd play-java-chatroom-example && scripts/test-sbt && popd
pushd play-java-compile-di-example && scripts/test-sbt && popd
# ...
# ... and all other samples just like we have now
fi It should be possble now to call the script from the workflow yml with
And now even better: ./test.sh --backend-server=$MATRIX_SERVER --sample=$MATRIX_SAMPLE What do you think about that? |
Aso one more idea (in addition to my last comment): If you want we can remove some of the |
e3e4e31
to
698bd4d
Compare
So, Matthias, I totally agree with many of your points 👍 |
I checked locally and the scripts works for me 👍 Added some comments.
For me it is ok if you add the 31 jobs manually and not adding it to the matrix if you think it's better. We will have much less duplication now anyway, it should always be just one line I think? One more thing, which is just for you and you probably know anyway. Currently using netty together with gradle does not "work", will still use pekko. So you maybe want to make this work also, but it's up to you:
|
664d4fa
to
ce4a611
Compare
524ced6
to
b08484a
Compare
Yes, but sometimes it can be useful and our workflow should be ready to this case 😄
Maybe in the future we can back to this discussion, but currently I see the next cases when separated jobs are useful:
|
echo "+----------------------------+" | ||
echo "| Executing tests using sbt |" | ||
echo "+----------------------------+" | ||
sbt ++$MATRIX_SCALA test docs/paradox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed docs/paradox
? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, removed. This docs had been publishing in Lightbend Developer Portal, but we don't publish it anymore. That why I think it isn't actual for us now and we don't need to check it during build. We should migrate this docs to Antora in the future 🤔
echo "+----------------------------+" | ||
echo "| Executing tests using sbt |" | ||
echo "+----------------------------+" | ||
sbt ++$MATRIX_SCALA test docs/paradox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again docs/paradox
removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because these samples didn't change 😉
Yeah, that makes sense 😉
If you are finished you can merge this. I am not totally happy about that many jobs and its duplicated lines in the yml file but I can life with it. I have a bit of a feeling we might overengineer things here... But let's give it a try.
@Mergifyio backport 3.0.x |
✅ Backports have been created
|
@Mergifyio backport 2.9.x |
✅ Backports have been created
|
Main reason: decrease a build time
Target behaviour: