Skip to content

Commit

Permalink
#104 Run tests for the user creating the PR and validate that the cal…
Browse files Browse the repository at this point in the history
…culate file exists for the user
  • Loading branch information
filiphr committed Jan 5, 2024
1 parent a53549a commit f2a3b40
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ jobs:

- name: 'Build project'
run: mvn -B clean verify -Pci

- name: 'Setup SDKMAN'
uses: sdkman/sdkman-action@b1f9b696c79148b66d3d3a06f7ea801820318d0f
id: sdkman
if: github.event_name == 'pull_request'

- name: 'Test submission'
run: ./test.sh ${{ github.event.pull_request.user.login }}
if: github.event_name == 'pull_request'
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=21.0.1-open
1 change: 1 addition & 0 deletions calculate_average_filiphr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 21.0.1-graal 1>&2
sdk use java 21.0.1-graal 1>&2
JAVA_OPTS=""
time java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_filiphr
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
<exclude>**/measurements*.txt</exclude>
<exclude>**/measurements*.out</exclude>
<exclude>out_expected.txt</exclude>
<exclude>.sdkmanrc</exclude>
</excludes>
</configuration>
<executions>
Expand Down
8 changes: 7 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ if [ -z "$1" ]; then
exit 1
fi

CALCULATE_FILE="./calculate_average_$1.sh"
if [ ! -f "$CALCULATE_FILE" ]; then
echo "$CALCULATE_FILE does not exist."
exit 1
fi

for sample in $(ls src/test/resources/samples/*.txt); do
echo "Validating calculate_average_$1.sh -- $sample"

rm -f measurements.txt
ln -s $sample measurements.txt

diff <("./calculate_average_$1.sh") ${sample%.txt}.out
diff <(${CALCULATE_FILE}) ${sample%.txt}.out
done
rm measurements.txt

0 comments on commit f2a3b40

Please sign in to comment.