diff --git a/.dockerignore b/.dockerignore index d16386367..64952591a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,4 @@ -build/ \ No newline at end of file +build/ +.github/ +interchaintest/ +*.md \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 183f707d9..ea79b0be6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + GO_VERSION: 1.20.7 + jobs: build: runs-on: ubuntu-latest @@ -18,9 +21,9 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.20.0 + go-version: ${{ env.GO_VERSION }} - run: go build ./... test: @@ -28,9 +31,9 @@ jobs: name: test steps: - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.20.0 + go-version: ${{ env.GO_VERSION }} - name: Checkout code uses: actions/checkout@v3 - name: Test @@ -42,9 +45,9 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.20.0 + go-version: ${{ env.GO_VERSION }} - run: | go mod tidy CHANGES_IN_REPO=$(git status --porcelain) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9cfb1ea78..9b1a3a8cd 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -17,6 +17,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + GO_VERSION: 1.20.7 + jobs: analyze: name: Analyze @@ -29,9 +32,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: - go-version: 1.20.0 + go-version: ${{ env.GO_VERSION }} # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b98d8c4e6..6662d1d2f 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,14 +16,17 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + GO_VERSION: 1.20.7 + jobs: golangci: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: - go-version: 1.20.0 + go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v3 - name: golangci-lint-junod diff --git a/.github/workflows/interchaintest-E2E.yml b/.github/workflows/interchaintest-E2E.yml index 5de0d010d..5d7b642ff 100644 --- a/.github/workflows/interchaintest-E2E.yml +++ b/.github/workflows/interchaintest-E2E.yml @@ -4,159 +4,93 @@ on: pull_request: push: tags: - - '**' + - "**" branches: - - 'main' - - 'master' + - "main" + - "master" permissions: contents: read packages: write env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }}-e2e - GO_VERSION: 1.19 + GO_VERSION: 1.20.7 + TAR_PATH: /tmp/juno-docker-image.tar + IMAGE_NAME: juno-docker-image concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - build-and-push-image: + build-docker: runs-on: ubuntu-latest - outputs: - branchTag: ${{ steps.meta.outputs.version }} - permissions: - contents: read - packages: write - steps: - - name: Checkout repository + - name: Checkout uses: actions/checkout@v3 - # We setup go & cache dependencies here. This way each child job - # does not have to reinstall all dependencies individually. - # Should ID be unique to this job only? - - name: Setup Golang with cache - uses: magnetikonline/action-golang-cache@v4 + - name: Setup Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} - id: go - - - name: Download dependencies - run: | - go mod download - cd interchaintest && go mod download - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + cache-dependency-path: interchaintest/go.sum - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push Docker image - id: push + - name: Build and export uses: docker/build-push-action@v4 with: context: . - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - # make juno:branchname here for all needs.build-and-push-image.outputs.branchTag - # then upload to github. Then download for each as a cache. This way its only built once - - test-juno-basic: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-basic - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} - - test-juno-ibc: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-ibc - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + tags: juno:local + outputs: type=docker,dest=${{ env.TAR_PATH }} - test-juno-upgrade: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-upgrade - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} - - test-juno-tokenfactory: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-tokenfactory - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} - - test-juno-feeshare: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-feeshare - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.IMAGE_NAME }} + path: ${{ env.TAR_PATH }} - test-juno-ibchooks: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-ibchooks - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + e2e-tests: + needs: build-docker + runs-on: ubuntu-latest + strategy: + matrix: + # names of `make` commands to run tests + test: + - "ictest-basic" + - "ictest-ibchooks" + - "ictest-tokenfactory" + - "ictest-feeshare" + - "ictest-pfm" + - "ictest-upgrade" + - "ictest-ibc" + - "ictest-unity-deploy" + - "ictest-unity-gov" + - "ictest-pob" + - "ictest-drip" + fail-fast: false - # === UNITY CONTRACT === - test-juno-unity-deploy: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-unity-deploy - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + steps: + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + cache-dependency-path: interchaintest/go.sum - test-juno-unity-gov: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-unity-gov - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + - name: checkout chain + uses: actions/checkout@v3 - test-juno-pfm: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-pfm - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + - name: Download Tarball Artifact + uses: actions/download-artifact@v3 + with: + name: ${{ env.IMAGE_NAME }} + path: /tmp - test-pob: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-pob - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + - name: Load Docker Image + run: | + docker image load -i ${{ env.TAR_PATH }} + docker image ls -a - test-drip: - needs: build-and-push-image - uses: ./.github/workflows/make-cmd-runner.yml - with: - make-command: ictest-drip - branch-tag: ${{needs.build-and-push-image.outputs.branchTag}} + - name: Run Test + run: make ${{ matrix.test }} diff --git a/.github/workflows/make-cmd-runner.yml b/.github/workflows/make-cmd-runner.yml deleted file mode 100644 index 66f999b7d..000000000 --- a/.github/workflows/make-cmd-runner.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Make runner - -on: - workflow_call: - inputs: - make-command: - type: string - required: true - description: 'The make command to run' - branch-tag: - type: string - required: true - description: 'The branch tag of the docker image' - - -jobs: - run_make: - runs-on: ubuntu-latest - steps: - - name: checkout chain - uses: actions/checkout@v2 - - - name: Setup Golang with cache - uses: magnetikonline/action-golang-cache@v4 - with: - go-version: 1.19 - id: go - - - run: make ${{ inputs.make-command }} - env: - BRANCH_CI: ${{ inputs.branch-tag }} \ No newline at end of file diff --git a/contrib/devtools/Dockerfile b/contrib/devtools/Dockerfile index 53592ff6a..a2d91ad31 100644 --- a/contrib/devtools/Dockerfile +++ b/contrib/devtools/Dockerfile @@ -3,7 +3,7 @@ # docker run --rm -v $(pwd):/workspace --workdir /workspace cosmossdk-proto sh ./scripts/protocgen.sh FROM bufbuild/buf:1.9.0 as BUILDER -FROM golang:1.19-alpine +FROM golang:1.20-alpine RUN apk add --no-cache \ nodejs \ diff --git a/interchaintest/chain_upgrade_test.go b/interchaintest/chain_upgrade_test.go index 663ca8ea6..e96a58cc3 100644 --- a/interchaintest/chain_upgrade_test.go +++ b/interchaintest/chain_upgrade_test.go @@ -18,28 +18,38 @@ import ( ) const ( + chainName = "juno" + upgradeName = "v17" + haltHeightDelta = uint64(9) // will propose upgrade this many blocks in the future blocksAfterUpgrade = uint64(7) ) +var ( + // baseChain is the current version of the chain that will be upgraded from + baseChain = ibc.DockerImage{ + Repository: JunoMainRepo, + Version: "v16.0.0", + UidGid: "1025:1025", + } +) + func TestBasicJunoUpgrade(t *testing.T) { repo, version := GetDockerImageInfo() - startVersion := "v16.0.0" - upgradeName := "v17" - CosmosChainUpgradeTest(t, "juno", startVersion, version, repo, upgradeName) + CosmosChainUpgradeTest(t, chainName, version, repo, upgradeName) } -func CosmosChainUpgradeTest(t *testing.T, chainName, initialVersion, upgradeBranchVersion, upgradeRepo, upgradeName string) { +func CosmosChainUpgradeTest(t *testing.T, chainName, upgradeBranchVersion, upgradeRepo, upgradeName string) { if testing.Short() { t.Skip("skipping in short mode") } t.Parallel() - t.Log(chainName, initialVersion, upgradeBranchVersion, upgradeRepo, upgradeName) + t.Log(chainName, upgradeBranchVersion, upgradeRepo, upgradeName) numVals, numNodes := 4, 4 - chains := CreateThisBranchChain(t, numVals, numNodes) + chains := CreateChain(t, numVals, numNodes, baseChain) chain := chains[0].(*cosmos.CosmosChain) ic, ctx, client, _ := BuildInitialChain(t, chains) @@ -62,7 +72,6 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, initialVersion, upgradeBran ValidatorVoting(t, ctx, chain, proposalID, height, haltHeight) UpgradeNodes(t, ctx, chain, client, haltHeight, upgradeRepo, upgradeBranchVersion) - } func UpgradeNodes(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, client *client.Client, haltHeight uint64, upgradeRepo, upgradeBranchVersion string) { diff --git a/interchaintest/go.mod b/interchaintest/go.mod index 7af0faed5..a3820e9be 100644 --- a/interchaintest/go.mod +++ b/interchaintest/go.mod @@ -1,6 +1,6 @@ module github.com/CosmosContracts/juno/tests/interchaintest -go 1.19 +go 1.20 replace ( // interchaintest supports ICS features so we need this for now diff --git a/interchaintest/module_drip_test.go b/interchaintest/module_drip_test.go index 64bbf0dcb..3d468446a 100644 --- a/interchaintest/module_drip_test.go +++ b/interchaintest/module_drip_test.go @@ -27,7 +27,7 @@ func TestJunoDrip(t *testing.T) { }, }...)) - chains := CreateThisBranchChainWithCustomConfig(t, 1, 0, newCfg) + chains := CreateChainWithCustomConfig(t, 1, 0, newCfg) ic, ctx, _, _ := BuildInitialChain(t, chains) // Chains diff --git a/interchaintest/setup.go b/interchaintest/setup.go index 1082b2a4e..b2ec1f018 100644 --- a/interchaintest/setup.go +++ b/interchaintest/setup.go @@ -97,21 +97,24 @@ func junoEncoding() *testutil.TestEncodingConfig { return &cfg } -// This allows for us to test -func FundSpecificUsers() { +// CreateChain generates a new chain with a custom image (useful for upgrades) +func CreateChain(t *testing.T, numVals, numFull int, img ibc.DockerImage) []ibc.Chain { + cfg := junoConfig + cfg.Images = []ibc.DockerImage{img} + return CreateChainWithCustomConfig(t, numVals, numFull, cfg) } -// Base chain, no relaying off this branch (or juno:local if no branch is provided.) +// CreateThisBranchChain generates this branch's chain (ex: from the commit) func CreateThisBranchChain(t *testing.T, numVals, numFull int) []ibc.Chain { - return CreateThisBranchChainWithCustomConfig(t, numVals, numFull, junoConfig) + return CreateChain(t, numVals, numFull, JunoImage) } -func CreateThisBranchChainWithCustomConfig(t *testing.T, numVals, numFull int, config ibc.ChainConfig) []ibc.Chain { +func CreateChainWithCustomConfig(t *testing.T, numVals, numFull int, config ibc.ChainConfig) []ibc.Chain { cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ { Name: "juno", ChainName: "juno", - Version: junoVersion, + Version: config.Images[0].Version, ChainConfig: config, NumValidators: &numVals, NumFullNodes: &numFull, diff --git a/proto/Dockerfile b/proto/Dockerfile index d5a673c53..f5eb9c7fb 100644 --- a/proto/Dockerfile +++ b/proto/Dockerfile @@ -3,7 +3,7 @@ FROM bufbuild/buf:1.7.0 as BUILDER -FROM golang:1.19-alpine +FROM golang:1.20-alpine RUN apk add --no-cache \