Compare commits

..

1 Commits

Author SHA1 Message Date
Valentin Maerten
0431e4bf27 test(failfast): use duration assertion instead of stdout to fix flake 2026-04-19 22:55:23 +02:00
11 changed files with 74 additions and 338 deletions

View File

@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"testing"
"time"
"github.com/sebdah/goldie/v2"
"github.com/stretchr/testify/require"
@@ -30,13 +31,15 @@ type (
// gen:fixtures`.
ExecutorTest struct {
TaskTest
task string
vars map[string]any
input string
executorOpts []task.ExecutorOption
wantSetupError bool
wantRunError bool
wantStatusError bool
task string
vars map[string]any
input string
executorOpts []task.ExecutorOption
wantSetupError bool
wantRunError bool
wantStatusError bool
skipOutputFixture bool
maxDuration time.Duration
}
)
@@ -113,6 +116,32 @@ func (opt *statusErrorTestOption) applyToExecutorTest(t *ExecutorTest) {
t.wantStatusError = true
}
// WithoutOutputFixture disables the stdout/stderr golden fixture comparison.
// Use for tasks with non-deterministic output by design (e.g. parallel deps
// cancelled mid-execution) where only the run error or timing matters.
func WithoutOutputFixture() ExecutorTestOption {
return &withoutOutputFixtureTestOption{}
}
type withoutOutputFixtureTestOption struct{}
func (opt *withoutOutputFixtureTestOption) applyToExecutorTest(t *ExecutorTest) {
t.skipOutputFixture = true
}
// WithMaxDuration asserts the run phase completes within d. Use to verify
// that failfast/cancellation kicks in promptly instead of waiting for deps
// to finish naturally.
func WithMaxDuration(d time.Duration) ExecutorTestOption {
return &maxDurationTestOption{d: d}
}
type maxDurationTestOption struct{ d time.Duration }
func (opt *maxDurationTestOption) applyToExecutorTest(t *ExecutorTest) {
t.maxDuration = opt.d
}
// Helpers
// writeFixtureErrRun is a wrapper for writing the output of an error during the
@@ -172,7 +201,9 @@ func (tt *ExecutorTest) run(t *testing.T) {
if err := e.Setup(); tt.wantSetupError {
require.Error(t, err)
tt.writeFixtureErrSetup(t, g, err)
tt.writeFixtureBuffer(t, g, buffer.buf)
if !tt.skipOutputFixture {
tt.writeFixtureBuffer(t, g, buffer.buf)
}
return
} else {
require.NoError(t, err)
@@ -190,10 +221,18 @@ func (tt *ExecutorTest) run(t *testing.T) {
// Run the task and check for errors
ctx := t.Context()
if err := e.Run(ctx, call); tt.wantRunError {
start := time.Now()
err := e.Run(ctx, call)
if tt.maxDuration > 0 {
require.Less(t, time.Since(start), tt.maxDuration,
"task took too long — failfast/cancellation likely did not trigger")
}
if tt.wantRunError {
require.Error(t, err)
tt.writeFixtureErrRun(t, g, err)
tt.writeFixtureBuffer(t, g, buffer.buf)
if !tt.skipOutputFixture {
tt.writeFixtureBuffer(t, g, buffer.buf)
}
return
} else {
require.NoError(t, err)
@@ -206,7 +245,9 @@ func (tt *ExecutorTest) run(t *testing.T) {
}
}
tt.writeFixtureBuffer(t, g, buffer.buf)
if !tt.skipOutputFixture {
tt.writeFixtureBuffer(t, g, buffer.buf)
}
}
// Run the test (with a name if it has one)
@@ -1130,12 +1171,14 @@ func TestFailfast(t *testing.T) {
NewExecutorTest(t,
WithName("default"),
WithVar("SLEEP", "sleep 5 && "),
WithExecutorOptions(
task.WithDir("testdata/failfast/default"),
task.WithSilent(true),
task.WithFailfast(true),
),
WithPostProcessFn(PPSortedLines),
WithoutOutputFixture(),
WithMaxDuration(4*time.Second),
WithRunError(),
)
})
@@ -1149,7 +1192,8 @@ func TestFailfast(t *testing.T) {
task.WithDir("testdata/failfast/task"),
task.WithSilent(true),
),
WithPostProcessFn(PPSortedLines),
WithoutOutputFixture(),
WithMaxDuration(4*time.Second),
WithRunError(),
)
})

View File

@@ -1,14 +1,20 @@
version: '3'
vars:
SLEEP: ''
tasks:
default:
deps:
- dep1
- dep2
- dep3
- task: dep1
vars: { SLEEP: '{{.SLEEP}}' }
- task: dep2
vars: { SLEEP: '{{.SLEEP}}' }
- task: dep3
vars: { SLEEP: '{{.SLEEP}}' }
- dep4
dep1: sleep 0.1 && echo 'dep1'
dep2: sleep 0.2 && echo 'dep2'
dep3: sleep 0.3 && echo 'dep3'
dep1: '{{.SLEEP}}echo ''dep1'''
dep2: '{{.SLEEP}}echo ''dep2'''
dep3: '{{.SLEEP}}echo ''dep3'''
dep4: exit 1

View File

@@ -1 +1 @@
task: Failed to run task "default": task: Failed to run task "dep4": exit status 1
task: Failed to run task "default": task: Failed to run task "dep4": exit status 1

View File

@@ -9,7 +9,7 @@ tasks:
- dep4
failfast: true
dep1: sleep 0.1 && echo 'dep1'
dep2: sleep 0.2 && echo 'dep2'
dep3: sleep 0.3 && echo 'dep3'
dep1: sleep 5 && echo 'dep1'
dep2: sleep 6 && echo 'dep2'
dep3: sleep 7 && echo 'dep3'
dep4: exit 1

View File

@@ -1 +1 @@
task: Failed to run task "default": task: Failed to run task "dep4": exit status 1
task: Failed to run task "default": task: Failed to run task "dep4": exit status 1

View File

@@ -1,80 +0,0 @@
export interface Adopter {
name: string;
url: string;
img: string;
}
export const adopters: Adopter[] = [
// Big brand names
{
name: 'Docker',
url: 'https://github.com/docker/mcp-registry',
img: 'https://github.com/docker.png'
},
{
name: 'Microsoft',
url: 'https://github.com/Azure/Azure-Sentinel',
img: 'https://github.com/microsoft.png'
},
{
name: 'HashiCorp',
url: 'https://github.com/hashicorp/terraform-aws-terraform-enterprise-hvd',
img: 'https://github.com/hashicorp.png'
},
{
name: 'Vercel',
url: 'https://github.com/vercel/terraform-provider-vercel',
img: 'https://github.com/vercel.png'
},
{
name: 'Google Cloud',
url: 'https://github.com/GoogleCloudPlatform/deploystack',
img: 'https://github.com/GoogleCloudPlatform.png'
},
{
name: 'AWS',
url: 'https://github.com/aws-samples/appmod-blueprints',
img: 'https://github.com/aws-samples.png'
},
{
name: 'Anthropic',
url: 'https://github.com/anthropics/buffa',
img: 'https://github.com/anthropics.png'
},
// Notable open source projects
{
name: 'Flet',
url: 'https://github.com/flet-dev/flet',
img: 'https://github.com/flet-dev.png'
},
{
name: 'GoReleaser',
url: 'https://github.com/goreleaser/goreleaser',
img: 'https://github.com/goreleaser.png'
},
{
name: 'Arduino CLI',
url: 'https://github.com/arduino/arduino-cli',
img: 'https://github.com/arduino.png'
},
{
name: 'FerretDB',
url: 'https://github.com/FerretDB/FerretDB',
img: 'https://github.com/FerretDB.png'
},
{
name: 'Tyk',
url: 'https://github.com/TykTechnologies/tyk',
img: 'https://github.com/TykTechnologies.png'
},
{
name: 'Charmbracelet',
url: 'https://github.com/charmbracelet/glamour',
img: 'https://github.com/charmbracelet.png'
},
{
name: 'Outline',
url: 'https://github.com/OutlineFoundation/outline-server',
img: 'https://github.com/OutlineFoundation.png'
}
];

View File

@@ -1,201 +0,0 @@
<script setup lang="ts">
import { adopters } from '../adopters';
const loop = [...adopters, ...adopters];
</script>
<template>
<section class="adopters-carousel" aria-labelledby="adopters-heading">
<h2 id="adopters-heading" class="label">
<span class="slashes">//</span>
Trusted by open source projects
</h2>
<p class="subline">
Adopted by <strong>Docker</strong>, <strong>Microsoft</strong>,
<strong>HashiCorp</strong>, <strong>Vercel</strong>,
<strong>Google Cloud</strong>, <strong>AWS</strong>,
<strong>Anthropic</strong> and more.
</p>
<div class="viewport">
<div class="track">
<a
v-for="(item, i) in loop"
:key="`${item.name}-${i}`"
:href="item.url"
target="_blank"
rel="noopener"
class="chip"
:aria-label="`${item.name} on GitHub`"
>
<img
:src="item.img"
:alt="`${item.name} logo`"
class="logo"
loading="lazy"
decoding="async"
width="28"
height="28"
/>
<span class="name">{{ item.name }}</span>
<span class="chevron" aria-hidden="true">&rarr;</span>
</a>
</div>
</div>
</section>
</template>
<style scoped>
.adopters-carousel {
max-width: 1248px;
margin: 5rem auto 2rem;
padding: 0 24px;
}
.label {
font-family: var(--vp-font-family-mono);
font-size: 0.8rem;
font-weight: 500;
letter-spacing: 0.04em;
color: var(--vp-c-text-2);
text-transform: uppercase;
text-align: center;
margin: 0 0 0.75rem;
}
.slashes {
color: var(--vp-c-brand-1);
margin-right: 0.4em;
}
.subline {
text-align: center;
font-size: 0.95rem;
color: var(--vp-c-text-2);
max-width: 640px;
margin: 0 auto 2rem;
line-height: 1.5;
}
.subline strong {
color: var(--vp-c-text-1);
font-weight: 600;
}
.viewport {
overflow: hidden;
-webkit-mask-image: linear-gradient(
90deg,
transparent 0,
#000 6%,
#000 94%,
transparent 100%
);
mask-image: linear-gradient(
90deg,
transparent 0,
#000 6%,
#000 94%,
transparent 100%
);
}
.track {
display: flex;
gap: 0.875rem;
width: max-content;
animation: scroll 55s linear infinite;
padding: 6px 0;
}
.track:hover {
animation-play-state: paused;
}
.chip {
display: inline-flex;
align-items: center;
gap: 0.75rem;
padding: 0.625rem 1.125rem 0.625rem 0.625rem;
border: 1px solid var(--vp-c-divider);
border-radius: 999px;
background: var(--vp-c-bg-soft);
color: var(--vp-c-text-1);
text-decoration: none !important;
white-space: nowrap;
transition:
border-color 0.25s ease,
background 0.25s ease,
transform 0.25s ease,
box-shadow 0.25s ease;
}
.chip:hover {
border-color: var(--vp-c-brand-1);
background: var(--vp-c-bg);
transform: translateY(-2px);
box-shadow: 0 6px 20px -10px
color-mix(in srgb, var(--vp-c-brand-1) 60%, transparent);
}
.logo {
width: 28px;
height: 28px;
border-radius: 6px;
object-fit: cover;
flex-shrink: 0;
background: #fff;
}
.name {
font-size: 0.9rem;
font-weight: 500;
letter-spacing: -0.005em;
}
.chevron {
font-family: var(--vp-font-family-mono);
font-size: 0.85rem;
color: var(--vp-c-text-3);
opacity: 0;
transform: translateX(-4px);
transition:
opacity 0.25s ease,
transform 0.25s ease,
color 0.25s ease;
margin-left: -0.25rem;
}
.chip:hover .chevron {
opacity: 1;
transform: translateX(0);
color: var(--vp-c-brand-1);
}
@keyframes scroll {
from {
transform: translateX(0);
}
to {
transform: translateX(calc(-50% - 0.4375rem));
}
}
@media (max-width: 640px) {
.adopters-carousel {
margin-top: 3.5rem;
}
}
@media (prefers-reduced-motion: reduce) {
.track {
animation: none;
flex-wrap: wrap;
justify-content: center;
width: 100%;
}
.chip:hover {
transform: none;
}
}
</style>

View File

@@ -1,14 +1,12 @@
<script setup lang="ts">
import { VPHomeSponsors } from 'vitepress/theme';
import { sponsors } from '../sponsors';
import AdoptersCarousel from './AdoptersCarousel.vue';
</script>
<template>
<div class="content">
<div class="content-container">
<main class="main">
<AdoptersCarousel />
<VPHomeSponsors
v-if="sponsors"
message="Task is free and open source, made possible by wonderful sponsors."

View File

@@ -9,7 +9,6 @@ import {
localIconLoader
} from 'vitepress-plugin-group-icons';
import { team } from './team.ts';
import { adopters } from './adopters.ts';
import { taskDescription, taskName, ogUrl, ogImage } from './meta.ts';
import { fileURLToPath, URL } from 'node:url';
import llmstxt from 'vitepress-plugin-llms';
@@ -108,34 +107,6 @@ export default defineConfig({
head.push(['meta', { name: 'robots', content: 'noindex, nofollow' }])
}
// Structured data for the adopters carousel on the homepage: an ItemList
// of Organization entities so search engines can surface Task's adopters
// directly in rich results.
if (isHome) {
head.push([
'script',
{ type: 'application/ld+json' },
JSON.stringify({
'@context': 'https://schema.org',
'@type': 'ItemList',
name: 'Organizations and projects using Task',
itemListOrder: 'https://schema.org/ItemListUnordered',
numberOfItems: adopters.length,
itemListElement: adopters.map((a, i) => ({
'@type': 'ListItem',
position: i + 1,
item: {
'@type': 'Organization',
name: a.name,
url: a.url,
logo: a.img,
sameAs: [a.url]
}
}))
})
])
}
return head
},
srcDir: 'src',