Skip to content

Commit

Permalink
Merge branch 'master' into bastian/webassembly
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Nov 1, 2024
2 parents c0a9bf1 + a56e521 commit 91b3e19
Show file tree
Hide file tree
Showing 1,136 changed files with 8,262 additions and 52,686 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
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"

- name: Build
run: make -j8 build

- name: Test
run: make ci

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

- name: Upload coverage report
uses: codecov/codecov-action@v2
with:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/compat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Source Compatibility Suite
on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
inputs:

jobs:
source-compat:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
working-directory: compat
run: pip3 install -r requirements.txt
- name: Run
working-directory: compat
run: "python3 main.py"
34 changes: 0 additions & 34 deletions .github/workflows/compat.yaml.disabled

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/compatibility-check-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
run: |
GOPROXY=direct go mod edit -replace github.com/onflow/cadence=github.com/${{ inputs.repo }}@${{ inputs.current-branch }}
go mod tidy
go run ./cmd/check_contracts/main.go ../../tmp/contracts.csv ../../tmp/output-new.txt
go run ./cmd/check_contracts/main.go flow-${{ inputs.chain }} ../../tmp/contracts.csv ../../tmp/output-new.txt
# Check contracts using base branch

Expand All @@ -97,7 +97,7 @@ jobs:
run: |
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
go run ./cmd/check_contracts/main.go flow-${{ inputs.chain }} ../../tmp/contracts.csv ../../tmp/output-old.txt
# Upload checking results for later use

Expand All @@ -108,6 +108,7 @@ jobs:
path: |
./tmp/output-old.txt
./tmp/output-new.txt
./tmp/contracts.csv
# Check Diff

Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/get-contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Get contracts

on:
workflow_call:
inputs:
chain:
required: true
type: string
secrets:
FLOWDIVER_API_KEY:
required: true

env:
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ github.run_id }}-${{ inputs.chain }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Make output dirs
run: |
mkdir tmp
# Get contracts

- name: Download contracts
env:
FLOWDIVER_API_KEY: ${{ secrets.FLOWDIVER_API_KEY }}
working-directory: ./tools/get-contracts
run: |
go run . --chain=${{ inputs.chain }} --apiKey="$FLOWDIVER_API_KEY" > ../../tmp/contracts.csv
# Upload

- name: Upload
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.chain }}-contracts
path: |
./tmp/contracts.csv
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
43 changes: 28 additions & 15 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,22 +30,22 @@ 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
build-tools: build-analysis build-get-contracts build-compatibility-check

.PHONY: build-analysis
build-analysis:
Expand All @@ -55,19 +55,32 @@ build-analysis:
build-get-contracts:
(cd ./tools/get-contracts && go build .)

.PHONY: build-compatibility-check
build-compatibility-check:
(cd ./tools/compatibility-check && go build .)

.PHONY: ci
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 ./interpreter/... -runSmokeTests=true -validateAtree=false
# remove coverage of empty functions from report
sed -i -e 's/^.* 0 0$$//' coverage.txt

.PHONY: test
test:
# test all packages
go test -parallel 8 ./...
test: test-all-packages test-tools

.PHONY: test-all-packages
test-all-packages:
(go test -parallel 8 ./...)

.PHONY: test-tools
test-tools:
(cd ./tools/analysis && go test -parallel 8 ./)
(cd ./tools/compatibility-check && go test -parallel 8 ./)
(cd ./tools/constructorcheck && go test -parallel 8 ./)
(cd ./tools/maprange && go test -parallel 8 ./)

.PHONY: lint-github-actions
lint-github-actions: build-linter
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.
2 changes: 1 addition & 1 deletion 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
File renamed without changes.
4 changes: 2 additions & 2 deletions runtime/ast/composite.go → ast/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

"github.com/turbolent/prettier"

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

// ConformingDeclaration
Expand Down
2 changes: 1 addition & 1 deletion runtime/ast/composite_test.go → ast/composite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/turbolent/prettier"

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

func TestFieldDeclaration_MarshalJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion runtime/ast/conditionkind.go → ast/conditionkind.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package ast
import (
"encoding/json"

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

//go:generate go run golang.org/x/tools/cmd/stringer -type=ConditionKind
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion runtime/ast/declaration.go → ast/declaration.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 Declaration interface {
Expand Down
1 change: 1 addition & 0 deletions runtime/ast/elementtype.go → ast/elementtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ const (
ElementTypeForceExpression
ElementTypePathExpression
ElementTypeAttachExpression
ElementTypeStringTemplateExpression
)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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"
)

// EntitlementDeclaration
Expand Down
File renamed without changes.
Loading

0 comments on commit 91b3e19

Please sign in to comment.