-
Notifications
You must be signed in to change notification settings - Fork 47
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
Configuring GitHub actions #111
Conversation
@lppedd would this work for you? |
@@ -138,3 +138,4 @@ Desktop.ini | |||
*~ | |||
.directory | |||
.merge_file* | |||
.idea |
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.
The idea of committing a subset of .idea
was to streamline inspections and formatting, mostly. I generally tend to do this everywhere, so a dev can jump in and have the environment ready with no additional processes needed.
But if you feel like it doesn't suit the repo, feel free to remove those files.
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.
I tend to have all the .idea configuration generated by gradle. I just thought these files were committed by mistake
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.
I tend to have all the .idea configuration generated by Gradle
A part of those files are indeed fine as generated at project import time, but others like codeStyles/*
or inspectionProfiles/*
are not generated, and when opening the project you'll find the "Default" settings applied. This means everyone will add his own custom formatting.
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.
For formatting, I think we can add ktlint and .editorconfig, which should help with consistency with different IDEs. Perhaps I can add an issue about that
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.
I would avoid KTLint and stick with editorconfig
then. I can generate the .editorconfig
file in case.
KTLint configuration is a PITA and it doesn't have a reliable IDE plugin.
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.
Great, let's go with .editorconfig then!
Should I consider this a follow up task and proceed with this merge or should we add this to this PR?
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.
Studying how Actions are set up right now.
Is this related to the generation process or also to the runtime? |
For sure this affects the build process, so I need to run GitHub actions with Java 11. But it is true that we can still setup the build to compile for Java 8. However that would be unrelated from the GitHub actions configuration |
.github/workflows/build.yml
Outdated
distribution: 'adopt' | ||
java-version: ${{ matrix.java }} | ||
- name: Test | ||
run: ./gradlew ciBasicBuild |
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.
Looking at those two tasks (ciTest
and ciBasicBuild
) it seems we're just wasting CI time. Building is done two times, so I guess an unified task is enough, it will just say "Build" and we know it also contains tests.
Instead of creating custom tasks you can just invoke:
gradlew build
And it will take care of building and testing what it can actually build and test.
Under Ubuntu it's going to be JVM, JS, and linuxX64
.
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 is true that there is overlap between the two tasks. I originally add one, but following your comment in an issue I thought you preferred to have them split.
Normally I would use build or check, but at least on Mac they require to have Xcode installed to run also the native builds. I am not sure what kind of configuration it would require on GitHub actions, perhaps configuring GCC or other compilers, so I was thinking that we could get away with testing on the JVM for these frequently running actions. We could then have more complete actions later, to build on all platforms, and run those before a release or trigger them manually.
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 following your comment in an issue I thought you preferred to have them split.
Yeah I had guessed you did it because of this, sorry! In Jenkins I'm used to publish custom "check points" back to my GitHub Enterprise instance, but I guess GitHub Actions are not that advanced yet.
so I was thinking that we could get away with testing on the JVM for these frequently running actions
I'd test both JVM and JS. JS is a risky platform and it should be always tested imo (I know this by experience).
I'd say you can use gradlew build -Ptarget.is.native=false
.
target.is.native=false
disables all the Kotlin Native targets, I had this one prepared for this exact occasion.
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.
Thank you, I will run ./gradlew check -Ptarget.is.native=false.target.is.native=false
.github/workflows/build.yml
Outdated
- name: Test | ||
run: ./gradlew ciBasicBuild |
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.
There is a gradle-build-action action that will automatically cache various gradle build files between subsequent actions.
- name: Test | |
run: ./gradlew ciBasicBuild | |
- name: Test | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: ciBasicBuild |
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.
relevant action repo for reference: https://github.com/gradle/gradle-build-action
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.
Interesting, but for now I will keep things simple and avoid caches. For now I think we can have a single job and step and just look at logs if something fails
on my fork of the repo I had setup a GHA workflow for tests and deploying to our JFrog repo. feel free to grab anything you want from that action file, or ask questions about it. https://github.com/CruGlobal/antlr-kotlin/blob/build/v0.0.7/.github/workflows/publish-fork.yml |
@frett looks pretty neat! I've got a question, what's up with the |
Kotlin Multiplatform uses a Konan runtime to actually do the Kotlin/Native compilation. That binary was automatically downloaded and setup everytime a build would run. Unfortunately that isn't captured by the |
the publish action on my GHA workflow runs on macos to have access to XCode in order to get the ios targets. running it on macos does also support jvm & js, but there is potential additional costs for a macos runner vs a normal ubuntu runner. We have a enterprise account so I'm not sure if there are any costs or restrictions in place for an open source project |
Oh I see, makes sense! So (pardon my inexperience on Actions), splitting up the YAML file, we could have:
And:
Would this work? |
I would do:
the pull_request triggers are based on the branch you are merging into |
Thank you!
I guess this would mean two JS builds too. Maybe running on Java 11 only is sufficient? |
it's probably sufficient, but the GHA workflow is only taking 2-3 mins to run currently, so running it on both toolchains vs 1 wouldn't have a huge impact. plus those 2 jobs would run concurrently. |
Sounds reasonable. So, looking at the overall picture, we are left with:
I'm starting to understand how all of this work finally. |
yeah, although you missed the |
Damn, thanks! Added back in the comment. |
that looks good and should work as a starting point, the workflow can evolve over time as needs arise :) |
@frett so had a bit of docs reading and came up with: Edit: updated with a working script name: Build
on:
push:
branches: [ 'master' ]
pull_request:
branches: [ 'master' ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
include:
- java: '11'
target: JVM
task: jvmTest
- java: '17'
target: JVM
task: jvmTest
- java: '17'
target: JS
task: jsTest
runs-on: ubuntu-latest
name: Build (${{ matrix.java }} / ${{ matrix.target }})
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- name: Cache Konan
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ github.sha }}
restore-keys: ${{ runner.os }}-konan-
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run Build and Tests (${{ matrix.target }})
run: ./gradlew ${{ matrix.task }}
working-directory: ${{ github.workspace }}
continue-on-error: false This allows you to execute three jobs:
|
I'm not sure without giving it a try |
I've actually found out we can just do the following to define the matrix runs:
Easier and probably more understandable. |
Thanks! Another step towards easier maintenance is done 😎 |
The GitHub actions should now run for every commit and every PR.
We just perform some basic tasks, like compiling for the JVM and running tests on the JVM. Later one we could enable more tasks.
Fix #108