Skip to content

Commit

Permalink
Merge pull request #3657 from onflow/supun/update-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 30, 2024
2 parents 262de48 + f642b8e commit 4f9e343
Show file tree
Hide file tree
Showing 289 changed files with 3,845 additions and 8,754 deletions.
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 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.

4 changes: 2 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 Down
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ build: build-tools ./cmd/parse/parse ./cmd/parse/parse.wasm ./cmd/check/check ./
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 ./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
24 changes: 22 additions & 2 deletions ast/inspector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,37 @@ import (

"github.com/onflow/cadence/ast"
"github.com/onflow/cadence/parser"
"github.com/onflow/cadence/tests/examples"
)

// TestInspector_Elements compares Inspector against Inspect.
func TestInspector_Elements(t *testing.T) {

t.Parallel()

const code = `
access(all) contract interface FungibleToken {
access(all) resource interface Provider {
access(all) fun withdraw(amount: Int): @Vault
}
access(all) resource interface Receiver {
access(all) fun deposit(vault: @Vault)
}
access(all) resource interface Vault: Provider, Receiver {
access(all) balance: Int
}
access(all) fun absorb(vault: @Vault)
access(all) fun sprout(balance: Int): @Vault
}
`

program, err := parser.ParseProgram(
nil,
[]byte(examples.FungibleTokenContractInterface),
[]byte(code),
parser.Config{},
)
require.NoError(t, err)
Expand Down
8 changes: 0 additions & 8 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ func DefaultCheckerConfig(
importedLocation common.Location,
_ ast.Range,
) (sema.Import, error) {
if importedLocation == stdlib.CryptoCheckerLocation {
cryptoChecker := stdlib.CryptoChecker()
return sema.ElaborationImport{
Elaboration: cryptoChecker.Elaboration,
}, nil
}

stringLocation, ok := importedLocation.(common.StringLocation)
if !ok {
return nil, &sema.CheckerError{
Expand All @@ -126,7 +119,6 @@ func DefaultCheckerConfig(
Elaboration: importedChecker.Elaboration,
}, nil
},
AttachmentsEnabled: true,
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/info/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/onflow/cadence/parser"
"github.com/onflow/cadence/sema"
"github.com/onflow/cadence/stdlib"
"github.com/onflow/cadence/tests/checker"
"github.com/onflow/cadence/test_utils/sema_utils"
)

type command struct {
Expand Down Expand Up @@ -80,7 +80,7 @@ var commands = map[string]command{

func dumpBuiltinTypes() {

allBaseSemaTypes := checker.AllBaseSemaTypes()
allBaseSemaTypes := sema_utils.AllBaseSemaTypes()

types := make([]sema.Type, 0, len(allBaseSemaTypes))

Expand Down Expand Up @@ -239,7 +239,7 @@ func dumpBuiltinValues() {
ty sema.Type
}

allBaseSemaValueTypes := checker.AllBaseSemaValueTypes()
allBaseSemaValueTypes := sema_utils.AllBaseSemaValueTypes()
standardLibraryValues := stdlib.DefaultScriptStandardLibraryValues(nil)

valueTypes := make([]valueType, 0, len(allBaseSemaValueTypes)+len(standardLibraryValues))
Expand Down
Loading

0 comments on commit 4f9e343

Please sign in to comment.