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
6 changes: 4 additions & 2 deletions .dagger/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ func (g *Greetings) DebugTests(
// Check if backend is broken
if _, berr := g.Backend.CheckDirectory(ctx, g.Backend.Source()); berr != nil {
ws := dag.Workspace(
g.Backend.Source(),
g.Source,
g.Backend.AsWorkspaceCheckable(),
".",
)
env := dag.Env().
WithWorkspaceInput("workspace", ws, "workspace to read, write, and test code").
Expand All @@ -39,8 +40,9 @@ func (g *Greetings) DebugTests(
// Check if frontend is broken
if _, ferr := g.Frontend.CheckDirectory(ctx, g.Frontend.Source()); ferr != nil {
ws := dag.Workspace(
g.Frontend.Source(),
g.Source,
g.Frontend.AsWorkspaceCheckable(),
"website",
)
env := dag.Env().
WithWorkspaceInput("workspace", ws, "workspace to read, write, and test code").
Expand Down
2 changes: 2 additions & 0 deletions .dagger/develop.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (g *Greetings) Develop(
g.Source,
// FIXME: no great way to determine which checker without submodule or self calls
g.Backend.AsWorkspaceCheckable(),
".",
)

env := dag.Env().
Expand Down Expand Up @@ -117,6 +118,7 @@ func (g *Greetings) DevelopFeedback(
source,
// FIXME: no great way to determine which checker without submodule or self calls
g.Backend.AsWorkspaceCheckable(),
".",
)

env := dag.Env().
Expand Down
1 change: 1 addition & 0 deletions .dagger/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (g *Greetings) DevelopReview(
source,
// FIXME: no great way to determine which checker without submodule or self calls
g.Backend.AsWorkspaceCheckable(),
".",
)

env := dag.Env().
Expand Down
14 changes: 9 additions & 5 deletions .dagger/workspace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type Checkable interface {

// Place to do work and check it
type Workspace struct {
Work *dagger.Directory
Work *dagger.Directory
CheckDirectory string
// +private
Start *dagger.Directory
// +private
Expand All @@ -28,11 +29,14 @@ func New(
source *dagger.Directory,
// Checker to use for testing
checker Checkable,
// Path to execute checker on
checkDirectory string,
) *Workspace {
return &Workspace{
Start: source,
Work: source,
Checker: checker,
Start: source,
Work: source,
Checker: checker,
CheckDirectory: checkDirectory,
}
}

Expand Down Expand Up @@ -76,7 +80,7 @@ func (w *Workspace) Tree(ctx context.Context) (string, error) {

// Run the tests in the workspace
func (w *Workspace) Check(ctx context.Context) (string, error) {
return w.Checker.CheckDirectory(ctx, w.Work)
return w.Checker.CheckDirectory(ctx, w.Work.Directory(w.CheckDirectory))
}

// Show the changes made to the workspace so far in unified diff format
Expand Down
2 changes: 1 addition & 1 deletion dagger.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "greetings",
"engineVersion": "v0.18.12",
"engineVersion": "v0.18.16",
"sdk": {
"source": "go"
},
Expand Down
6 changes: 3 additions & 3 deletions website/cypress/e2e/greeting_test.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
describe("Greetings API", () => {
it("should display a greeting", () => {
cy.visit("/");
cy.get("h1").should("contain", "Greetings Daggernauts");
cy.get("h1").should("contain", "Greetings Halifax!");
});

it("should change the greeting when the button is clicked", () => {
cy.visit("/");
cy.get("#greetingDisplay").should(
"contain",
"Click the button to see a greeting!",
"Click the button to see a Maritime greeting!",
);
cy.get("#randomGreetingButton").click();
cy.get("#greetingDisplay").should(
"not.contain",
"Click the button to see a greeting!",
"Click the button to see a Maritime greeting!",
);
});
});
87 changes: 62 additions & 25 deletions website/index.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,69 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Greetings App</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-purple-900 text-white font-sans flex flex-col items-center justify-center min-h-screen">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Halifax Harbour Greetings</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css"
rel="stylesheet"
/>
<style>
.maritime-gradient {
background: linear-gradient(
135deg,
#1e3a8a 0%,
#0369a1 50%,
#059669 100%
);
}
.harbor-blue {
background-color: #1e40af;
}
.lighthouse-beacon {
animation: pulse 2s infinite;
}
</style>
</head>
<body
class="maritime-gradient text-white font-sans flex flex-col items-center justify-center min-h-screen"
>
<div class="container mx-auto px-4 py-8 max-w-screen-md">
<h1 class="text-3xl font-bold mb-4">Greetings Daggernauts</h1>
<div id="greetingDisplay" class="greeting bg-purple-700 rounded shadow p-4 min-h-20 flex items-center justify-center">
Click the button to see a greeting!
</div>
<button id="randomGreetingButton" class="bg-purple-500 hover:bg-purple-400 text-white font-bold py-2 px-4 rounded mt-4">👋</button>
<h1 class="text-3xl font-bold mb-2">🌊 Halifax Harbour Greetings ⚓</h1>
<p class="text-blue-200 mb-4 text-center">
Welcome to the Atlantic's finest port city!
</p>
<div
id="greetingDisplay"
class="greeting harbor-blue rounded-lg shadow-lg p-6 min-h-20 flex items-center justify-center border-2 border-blue-300"
>
Click the button to receive a Maritime welcome!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Click the button to receive a Maritime welcome!
Click the button to see a Maritime greeting!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Click the button to receive a Maritime welcome!
Click the button to see a Maritime greeting!

</div>
<button
id="randomGreetingButton"
class="bg-teal-600 hover:bg-teal-500 text-white font-bold py-3 px-6 rounded-lg mt-4 lighthouse-beacon shadow-lg transition-all duration-200 hover:shadow-xl"
>
🦞 Ahoy!
</button>
</div>

<script>
async function getRandomGreeting() {
try {
const response = await fetch('http://localhost:8080/random');
const data = await response.json();
document.getElementById('greetingDisplay').textContent = data.greeting;
} catch (error) {
console.error('Error fetching greeting:', error);
document.getElementById('greetingDisplay').textContent = 'Error fetching greeting';
} }
async function getRandomGreeting() {
try {
const response = await fetch("http://localhost:8080/random");
const data = await response.json();
document.getElementById("greetingDisplay").textContent =
data.greeting;
} catch (error) {
console.error("Error fetching greeting:", error);
document.getElementById("greetingDisplay").textContent =
"Error fetching greeting";
}
}

document.getElementById('randomGreetingButton').addEventListener('click', getRandomGreeting);
document
.getElementById("randomGreetingButton")
.addEventListener("click", getRandomGreeting);
</script>
</body>
</html>
</body>
</html>
Loading