Skip to content

Commit b51d1d4

Browse files
committed
Fix Windows CI workflow failure by conditionally generating coverage
- Split unit test step into two conditional steps - Generate coverage only on ubuntu-latest (where it's uploaded) - Run tests without coverage on macOS and Windows - Fixes 'no required module provides package .txt' error on Windows - Improves CI efficiency by not generating unused coverage files
1 parent d2fb9ba commit b51d1d4

8 files changed

Lines changed: 23 additions & 35 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ jobs:
3434
- name: Verify dependencies
3535
run: go mod verify
3636

37-
- name: Run unit tests
37+
- name: Run unit tests (with coverage)
38+
if: matrix.os == 'ubuntu-latest'
3839
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic github.com/Notifuse/liquidgo/liquid
3940

41+
- name: Run unit tests (without coverage)
42+
if: matrix.os != 'ubuntu-latest'
43+
run: go test -v -race github.com/Notifuse/liquidgo/liquid
44+
4045
- name: Run tag tests
4146
run: go test -v -race github.com/Notifuse/liquidgo/liquid/tag/... github.com/Notifuse/liquidgo/liquid/tags/...
4247

liquid/tags/if.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,6 @@ func (i *IfTag) parseBodyForBlock(tokenizer *liquid.Tokenizer, condition Conditi
126126

127127
foundEndTag := false
128128
unknownTagHandler := func(endTagName, endTagMarkup string) bool {
129-
// Update blank status (Ruby: @blank &&= body.blank?)
130-
if !attachment.Blank() {
131-
// If attachment is not blank, the if tag is not blank
132-
// We can't directly set Block.blank, so we track it via the Block's body
133-
// For now, we'll handle this in Blank() method
134-
}
135-
136129
if endTagName == i.BlockDelimiter() {
137130
foundEndTag = true
138131
return false // Stop parsing - found endif

liquid/tags/include.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (i *IncludeTag) RenderToOutputBuffer(context liquid.TagContext, output *str
9292
templateNameStr, ok := templateName.(string)
9393
if !ok {
9494
var locale *liquid.I18n
95-
if pc, ok := i.Tag.ParseContext().(*liquid.ParseContext); ok {
95+
if pc, ok := i.ParseContext().(*liquid.ParseContext); ok {
9696
locale = pc.Locale()
9797
}
9898
var msg string
@@ -107,7 +107,7 @@ func (i *IncludeTag) RenderToOutputBuffer(context liquid.TagContext, output *str
107107
}
108108

109109
// Load partial from cache
110-
partial, err := liquid.LoadPartial(templateNameStr, context, i.Tag.ParseContext())
110+
partial, err := liquid.LoadPartial(templateNameStr, context, i.ParseContext())
111111
if err != nil {
112112
errorMsg := context.HandleError(err, nil)
113113
*output += errorMsg

liquid/tags/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (r *RenderTag) RenderToOutputBuffer(context liquid.TagContext, output *stri
121121
}
122122
} else if templateNameStr, ok := template.(string); ok {
123123
// String template name - load from cache
124-
partialInterface, err := liquid.LoadPartial(templateNameStr, context, r.Tag.ParseContext())
124+
partialInterface, err := liquid.LoadPartial(templateNameStr, context, r.ParseContext())
125125
if err != nil {
126126
errorMsg := context.HandleError(err, nil)
127127
*output += errorMsg

liquid/template.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -395,17 +395,11 @@ func (t *Template) buildContext(assigns interface{}, options *RenderOptions) Tag
395395
default:
396396
// Check if it's a drop - if so, we need to make it accessible for variable lookups
397397
// In Ruby Liquid, drops can be passed as context and their methods become available as variables
398-
var outerScope map[string]interface{}
399-
var dropToStore interface{}
400-
401-
if assigns != nil {
402-
dropToStore = assigns
403-
// Wrap the drop in the outer scope so it's accessible
404-
// The drop itself will be the context for variable lookups
405-
outerScope = map[string]interface{}{"__drop__": assigns}
406-
} else {
407-
outerScope = t.instanceAssigns
408-
}
398+
// assigns is not nil here (nil case handled above)
399+
dropToStore := assigns
400+
// Wrap the drop in the outer scope so it's accessible
401+
// The drop itself will be the context for variable lookups
402+
outerScope := map[string]interface{}{"__drop__": assigns}
409403

410404
ctx = BuildContext(ContextConfig{
411405
Environments: []map[string]interface{}{t.assigns},
@@ -438,11 +432,6 @@ func (t *Template) buildContext(assigns interface{}, options *RenderOptions) Tag
438432
}
439433
}
440434

441-
// Set output if provided
442-
if options.Output != nil {
443-
// Output is handled in Render method
444-
}
445-
446435
// Apply other options
447436
if options.Filters != nil {
448437
ctx.AddFilters(options.Filters)

liquid/tokenizer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ func (t *Tokenizer) nextToken() string {
128128

129129
byteB := t.ss.PeekByte()
130130

131-
if byteB == percentage {
131+
switch byteB {
132+
case percentage:
132133
t.ss.ScanByte()
133134
return t.nextTagToken()
134-
} else if byteB == openCurley {
135+
case openCurley:
135136
t.ss.ScanByte()
136137
return t.nextVariableToken()
137138
}

performance/shopify/comment_form.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func NewCommentForm(tagName, markup string, parseContext liquid.ParseContextInte
2121
matches := re.FindStringSubmatch(markup)
2222

2323
if matches == nil {
24-
return nil, fmt.Errorf("Syntax Error in 'comment_form' - Valid syntax: comment_form [article]")
24+
return nil, fmt.Errorf("syntax error in 'comment_form' - valid syntax: comment_form [article]")
2525
}
2626

2727
block := liquid.NewBlock(tagName, markup, parseContext)
@@ -55,7 +55,7 @@ func (c *CommentForm) RenderToOutputBuffer(context liquid.TagContext, output *st
5555
ctx.Set("form", form)
5656

5757
// Render block content
58-
bodyOutput := c.Block.Render(context)
58+
bodyOutput := c.Render(context)
5959

6060
// Wrap in form tag
6161
articleID := "unknown"

performance/shopify/paginate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewPaginate(tagName, markup string, parseContext liquid.ParseContextInterfa
2525
matches := re.FindStringSubmatch(markup)
2626

2727
if matches == nil {
28-
return nil, fmt.Errorf("Syntax Error in tag 'paginate' - Valid syntax: paginate [collection] by number")
28+
return nil, fmt.Errorf("syntax error in tag 'paginate' - valid syntax: paginate [collection] by number")
2929
}
3030

3131
block := liquid.NewBlock(tagName, markup, parseContext)
@@ -82,7 +82,7 @@ func (p *Paginate) RenderToOutputBuffer(context liquid.TagContext, output *strin
8282
collection := ctx.FindVariable(p.collectionName, false)
8383
if collection == nil {
8484
// In non-error mode, just render the block
85-
bodyOutput := p.Block.Render(context)
85+
bodyOutput := p.Render(context)
8686
*output += bodyOutput
8787
return
8888
}
@@ -95,7 +95,7 @@ func (p *Paginate) RenderToOutputBuffer(context liquid.TagContext, output *strin
9595
collectionSize = len(c)
9696
default:
9797
// In non-error mode, just render the block
98-
bodyOutput := p.Block.Render(context)
98+
bodyOutput := p.Render(context)
9999
*output += bodyOutput
100100
return
101101
}
@@ -151,7 +151,7 @@ func (p *Paginate) RenderToOutputBuffer(context liquid.TagContext, output *strin
151151
pagination["parts"] = parts
152152

153153
// Render block content
154-
bodyOutput := p.Block.Render(context)
154+
bodyOutput := p.Render(context)
155155
*output += bodyOutput
156156
}
157157

0 commit comments

Comments
 (0)