Skip to content

Commit b801db3

Browse files
authored
Added a few refinements to make the repo more user friendly. (#3)
* Enhanced the [README.md](README.md) * Added the [cheatsheet.md](cheatsheet.md) * Added the `build.sh` file * Added a PR checklist. * Updated the .gitignore file.
1 parent 01f0441 commit b801db3

File tree

6 files changed

+507
-5
lines changed

6 files changed

+507
-5
lines changed

.github/pull_request_template.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Description
2+
3+
Enter your description here.
4+
5+
## Checklist
6+
7+
- [ ] Unit tests created/updated for any new code (where applicable).
8+
- [ ] Run all tests with `./build.sh validate`.
9+
- [ ] Update the [CHANGELOG.md](CHANGELOG.md).
10+
- [ ] Update the [README.md](README.md) if necessary.

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@
2323
# Java
2424
target
2525

26+
# Properties files (may contain user credentials)
27+
consumer.properties
28+
producer.properties
29+
30+
# Exercises folder
31+
exercises/*
32+
!exercises/exercise.sh
33+
!exercises/exercise.bat
34+
35+
/flink*
36+

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# Changelog
22

3-
## Version 0.1
3+
## Version 0.1.0
44

55
* Initial commit of required files for a public repo.
66

7-
## Version 1.0
7+
## Version 1.0.0
88

9-
* Initial commit of exercise code.
9+
* Initial commit of exercise code.
10+
11+
## Version 1.1.0
12+
13+
* Enhanced the [README.md](README.md)
14+
* Added the [cheatsheet.md](cheatsheet.md)
15+
* Added the `build.sh`
16+
* Updated the `.gitignore`
17+
* Added a pull request template for Github.

README.md

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,77 @@
1-
# Building Flink Applications in Java
1+
# Building Apache Flink Applications in Java
22

3-
This repository is for the **Building Flink Applications in Java** course provided by Confluent Developer.
3+
This repository is for the **Building Flink Applications in Java** course provided by Confluent Developer.
4+
5+
[https://developer.confluent.io/courses/flink-java](https://developer.confluent.io/courses/flink-java)
6+
7+
## Requirements
8+
9+
- Java 11
10+
- Flink does not currently support anything newer than Java 11. The code in the repo assumes that you are using Java 11.
11+
- A Java development environment.
12+
- A Flink installation.
13+
- A Confluent Cloud account.
14+
15+
## Gitpod
16+
17+
A [Gitpod](https://gitpod.io/) configuration is available for these exercises. You can use this to construct a pre-configured environment suitable for working on the exercises:
18+
19+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/confluentinc/learn-building-flink-applications-in-java-exercises)
20+
21+
## Repo Structure
22+
23+
### build.sh
24+
25+
This script is intended for use by the course developers. Students can ignore it.
26+
27+
The `build.sh` script can be used to validate the code across all exercises and solutions.
28+
29+
```bash
30+
./build.sh validate
31+
```
32+
33+
This will stage and then solve each exercise before running the tests for that exercise. It will then move on to the next.
34+
35+
### install_flink.sh
36+
37+
This script is used by the `.gitpod.yml` to install Flink. However, if you are setting up a local environment, you may want to refer to this script (or even execute it) to get your own Flink installation ready.
38+
39+
### cheatsheet.md
40+
41+
A cheatsheet containing code snippets from the course lectures can be found in:
42+
43+
[cheatsheet.md](cheatsheet.md)
44+
45+
### exercises
46+
47+
This folder is where you should be doing your work. Initially it contains just a helper script (`exercise.sh`) but as you advance through the exercises it will contain more.
48+
49+
### exercises/exercise.sh
50+
51+
The `exercise.sh` script is there to help you advance through the exercises. At the beginning of each exercise, you can import any new code by running:
52+
53+
```bash
54+
./exercise.sh stage <exercise number>
55+
```
56+
57+
You can automatically solve an exercise by running:
58+
59+
```bash
60+
./exercise.sh solve <exercise number>
61+
```
62+
63+
**Note:** Solving an exercise will overwrite your code.
64+
65+
You can solve a single file by running:
66+
67+
```bash
68+
./exercise.sh solve <exercise number> <file name>
69+
```
70+
71+
### solutions
72+
73+
This folder contains the solutions for each exercise. You can use these as a reference if you get stuck. It is also used by the `exercise.sh` script to automatically solve exercises.
74+
75+
### staging
76+
77+
This folder is used by the `exercise.sh` script to set up each exercise. You can ignore it.

build.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
EXERCISES_DIR=exercises
6+
SOLUTIONS_DIR=solutions
7+
STAGING_DIR=staging
8+
SCRIPT_DIR=scripts
9+
10+
function help() {
11+
echo "Usage:"
12+
echo " build.sh <command>"
13+
echo " Commands:"
14+
echo " validate - Run through each exercise, stage the exercise, then apply the solution. Verify the exercise builds in it's final state."
15+
}
16+
17+
function validate() {
18+
WORKING_DIR=$(pwd)
19+
20+
EXERCISES=($(ls $SOLUTIONS_DIR/ | grep "^[0-9]*"))
21+
22+
TMP_DIR=target/tmp
23+
rm -rf $TMP_DIR
24+
mkdir -p $TMP_DIR
25+
26+
cp -r $EXERCISES_DIR $TMP_DIR
27+
cp -r $SOLUTIONS_DIR $TMP_DIR
28+
cp -r $STAGING_DIR $TMP_DIR
29+
30+
cd $TMP_DIR/$EXERCISES_DIR
31+
32+
for EXERCISE in "${EXERCISES[@]}"
33+
do
34+
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
35+
echo $EXERCISE
36+
./exercise.sh stage $EXERCISE
37+
./exercise.sh solve $EXERCISE
38+
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
39+
40+
if [ -f "pom.xml" ]; then
41+
mvn clean test
42+
fi
43+
done
44+
45+
rm -rf $TMP_DIR
46+
47+
cd $WORKING_DIR
48+
}
49+
50+
## Determine which command is being requested, and execute it.
51+
COMMAND=${1:-"help"}
52+
if [ "$COMMAND" = "validate" ]; then
53+
validate
54+
elif [ "$COMMAND" = "help" ]; then
55+
help
56+
else
57+
echo "INVALID COMMAND: $COMMAND"
58+
help
59+
exit 1
60+
fi

0 commit comments

Comments
 (0)