Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,59 @@ name: "dropwizard-ci-pipeline"
on:
push:
branches:
- main
- main # Trigger on push to main
pull_request:
branches:
- main # Trigger on PRs targeting main

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Install Java
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
java-version: '11'

- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew build -x test

- name: Run tests
run: ./gradlew test
run: ./gradlew test

system-test:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v4

- name: Run Docker Compose
run: docker compose up -d --build

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install test dependencies
run: pip install pytest requests

- name: Wait for server
run: |
for i in $(seq 1 30); do
curl -s http://localhost:8085/hello-world && exit 0
sleep 2
done
echo "Server never came up" && exit 1

- name: Run system tests
run: pytest

- name: Bring server down
if: always()
run: docker compose down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /home/gradle/src
RUN gradle shadowJar

# Get the Java version 8 image
FROM openjdk:11
FROM eclipse-temurin:11

WORKDIR /app
COPY --from=build /home/gradle/src/build/libs/hello-friends-1.0-SNAPSHOT.jar /app
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'

services:
# just a random name.
oh-my-server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;

// Modifying main so that I can commit something for the lab exercise.
// This will be deleted later.

public class HelloWorldApplication extends Application<HelloWorldConfiguration> {
public static void main(String[] args) throws Exception {
new HelloWorldApplication().run(args);
Expand Down
17 changes: 17 additions & 0 deletions src/test/pytest/Test_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json
import requests

# Verifies that the server correctly returns a status code of 404 (Not Found)
# in the response's JSON payload.
def test_code():
response=requests.get("http://localhost:8085")
json_response=response.json()
assert(json_response["code"]==404)


# Validates that the server returns the expected error message in the "message"
# field of the JSON response.
def test_message():
response=requests.get("http://localhost:8085")
json_response=response.json()
assert(json_response["message"]=="HTTP 404 Not Found")
Loading