Skip to content

Commit

Permalink
Merge pull request #3626 from onflow/supun/string-templates
Browse files Browse the repository at this point in the history
Sync `feature/string-templates` branch with `master`
  • Loading branch information
SupunS authored Oct 18, 2024
2 parents 3208a5d + 1772f43 commit a185a42
Show file tree
Hide file tree
Showing 1,086 changed files with 30,115 additions and 67,360 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ jobs:

- name: Run benchmark on current branch
run: |
( for i in {1..${{ steps.settings.outputs.benchmark_repetitions }}}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done | sed 's/pkg:.*/pkg: github.com\/onflow\/cadence\/runtime/' ) | tee new.txt
( for i in {1..${{ steps.settings.outputs.benchmark_repetitions }}}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done | sed 's/pkg:.*/pkg: github.com\/onflow\/cadence\/' ) | tee new.txt
# the package replace line above is to make the results table more readable, since it is not fragmented by package

- name: Checkout base branch
run: git checkout ${{ github.event.pull_request.base.sha }}

- name: Run benchmark on base branch
run: |
( for i in {1..${{ steps.settings.outputs.benchmark_repetitions }}}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done | sed 's/pkg:.*/pkg: github.com\/onflow\/cadence\/runtime/' ) | tee old.txt
( for i in {1..${{ steps.settings.outputs.benchmark_repetitions }}}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done | sed 's/pkg:.*/pkg: github.com\/onflow\/cadence\/' ) | tee old.txt
# see https://trstringer.com/github-actions-multiline-strings/ to see why this part is complex
- name: Use benchstat for comparison
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: make ci

- name: Cadence Testing Framework
run: cd runtime/stdlib/contracts && flow test --cover --covercode="contracts" crypto_test.cdc
run: cd stdlib/contracts && flow test --cover --covercode="contracts" crypto_test.cdc

- name: Upload coverage report
uses: codecov/codecov-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compatibility-check-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Check contracts using ${{ inputs.base-branch }}
working-directory: ./tools/compatibility-check
run: |
GOPROXY=direct go mod edit -replace github.com/onflow/cadence=github.com/${{ inputs.repo }}@${{ inputs.base-branch }}
GOPROXY=direct go mod edit -replace github.com/onflow/cadence=github.com/${{ inputs.repo }}@`git rev-parse origin/${{ inputs.base-branch }}`
go mod tidy
go run ./cmd/check_contracts/main.go ../../tmp/contracts.csv ../../tmp/output-old.txt
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ suppressions

coverage.txt
coverage.txt-e
runtime/cmd/check/check
runtime/cmd/main/main
runtime/cmd/parse/parse
runtime/cmd/parse/parse.wasm
cmd/check/check
cmd/main/main
cmd/parse/parse
cmd/parse/parse.wasm
tools/golangci-lint/golangci-lint
tools/maprange/maprange
tools/unkeyed/unkeyed
Expand Down
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GOPATH ?= $(HOME)/go
# Ensure go bin path is in path (Especially for CI)
PATH := $(PATH):$(GOPATH)/bin

COVERPKGS := $(shell go list ./... | grep -v /cmd | grep -v /runtime/test | tr "\n" "," | sed 's/,*$$//')
COVERPKGS := $(shell go list ./... | grep -v /cmd | grep -v /test | tr "\n" "," | sed 's/,*$$//')


LINTERS :=
Expand All @@ -30,19 +30,19 @@ ifneq ($(linters),)
endif

.PHONY: build
build: build-tools ./runtime/cmd/parse/parse ./runtime/cmd/parse/parse.wasm ./runtime/cmd/check/check ./runtime/cmd/main/main
build: build-tools ./cmd/parse/parse ./cmd/parse/parse.wasm ./cmd/check/check ./cmd/main/main

./runtime/cmd/parse/parse:
go build -o $@ ./runtime/cmd/parse
./cmd/parse/parse:
go build -o $@ ./cmd/parse

./runtime/cmd/parse/parse.wasm:
GOARCH=wasm GOOS=js go build -o $@ ./runtime/cmd/parse
./cmd/parse/parse.wasm:
GOARCH=wasm GOOS=js go build -o $@ ./cmd/parse

./runtime/cmd/check/check:
go build -o $@ ./runtime/cmd/check
./cmd/check/check:
go build -o $@ ./cmd/check

./runtime/cmd/main/main:
go build -o $@ ./runtime/cmd/main
./cmd/main/main:
go build -o $@ ./cmd/main

.PHONY: build-tools
build-tools: build-analysis build-get-contracts
Expand All @@ -60,7 +60,7 @@ ci:
# test all packages
go test -coverprofile=coverage.txt -covermode=atomic -parallel 8 -race -coverpkg $(COVERPKGS) ./...
# run interpreter smoke tests. results from run above are reused, so no tests runs are duplicated
go test -count=5 ./runtime/tests/interpreter/... -runSmokeTests=true -validateAtree=false
go test -count=5 ./tests/interpreter/... -runSmokeTests=true -validateAtree=false
# remove coverage of empty functions from report
sed -i -e 's/^.* 0 0$$//' coverage.txt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package activations

import (
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
)

// Activation is a map of strings to values.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions runtime/ast/access.go → ast/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"encoding/json"
"strings"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/errors"
"github.com/onflow/cadence/common"
"github.com/onflow/cadence/errors"
)

//go:generate go run golang.org/x/tools/cmd/stringer -type=PrimitiveAccess
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion runtime/ast/argument.go → ast/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/turbolent/prettier"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
)

type Argument struct {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion runtime/ast/attachment.go → ast/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/turbolent/prettier"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
)

// AttachmentDeclaration
Expand Down
File renamed without changes.
13 changes: 8 additions & 5 deletions runtime/ast/block.go → ast/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/turbolent/prettier"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
)

type Block struct {
Expand Down Expand Up @@ -355,10 +355,13 @@ func (c *EmitCondition) Walk(walkChild func(Element)) {

// Conditions

type Conditions []Condition
type Conditions struct {
Conditions []Condition
Range
}

func (c *Conditions) IsEmpty() bool {
return c == nil || len(*c) == 0
return c == nil || len(c.Conditions) == 0
}

func (c *Conditions) Doc(keywordDoc prettier.Doc) prettier.Doc {
Expand All @@ -368,7 +371,7 @@ func (c *Conditions) Doc(keywordDoc prettier.Doc) prettier.Doc {

var doc prettier.Concat

for _, condition := range *c {
for _, condition := range c.Conditions {
doc = append(
doc,
prettier.HardLine{},
Expand All @@ -395,7 +398,7 @@ func (c *Conditions) Walk(walkChild func(Element)) {
return
}

for _, condition := range *c {
for _, condition := range c.Conditions {
walkChild(condition)
}
}
Loading

0 comments on commit a185a42

Please sign in to comment.