Archived
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0dbbae413 | ||
|
|
215ba3845d | ||
|
|
b53b4a3287 | ||
|
|
14bb82fc9d |
No files matched your search
@@ -128,11 +128,20 @@ jobs:
|
||||
echo "linux_arm64_sha=$(grep barn-linux-arm64 SHA256SUMS | awk '{print $1}')" >> $GITHUB_OUTPUT
|
||||
echo "linux_x64_sha=$(grep barn-linux-x64 SHA256SUMS | awk '{print $1}')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate Homebrew tap token
|
||||
uses: actions/create-github-app-token@v2
|
||||
id: homebrew-token
|
||||
with:
|
||||
app-id: ${{ vars.HOMEBREW_APP_ID }}
|
||||
private-key: ${{ secrets.HOMEBREW_APP_PRIVATE_KEY }}
|
||||
owner: samson-media
|
||||
repositories: homebrew-tap
|
||||
|
||||
- name: Checkout homebrew tap
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: samson-media/homebrew-tap
|
||||
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
||||
token: ${{ steps.homebrew-token.outputs.token }}
|
||||
path: homebrew-tap
|
||||
|
||||
- name: Update Homebrew formula
|
||||
|
||||
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [0.3.0] - 2026-03-03
|
||||
|
||||
### Added
|
||||
- RETRIES and NEXT RETRY columns in `barn status` human table output
|
||||
- Retry At field in single job detail view (`barn describe`)
|
||||
- Retry display tests for human, JSON, and XML output formats
|
||||
|
||||
## [0.1.7] - 2026-01-22
|
||||
|
||||
### Fixed
|
||||
@@ -67,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
- Jobs that fail to start now properly transition to FAILED state
|
||||
- Startup errors are written to stderr.log for visibility
|
||||
|
||||
[0.3.0]: https://github.com/samson-media/barn/releases/tag/v0.3.0
|
||||
[0.1.7]: https://github.com/samson-media/barn/releases/tag/v0.1.7
|
||||
[0.1.6]: https://github.com/samson-media/barn/releases/tag/v0.1.6
|
||||
[0.1.5]: https://github.com/samson-media/barn/releases/tag/v0.1.5
|
||||
|
||||
@@ -209,6 +209,8 @@ There needs to be a barn service in order to run jobs (unless you use --offline)
|
||||
| `error` | Human-readable failure reason |
|
||||
| `pid` | OS process ID (best-effort) |
|
||||
| `heartbeat` | Last liveness update |
|
||||
| `retryCount` | Current retry attempt (0 if never retried) |
|
||||
| `retryAt` | Timestamp for next retry attempt (null if not retrying)|
|
||||
|
||||
Users can tag jobs for the purpose of filtering using the `--tag=string` CLI option.
|
||||
|
||||
@@ -245,8 +247,8 @@ Developers can use the `--offline` command line option to test how the service b
|
||||
|
||||
**Example: `barn status`**
|
||||
```
|
||||
ID STATE LOAD TAG CREATED EXIT PID
|
||||
job-6d368040 succeeded medium - 2026-01-22 01:48:46 0 17486
|
||||
ID STATE LOAD TAG CREATED EXIT PID RETRIES NEXT RETRY
|
||||
job-6d368040 succeeded medium - 2026-01-22 01:48:46 0 17486 - -
|
||||
|
||||
Total: 1 job (1 succeeded)
|
||||
```
|
||||
|
||||
@@ -503,6 +503,7 @@ retry_delay_seconds = 5
|
||||
|
||||
**Expected:**
|
||||
- Job retries automatically
|
||||
- `barn status` shows retry count in **RETRIES** column and next retry time in **NEXT RETRY** column
|
||||
- Eventually succeeds on 3rd attempt
|
||||
- retry_count file shows retry history
|
||||
|
||||
@@ -523,7 +524,8 @@ retry_delay_seconds = 5
|
||||
|
||||
**Expected:**
|
||||
- Job state is "failed"
|
||||
- retry_count equals max_retries
|
||||
- **RETRIES** column shows retry count equal to max_retries
|
||||
- **NEXT RETRY** column shows `-` (no further retries)
|
||||
- No more retry attempts
|
||||
|
||||
---
|
||||
@@ -538,7 +540,7 @@ barn status
|
||||
```
|
||||
|
||||
**Expected:**
|
||||
- Formatted table or list
|
||||
- Formatted table with columns: ID, STATE, LOAD, TAG, CREATED, EXIT, PID, RETRIES, NEXT RETRY
|
||||
- Human-readable timestamps
|
||||
- Clear column headers
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.samsonmedia</groupId>
|
||||
<artifactId>barn</artifactId>
|
||||
<version>0.2.0</version>
|
||||
<version>0.3.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Barn</name>
|
||||
|
||||
@@ -121,6 +121,13 @@ public class ConfigShowCommand extends BaseCommand {
|
||||
sb.append(String.format("base_dir = %s%n", config.storage().baseDir()));
|
||||
sb.append(String.format("max_disk_usage_gb = %d%n", config.storage().maxDiskUsageGb()));
|
||||
sb.append(String.format("preserve_work_dir = %b%n", config.storage().preserveWorkDir()));
|
||||
sb.append("\n");
|
||||
|
||||
// Load section
|
||||
sb.append("[load]\n");
|
||||
sb.append(String.format("max_high_jobs = %d%n", config.loadLevels().maxHighJobs()));
|
||||
sb.append(String.format("max_medium_jobs = %d%n", config.loadLevels().maxMediumJobs()));
|
||||
sb.append(String.format("max_low_jobs = %d%n", config.loadLevels().maxLowJobs()));
|
||||
|
||||
getOut().println(sb.toString().trim());
|
||||
}
|
||||
@@ -131,6 +138,7 @@ public class ConfigShowCommand extends BaseCommand {
|
||||
map.put("jobs", buildJobsSection(config));
|
||||
map.put("cleanup", buildCleanupSection(config));
|
||||
map.put("storage", buildStorageSection(config));
|
||||
map.put("load", buildLoadSection(config));
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -171,4 +179,12 @@ public class ConfigShowCommand extends BaseCommand {
|
||||
storage.put("preserve_work_dir", config.storage().preserveWorkDir());
|
||||
return storage;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildLoadSection(Config config) {
|
||||
Map<String, Object> load = new LinkedHashMap<>();
|
||||
load.put("max_high_jobs", config.loadLevels().maxHighJobs());
|
||||
load.put("max_medium_jobs", config.loadLevels().maxMediumJobs());
|
||||
load.put("max_low_jobs", config.loadLevels().maxLowJobs());
|
||||
return load;
|
||||
}
|
||||
}
|
||||
@@ -135,12 +135,17 @@ public class HumanFormatter implements OutputFormatter {
|
||||
sb.append(" Retries: ").append(job.retryCount()).append("\n");
|
||||
}
|
||||
|
||||
if (job.retryAt() != null) {
|
||||
sb.append(" Retry At: ").append(formatTimestamp(job.retryAt())).append("\n");
|
||||
}
|
||||
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
private String formatJobTable(List<Job> jobs) {
|
||||
// Define columns
|
||||
List<String> headers = List.of("ID", "STATE", "LOAD", "TAG", "CREATED", "EXIT");
|
||||
List<String> headers = List.of(
|
||||
"ID", "STATE", "LOAD", "TAG", "CREATED", "EXIT", "RETRIES", "NEXT RETRY");
|
||||
|
||||
// Convert jobs to rows
|
||||
List<List<String>> rows = new ArrayList<>();
|
||||
@@ -151,7 +156,9 @@ public class HumanFormatter implements OutputFormatter {
|
||||
job.loadLevel().toString().toLowerCase(Locale.ROOT),
|
||||
job.tag() != null ? job.tag() : "-",
|
||||
formatTimestamp(job.createdAt()),
|
||||
job.exitCode() != null ? job.exitCode().toString() : "-"
|
||||
job.exitCode() != null ? job.exitCode().toString() : "-",
|
||||
job.retryCount() > 0 ? String.valueOf(job.retryCount()) : "-",
|
||||
job.retryAt() != null ? formatTimestamp(job.retryAt()) : "-"
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -195,19 +195,23 @@ public class StatusCommand extends BaseCommand {
|
||||
.max().orElse(3));
|
||||
|
||||
// Header
|
||||
sb.append(String.format("%-" + idWidth + "s %-9s %-6s %-" + tagWidth + "s %-19s %-4s %-8s%n",
|
||||
"ID", "STATE", "LOAD", "TAG", "CREATED", "EXIT", "PID"));
|
||||
sb.append(String.format(
|
||||
"%-" + idWidth + "s %-9s %-6s %-" + tagWidth + "s %-19s %-4s %-8s %-7s %-19s%n",
|
||||
"ID", "STATE", "LOAD", "TAG", "CREATED", "EXIT", "PID", "RETRIES", "NEXT RETRY"));
|
||||
|
||||
// Rows
|
||||
for (Job job : jobs) {
|
||||
sb.append(String.format("%-" + idWidth + "s %-9s %-6s %-" + tagWidth + "s %-19s %-4s %-8s%n",
|
||||
sb.append(String.format(
|
||||
"%-" + idWidth + "s %-9s %-6s %-" + tagWidth + "s %-19s %-4s %-8s %-7s %-19s%n",
|
||||
job.id(),
|
||||
job.state().toString().toLowerCase(Locale.ROOT),
|
||||
job.loadLevel().toString().toLowerCase(Locale.ROOT),
|
||||
job.tag() != null ? job.tag() : "-",
|
||||
formatTimestamp(job.createdAt()),
|
||||
job.exitCode() != null ? job.exitCode().toString() : "-",
|
||||
job.pid() != null ? job.pid().toString() : "-"));
|
||||
job.pid() != null ? job.pid().toString() : "-",
|
||||
job.retryCount() > 0 ? String.valueOf(job.retryCount()) : "-",
|
||||
job.retryAt() != null ? formatTimestamp(job.retryAt()) : "-"));
|
||||
}
|
||||
|
||||
// Summary
|
||||
|
||||
@@ -186,11 +186,11 @@ public final class ConfigLoader {
|
||||
}
|
||||
|
||||
private Config buildConfig(Map<String, Map<String, Object>> data) {
|
||||
// Handle both "load_levels" (from TOML) and "loadlevels" (from env vars)
|
||||
Map<String, Object> loadLevelData = data.getOrDefault("load_levels", Map.of());
|
||||
if (loadLevelData.isEmpty()) {
|
||||
loadLevelData = data.getOrDefault("loadlevels", Map.of());
|
||||
}
|
||||
// Merge both "load_levels" (from TOML) and "loadlevels" (from env vars)
|
||||
// Env vars (loadlevels) take precedence over config file (load_levels)
|
||||
Map<String, Object> loadLevelData = new HashMap<>(data.getOrDefault("load_levels", Map.of()));
|
||||
loadLevelData.putAll(data.getOrDefault("loadlevels", Map.of()));
|
||||
|
||||
return new Config(
|
||||
buildServiceConfig(data.getOrDefault("service", Map.of())),
|
||||
buildJobsConfig(data.getOrDefault("jobs", Map.of())),
|
||||
|
||||
@@ -79,6 +79,18 @@ class HumanFormatterTest {
|
||||
assertThat(result).contains("Process failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
void format_withRetryingJob_shouldShowRetryInfo() {
|
||||
Job job = createRetryingJob("job-retry1234", 3,
|
||||
Instant.parse("2026-01-15T10:30:00Z"));
|
||||
|
||||
String result = formatter.format(job);
|
||||
|
||||
assertThat(result).contains("Retries:");
|
||||
assertThat(result).contains("3");
|
||||
assertThat(result).contains("Retry At:");
|
||||
}
|
||||
|
||||
@Test
|
||||
void format_withMap_shouldFormatKeyValues() {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
@@ -127,6 +139,18 @@ class HumanFormatterTest {
|
||||
assertThat(result).contains("medium");
|
||||
}
|
||||
|
||||
@Test
|
||||
void formatList_withRetryingJob_shouldShowRetryColumns() {
|
||||
List<Job> jobs = List.of(createRetryingJob("job-retry1234", 2,
|
||||
Instant.parse("2026-01-15T10:30:00Z")));
|
||||
|
||||
String result = formatter.formatList(jobs);
|
||||
|
||||
assertThat(result).contains("RETRIES");
|
||||
assertThat(result).contains("NEXT RETRY");
|
||||
assertThat(result).contains("2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void formatList_withStrings_shouldFormatEach() {
|
||||
List<String> strings = List.of("item1", "item2", "item3");
|
||||
@@ -242,4 +266,23 @@ class HumanFormatterTest {
|
||||
MEDIUM
|
||||
);
|
||||
}
|
||||
|
||||
private Job createRetryingJob(String id, int retryCount, Instant retryAt) {
|
||||
return new Job(
|
||||
id,
|
||||
JobState.QUEUED,
|
||||
List.of("echo", "test"),
|
||||
"tag",
|
||||
Instant.now().minus(Duration.ofMinutes(5)),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
retryCount,
|
||||
retryAt,
|
||||
MEDIUM
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -14,6 +16,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import com.samsonmedia.barn.config.JobsConfig;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
|
||||
@@ -100,6 +103,22 @@ class StatusCommandTest {
|
||||
assertThat(exitCode).isZero();
|
||||
assertThat(stdout.toString().toLowerCase()).contains("queued");
|
||||
}
|
||||
|
||||
@Test
|
||||
void status_withRetryingJob_shouldShowRetryColumns() throws IOException {
|
||||
Job job = repository.create(List.of("echo", "test"), "test", config);
|
||||
repository.markStarted(job.id(), 12345L);
|
||||
repository.markCompleted(job.id(), 1, "test failure");
|
||||
Instant retryAt = Instant.now().plus(5, ChronoUnit.MINUTES);
|
||||
repository.scheduleRetry(job.id(), retryAt);
|
||||
|
||||
int exitCode = cmd.execute("--offline");
|
||||
|
||||
assertThat(exitCode).isZero();
|
||||
String output = stdout.toString();
|
||||
assertThat(output).contains("RETRIES");
|
||||
assertThat(output).contains("NEXT RETRY");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -192,8 +192,44 @@ class XmlFormatterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class RetryFields {
|
||||
|
||||
@Test
|
||||
void format_withRetryingJob_shouldIncludeRetryFields() {
|
||||
Job job = createRetryingJob("job-retry1234", 2,
|
||||
Instant.parse("2026-01-15T10:30:00Z"));
|
||||
|
||||
String result = formatter.format(job);
|
||||
|
||||
assertThat(result).contains("<retry_count>2</retry_count>");
|
||||
assertThat(result).contains("<retry_at>");
|
||||
assertThat(result).contains("2026-01-15T10:30:00Z");
|
||||
assertThat(result).contains("</retry_at>");
|
||||
}
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
||||
private Job createRetryingJob(String id, int retryCount, Instant retryAt) {
|
||||
return new Job(
|
||||
id,
|
||||
JobState.QUEUED,
|
||||
List.of("echo", "test"),
|
||||
"tag",
|
||||
Instant.now(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
retryCount,
|
||||
retryAt,
|
||||
MEDIUM
|
||||
);
|
||||
}
|
||||
|
||||
private Job createJob(String id, JobState state, String tag) {
|
||||
return new Job(
|
||||
id,
|
||||
|
||||
Reference in new issue
Block a user