-
Notifications
You must be signed in to change notification settings - Fork 0
Configure gradle to check code samples
#53
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a553bc7
Add the local Java version to `gitignore`
JuliaEvseeva 83509c3
Configure gradle to be able to build code samples, embed, and check them
JuliaEvseeva 3728967
Run action on PR
JuliaEvseeva 5d12a35
Use the appropriate Java version
JuliaEvseeva 448f3d9
Use the `macos-latest` to be able to run the binary
JuliaEvseeva 4b93e48
Update the documentation
JuliaEvseeva d3d265b
Disable the code check until the issue with code alignment will be fixed
JuliaEvseeva 2f9dd10
Update the `README.md`
JuliaEvseeva 8e6b9c6
Add `samples` and include them to the build
JuliaEvseeva 0be11e6
Improve the `EMBEDDING` guide
JuliaEvseeva 067262a
Update `README`
JuliaEvseeva d74bbc0
Add gradle build folders to ignore
JuliaEvseeva 512e49c
Try to use `ubuntu` binary for GH Action
JuliaEvseeva aa7ad3c
Add permissions to the binary
JuliaEvseeva 087d9b7
Disable the `embedded-samples` check until the issue with alignment w…
JuliaEvseeva b3dfec8
Improve comment
JuliaEvseeva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Check Code Embedding | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| build-embedded-code: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| submodules: 'recursive' | ||
|
|
||
| - uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: 8 | ||
| distribution: zulu | ||
|
|
||
| - run: ./gradlew :buildAll | ||
|
|
||
| check-embedded-samples: | ||
| # TODO:2025-12-16:julia.evseeva: Remove the `if: false` when the issue | ||
| # will be fixed https://github.com/SpineEventEngine/embed-code/issues/66 | ||
| if: false | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| submodules: 'recursive' | ||
|
|
||
| - uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: 11 | ||
| distribution: zulu | ||
|
|
||
| - name: Check Embedding | ||
| run: ./gradlew :checkSamples | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ of the spine.io documentation: | |
|
|
||
| * `examples` — contains examples selected from the repositories under `spine-examples` | ||
| organization. These repositories are added to this project as Git submodules. | ||
| * `samples` — smaller pieces of code embedded to the site. | ||
|
|
||
| To get the latest version of the code snippets, update the submodules: | ||
|
|
||
|
|
@@ -50,7 +51,7 @@ to the documentation files using the tool. The most important points here are: | |
| ### How to update an existing code snippet? | ||
|
|
||
| 1. Update the snippet in the appropriate repository. | ||
| 2. Make sure it builds successfully: `./gradlew build`. | ||
| 2. Make sure it builds successfully. | ||
| 3. Go to the `SpineEventEngine/documentation` project. | ||
| 4. Navigate to the `_code` directory. | ||
| 5. Execute the binary based on your operating system and architecture: | ||
|
|
@@ -61,20 +62,44 @@ to the documentation files using the tool. The most important points here are: | |
| ./embed-code-macos -config-path="config-v1.yml" -mode="embed" | ||
| ``` | ||
|
|
||
| ### How to add a new code snippet? | ||
| ### Adding a new example project | ||
|
|
||
| 1. Add a new snippet in the appropriate repository. | ||
| 2. Make sure it builds successfully: `./gradlew build`. | ||
| 3. Go to the `SpineEventEngine/documentation` project and insert code | ||
| embedding directives where needed. | ||
| 4. Navigate to the `_code` directory. | ||
| 5. Execute: `./embed-code -config-path="config-of-your-choice.yml" -mode="embed"`. | ||
| 1. Make sure the project you're going to add has a top-level `buildAll` Gradle task. | ||
|
|
||
| See the build script of [Hello Example](https://github.com/spine-examples/hello/blob/master/build.gradle) | ||
| for the declaration of such a task. This task must be present in both single- | ||
| and multi-module Gradle example projects that are going to be used for | ||
| embedding into this site. | ||
|
|
||
| See the declaration of `buildAll` task for more details. | ||
|
|
||
| 2. Add the example code as a submodule for this project: | ||
|
|
||
| ```bash | ||
| git submodule add https://github.com/spine-examples/<example-name> _code/examples/<example-name> | ||
| ``` | ||
| Please make sure the new submodule goes under the `_code/examples` directory, as shown in | ||
| the command line template above. | ||
|
|
||
| 3. Include the build of the added project into the [`settings.gradle.kts`](settings.gradle.kts) | ||
| file. | ||
| 4. Insert code embedding directives where needed in the `docs/content/` folder. | ||
| 5. Navigate to the `_code` directory. | ||
| 6. Execute: `./embed-code -config-path="config-of-your-choice.yml" -mode="embed"`. | ||
|
|
||
| For example: | ||
| ```shell | ||
| ./embed-code-macos -config-path="config-v1.yml" -mode="embed" | ||
| ``` | ||
|
|
||
| ### Adding a new small piece | ||
|
|
||
| 1. Add the code under `_code/samples/src` directory. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's discuss this vocally again. I can see this folder as a Gradle project here, but not in this repo. |
||
| 2. Make sure tests for the new code pass. | ||
| 3. Add the new piece using the [`embed-code` guide][embed-code-readme]. | ||
| 4. Include the build of the added project into the [`settings.gradle.kts`](settings.gradle.kts) | ||
| file `includeBuild("./_code/samples")`. | ||
|
|
||
| ### How to remove a code snippet? | ||
|
|
||
| 1. Remove the snippet in the appropriate repository. | ||
|
|
||
Binary file not shown.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Copyright 2020, TeamDev. All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Redistribution and use in source and/or binary forms, with or without | ||
| * modification, must retain the above copyright notice and the following | ||
| * disclaimer. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| plugins { | ||
| id "io.spine.tools.gradle.bootstrap" version "1.7.0" | ||
| } | ||
|
|
||
| spine.enableJava().server() | ||
|
|
||
| ext { | ||
| junitVersion = '5.7.0' | ||
| } | ||
|
|
||
| dependencies { | ||
| testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" | ||
| testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" | ||
| } | ||
|
|
||
| test { | ||
| useJUnitPlatform { | ||
| includeEngines 'junit-jupiter' | ||
| } | ||
| } | ||
|
|
||
| project.ext { | ||
| // The root for the generated source code. | ||
| generatedRootDir = "$projectDir/generated" | ||
|
|
||
| // Directories for the code generated by the Protobuf Compiler and Spine plugins | ||
| // for the Compiler. | ||
| generatedJavaDir = "$generatedRootDir/main/java" | ||
| generatedTestJavaDir = "$generatedRootDir/test/java" | ||
|
|
||
| // Directories for the Spine-specific code generated by the Spine Model Compiler, | ||
| // for example, rejections. | ||
| generatedSpineDir = "$generatedRootDir/main/spine" | ||
| generatedTestSpineDir = "$generatedRootDir/test/spine" | ||
| } | ||
|
|
||
| apply plugin: 'idea' | ||
|
|
||
| idea { | ||
| module { | ||
| // Add generated code directories to the source code of the module in IntelliJ IDEA. | ||
| generatedSourceDirs += file(generatedJavaDir) | ||
| generatedSourceDirs += file(generatedSpineDir) | ||
| testSourceDirs += file(generatedTestJavaDir) | ||
| testSourceDirs += file(generatedTestSpineDir) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The task for composite builds to include this project and depend on this top-level task. | ||
| */ | ||
| task buildAll(type: GradleBuild) { | ||
| tasks = [ 'build' ] | ||
| } |
Binary file not shown.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.