Skip to content

Commit

Permalink
Merge pull request #22 from onflow/init-go-package
Browse files Browse the repository at this point in the history
Initialize go assets
  • Loading branch information
sisyphusSmiling authored Feb 13, 2024
2 parents 3f0a82a + 62c9c6d commit f4cd4ad
Show file tree
Hide file tree
Showing 24 changed files with 1,851 additions and 23 deletions.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Requesting a Feature or Improvement
about: "For feature requests. Please search for existing issues first. Also see CONTRIBUTING."
title: ''
labels: Feedback, Feature, SC-Eng
assignees: ''

---

## Instructions

Please fill out the template below to the best of your ability and include a label indicating which tool/service you were working with when you encountered the problem.

### Issue To Be Solved
(Replace This Text: Please present a concise description of the problem to be addressed by this feature request. Please be clear what parts of the problem are considered to be in-scope and out-of-scope.)

### (Optional): Suggest A Solution
(Replace This Text: A concise description of your preferred solution. Things to address include:
* Details of the technical implementation
* Tradeoffs made in design decisions
* Caveats and considerations for the future

If there are multiple solutions, please present each one separately. Save comparisons for the very end.)

### (Optional): Context

<what are you currently working on that this is blocking?>
18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Closes: #???

## Description

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review.
-->

______

For contributor use:

- [ ] Targeted PR against `main` branch
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [standards mentioned here](https://github.com/onflow/contract-updater/blob/master/CONTRIBUTING.md#styleguides).
- [ ] Updated relevant documentation
- [ ] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Added appropriate labels
40 changes: 25 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,29 @@ jobs:
name: Flow CLI Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.8.0
- name: Run tests
run: make ci
- name: Normalize coverage report filepaths
run : sh ./normalize_coverage_report.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20.x'
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.13.1
- name: Flow CLI Version
run: flow version
- name: Update PATH
run: echo "/root/.local/bin" >> $GITHUB_PATH
- name: Run tests
run: make ci
- name: Normalize coverage report filepaths
run : sh ./local/normalize_coverage_report.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.PHONY: test
test:
$(MAKE) generate -C lib/go
$(MAKE) test -C lib/go
flow test --cover --covercode="contracts" --coverprofile="coverage.lcov" tests/*.cdc

.PHONY: ci
ci: test
ci:
$(MAKE) ci -C lib/go
$(MAKE) test
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Coordinated Upgrade.
> :information_source: The `MigrationContractStaging` contract is not yet deployed. Its deployment address will be added
> here once it has been deployed.
| Network | Address |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Crescendo Migration Testnet | [0x27b2302520211b67](https://crescendo.flowdiver.io/contract/A.27b2302520211b67.MigrationContractStaging?tab=deployments) |
| Testnet | [0x2ceae959ed1a7e7a](https://contractbrowser.com/A.2ceae959ed1a7e7a.MigrationContractStaging) |
| Mainnet | TBD |
| Network | Address |
| --------- | ------------------------------------------------------------------------------------------------------------------------- |
| Crescendo | [0x27b2302520211b67](https://crescendo.flowdiver.io/contract/A.27b2302520211b67.MigrationContractStaging?tab=deployments) |
| Testnet | [0x2ceae959ed1a7e7a](https://contractbrowser.com/A.2ceae959ed1a7e7a.MigrationContractStaging) |
| Mainnet | TBD |

### Pre-Requisites

Expand Down
4 changes: 2 additions & 2 deletions contracts/staged-contract-updates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ advanced deployments are possible with support for multiple contract accounts an
1. Setup emulator environment - this creates our emulator accounts & deploys contracts:

```sh
sh staged_contract_updates_setup.sh
sh local/staged_contract_updates_setup.sh
```

### Walkthrough
Expand All @@ -52,7 +52,7 @@ advanced deployments are possible with support for multiple contract accounts an
1. Simulate block creation, running transactions to iterate over blocks to the pre-configured block update height:

```sh
sh tick_tock.sh
sh local/tick_tock.sh
```

1. We can get details from our `Updater` before updating:
Expand Down
2 changes: 2 additions & 0 deletions flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"MigrationContractStaging": {
"source": "./contracts/MigrationContractStaging.cdc",
"aliases": {
"crescendo": "27b2302520211b67",
"emulator": "f8d6e0586b0a20c7",
"testnet": "2ceae959ed1a7e7a",
"testing": "0000000000000007"
}
},
Expand Down
13 changes: 13 additions & 0 deletions lib/go/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: test
test:
$(MAKE) test -C templates

.PHONY: generate
generate:
$(MAKE) generate -C contracts
$(MAKE) generate -C templates

.PHONY: ci
ci:
$(MAKE) ci -C contracts
$(MAKE) ci -C templates
11 changes: 11 additions & 0 deletions lib/go/contracts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: generate
generate:
go generate

.PHONY: check-tidy
check-tidy: generate
go mod tidy
git diff --exit-code

.PHONY: ci
ci: check-tidy
18 changes: 18 additions & 0 deletions lib/go/contracts/contracts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package contracts

//go:generate go run github.com/kevinburke/go-bindata/go-bindata -prefix ../../../contracts -o internal/assets/assets.go -pkg assets -nometadata -nomemcopy ../../../contracts

import (
_ "github.com/kevinburke/go-bindata"

"github.com/onflow/contract-updater/lib/go/contracts/internal/assets"
)

const (
filenameMigrationContractStaging = "MigrationContractStaging.cdc"
)

func MigrationContractStaging() []byte {
code := assets.MustAssetString(filenameMigrationContractStaging)
return []byte(code)
}
5 changes: 5 additions & 0 deletions lib/go/contracts/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/onflow/contract-updater/lib/go/contracts

go 1.20

require github.com/kevinburke/go-bindata v3.24.0+incompatible
2 changes: 2 additions & 0 deletions lib/go/contracts/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/kevinburke/go-bindata v3.24.0+incompatible h1:qajFA3D0pH94OTLU4zcCCKCDgR+Zr2cZK/RPJHDdFoY=
github.com/kevinburke/go-bindata v3.24.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
276 changes: 276 additions & 0 deletions lib/go/contracts/internal/assets/assets.go

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions lib/go/templates/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: test
test:
go test ./...

.PHONY: generate
generate:
go generate

.PHONY: check-tidy
check-tidy: generate
go mod tidy
git diff --exit-code

.PHONY: ci
ci: check-tidy
51 changes: 51 additions & 0 deletions lib/go/templates/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module github.com/onflow/contract-updater/lib/go/templates

go 1.20

require (
github.com/kevinburke/go-bindata v3.23.0+incompatible
github.com/onflow/flow-go-sdk v1.0.0-M1
github.com/stretchr/testify v1.8.4
)

require (
github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/ethereum/go-ethereum v1.13.5 // indirect
github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect
github.com/fxamacker/circlehash v0.3.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/k0kubun/pp v3.0.1+incompatible // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/logrusorgru/aurora/v4 v4.0.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f // indirect
github.com/onflow/cadence v1.0.0-M3 // indirect
github.com/onflow/crypto v0.25.0 // indirect
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c // indirect
github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/blake3 v0.2.3 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gonum.org/v1/gonum v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit f4cd4ad

Please sign in to comment.