Skip to content

Commit

Permalink
committing to test workflow (#409)
Browse files Browse the repository at this point in the history
* committing to test workflow

* rename image

* edit chain name

* fix image/chain name

* fix uid for permissions and add build flags

* set daemon startup flag to false

* return nil for bridgevalset

* add start args

* go.mod

* simulate flow

* lint

* add to test more layer chain actions

* complete test flow + cleanup

* lint
  • Loading branch information
akremstudy authored Nov 4, 2024
1 parent a048248 commit f8c6d5c
Show file tree
Hide file tree
Showing 24 changed files with 5,857 additions and 268 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: End to End Tests

on:
pull_request:

env:
TAR_PATH: heighliner.tar

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build Docker Image
uses: strangelove-ventures/[email protected]
with:
registry: "" # empty registry, image only shared for e2e testing
tag: local # emulate local environment for consistency in interchaintest cases
tar-export-path: ${{ env.TAR_PATH }} # export a tarball that can be uploaded as an artifact for the e2e jobs
platform: linux/amd64 # test runner architecture only
git-ref: ${{ github.head_ref }} # source code ref

# Heighliner chains.yaml config
chain: layer
dockerfile: cosmos
build-target: make install
binaries: |
- /go/bin/layerd
- name: Publish Tarball as Artifact
uses: actions/upload-artifact@v4
with:
name: layer-docker-image
path: ${{ env.TAR_PATH }}

prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Generate Matrix
id: set-matrix
run: |
# Run the command and convert its output to a JSON array
TESTS=$(cd e2e && go test -list . | grep -v "^ok " | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${TESTS}" >> $GITHUB_OUTPUT
test:
needs:
- build
- prepare
runs-on: ubuntu-latest
strategy:
matrix:
# names of `make` commands to run tests
test: ${{fromJson(needs.prepare.outputs.matrix)}}
fail-fast: false

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Download Tarball Artifact
uses: actions/download-artifact@v4
with:
name: layer-docker-image

- name: Load Docker Image
run: docker image load -i ${{ env.TAR_PATH }}

- name: Run Tests
run: cd e2e && go test -race -v -timeout 10m -run ^${{ matrix.test }}$ .
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: go build -v ./...

- name: Test
run: go test -v ./...
run: go test -short -v ./...
19 changes: 10 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ run:
sort-results: true
allow-parallel-runners: true
exclude-dir: testutil/testdata
skip-files:
- server/grpc/gogoreflection/fix_registration.go
- "fix_registration.go"
- ".*\\.pb\\.go$"
- ".*\\.pb\\.gw\\.go$"
- ".*\\.pulsar\\.go$"
- crypto/keys/secp256k1/internal/*
- types/coin_regex.go


build-tags:
- e2e
Expand All @@ -25,7 +18,7 @@ linters:
- dogsled
- errcheck
- errorlint
- exportloopref
- copyloopvar
- gci
- goconst
- gocritic
Expand All @@ -46,6 +39,14 @@ linters:
- unused

issues:
exclude-files:
- server/grpc/gogoreflection/fix_registration.go
- "fix_registration.go"
- ".*\\.pb\\.go$"
- ".*\\.pb\\.gw\\.go$"
- ".*\\.pulsar\\.go$"
- crypto/keys/secp256k1/internal/*
# - types/coin_regex.go
exclude-rules:
- text: "Use of weak random number generator"
linters:
Expand Down
55 changes: 54 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ GOPATH=$(shell go env GOPATH)
COSMOS_VERSION=$(shell go list -m all | grep "github.com/cosmos/cosmos-sdk" | awk '{print $$NF}')
HTTPS_GIT := https://github.com/tellor-io/layer.git
DOCKER := $(shell which docker)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
ifeq (,$(VERSION))
ifeq ($(shell git status --porcelain),)
VERSION := $(BRANCH)
else
VERSION := $(BRANCH)-dirty
endif
endif
endif

ldflags := $(LDFLAGS)
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=Layer \
-X github.com/cosmos/cosmos-sdk/version.AppName=layerd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -ldflags '$(ldflags)'

###############################################################################
### Building / Install ###
###############################################################################

install: go.sum
@echo "Installing layerd..."
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/layerd
@echo "Completed install!"
.PHONY: install

build: mod
@cd ./cmd/layerd
Expand Down Expand Up @@ -47,7 +79,7 @@ build-with-checksum: build-linux-with-checksum build-darwin-with-checksum
### Linting ###
###############################################################################
# Golangci-lint version
golangci_version=v1.56.2
golangci_version=v1.61.0

#? setup-pre-commit: Set pre-commit git hook
setup-pre-commit:
Expand Down Expand Up @@ -121,6 +153,16 @@ proto-update-deps:

.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps

###############################################################################
### tests ###
###############################################################################
test:
@go test -v ./... -short

e2e:
@cd e2e && go test -v ./... -timeout 20m

.PHONY: test e2e
###############################################################################
### MOCKS ###
###############################################################################
Expand Down Expand Up @@ -189,4 +231,15 @@ mock-gen:
$(MAKE) mock-gen-registry
$(MAKE) mock-gen-reporter

get-heighliner:
git clone https://github.com/strangelove-ventures/heighliner.git
cd heighliner && go install

local-image:
ifeq (,$(shell which heighliner))
echo 'heighliner' binary not found. Consider running `make get-heighliner`
else
heighliner build -c layer --local --dockerfile cosmos --build-target "make install" --binaries "/go/bin/layerd"
endif

.PHONY: mock-gen mock-gen-bridge mock-gen-dispute mock-gen-mint mock-gen-oracle mock-gen-registry mock-gen-reporter mock-gen-daemon
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,41 @@ For more in-depth information, checkout the [Tellor Layer tech paper](https://gi

For docs on how to join our public testnet go here: [https://docs.tellor.io/layer-docs](https://docs.tellor.io/layer-docs)

## Starting a New Chain:
## Starting a New Chain

1) Select the start script that works for you
- `start_one_node.sh` is for those who want to run a chain with a single validator in a mac environment
- `start_one_node_aws.sh` is for those who want a chain with a single validator and the option to import a faucet account from a seed phrase to be used in a linux environment
- `start_two_chains.sh` (mac environment) sets up two nodes/validators and starts one of them from this script. Then to start the other validator you would run the `start_bill.sh` script

- `start_one_node.sh` is for those who want to run a chain with a single validator in a mac environment
- `start_one_node_aws.sh` is for those who want a chain with a single validator and the option to import a faucet account from a seed phrase to be used in a linux environment
- `start_two_chains.sh` (mac environment) sets up two nodes/validators and starts one of them from this script. Then to start the other validator you would run the `start_bill.sh` script

2) Run the selected script from the base layer folder:
`sh ./start_scripts/{selected_script}`

## Joining a Running Chain:
## Joining a Running Chain

To find more information please go to the layer_scripts folder.

Here you will find a detailed breakdown for how to join a chain as a node and how to create a new validator for the chain
Here you will find a detailed breakdown for how to join a chain as a node and how to create a new validator for the chain

## Tests

To run all tests:
`go test -v ./...`
To run integration tests:

`make test`

To run e2e tests:

`make e2e`

## Linting

To lint per folder:

`make lint-folder-fix FOLDER="x/mint"`

To lint all files:

`make lint`

## Maintainers<a name="maintainers"> </a>
Expand Down
Loading

0 comments on commit f8c6d5c

Please sign in to comment.