Skip to content

Commit

Permalink
Update GitHub Actions workflow and build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sofusalbertsen committed Jan 23, 2024
1 parent 52c9d78 commit c2c4cd9
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 139 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Main workflow
on: push
jobs:
Build:
runs-on: ubuntu-latest
container: gradle:6-jdk11
steps:
- name: Clone-down
- name: Clone down repository
uses: actions/checkout@v4
- run: ci/build-app.sh
- name: Build application
run: ci/build-app.sh
- name: Test
run: ci/unit-test-app.sh
51 changes: 34 additions & 17 deletions labs/build-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
container: gradle:6-jdk11
steps:
- name: Clone-down
- name: Clone down repository
uses: actions/checkout@v4
- run: chmod +x ci/build-app.sh && ci/build-app.sh
```
Expand All @@ -56,12 +56,15 @@ A line-by-line explanation of the above:
- **Line 4-5**: Defines a job named `Build` that runs on an Ubuntu VM.
- **Line 6**: Specifies that the job should run in a container with the image `gradle:6-jdk11`.
- **Line 7**: Defines the steps that should be executed in the job.
- **Line 8-9**: Checks out the repository's content to the runner, enabling subsequent steps to access it.
- **Line 10**: Runs the `build-app.sh` script.
- **Line 8**: A step named `Clone down repository`
- **Line 9**: Uses the action `actions/checkout@v4`, to clone down the repository's content to the runner, enabling subsequent steps to access it.
- **Line 10**: Runs the `build-app.sh` script found in the `ci` directory of the repository.


This workflow is a basic example that provides insights into the event type, branch reference, and repository structure when code is pushed to it.

If you want to see what `build-app.sh` is doing, look into [the script](../ci/build-app.sh).

## Task

- Replase the workflow you created in `.github/workflows/main.yml` with the above example.
Expand All @@ -81,28 +84,42 @@ git push

- Go to Github Actions tab of the repository and check the action status.

## Results

You should see something like this in the logs of Github Actions:
### Results
See that the build runs green and outputs this in the step log:

```bash
#!/bin/sh -eo pipefail
echo 'Hello World!'
Run ./ci/build-app.sh
Hello World!
```
Welcome to Gradle 6.9!
Here are the highlights of this release:
- This is a small backport release.
- Java 16 can be used to compile when used with Java toolchains
- Dynamic versions can be used within plugin declarations
- Native support for Apple Silicon processors
**Manually triggering the workflow**
For more details see https://docs.gradle.org/6.9/release-notes.html
You can also trigger the workflow manually by clicking the `Run workflow` button.
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :clean UP-TO-DATE
![run-workflow](img/run-workflow.png)
> Task :compileJava
Note: Creating bean classes for 3 type elements
- Click on the `Run workflow` button and click `Run workflow` again in the popup.
- Go to the `Actions` tab and see the workflow running again, this time with the `workflow_dispatch` event.
> Task :processResources
> Task :classes
> Task :shadowJar
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 28s
4 actionable tasks: 3 executed, 1 up-to-date
```

## Summary
Congratulations!

You have successfully created the first Github Actions workflow, and ran it successfully :tada:.
Congratulations, you have now build the java application!

But we have some way to go yet, we want to build a docker image, and run some tests on it as well.
6 changes: 3 additions & 3 deletions labs/extend-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ If you strugle and need to see the whole ***Solution*** you can extend the secti
runs-on: ubuntu-latest
container: gradle:6-jdk11
steps:
- name: Clone-down
- name: Clone down repository
uses: actions/checkout@v4
- name: Build application
run: chmod +x ci/build-app.sh && ci/build-app.sh
run: ci/build-app.sh
- name: Test
run: chmod +x ci/unit-test-app.sh && ci/unit-test-app.sh
run: ci/unit-test-app.sh

```

Expand Down
116 changes: 0 additions & 116 deletions labs/workflow-with-containers.md

This file was deleted.

12 changes: 12 additions & 0 deletions trainer/.github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on: push
jobs:
Build:
runs-on: ubuntu-latest
container: gradle:6-jdk11
steps:
- name: Clone down repository
uses: actions/checkout@v4
- name: Build application
run: ci/build-app.sh
- name: Test
run: ci/unit-test-app.sh

0 comments on commit c2c4cd9

Please sign in to comment.