Skip to content

Commit

Permalink
gh actions run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed May 1, 2024
1 parent 0884f39 commit e7f9acd
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 2 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: End to End Tests

on:
pull_request:

env:
TAR_PATH: docker-image.tar
ARTIFACT_NAME: tar-docker-image

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

jobs:
build-docker:
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: noble-forwarding-simd
dockerfile: cosmos
build-target: make build
build-dir: simapp
binaries: |
- simapp/build/simd
- name: Publish Tarball as Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.TAR_PATH }}

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

- name: Set up Go 1.22
uses: actions/setup-go@v4
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
e2e-tests:
needs:
- build-docker
- prepare-e2e-tests
runs-on: ubuntu-latest
strategy:
matrix:
# names of `make` commands to run tests
test: ${{fromJson(needs.prepare-e2e-tests.outputs.matrix)}}
fail-fast: false

steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '^1.22'

- name: checkout chain
uses: actions/checkout@v4

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}

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

- name: run test
run: cd e2e && go test -race -v -timeout 30m -run ^${{ matrix.test }}$ .
20 changes: 20 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Unit Tests

on:
pull_request:

jobs:
unit-tests:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ^1.22

- name: Run Unit Tests
run: go test -v ./...

1 change: 1 addition & 0 deletions chains.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- name: noble-forwarding-simd
dockerfile: cosmos
build-target: make build
build-dir: simapp
binaries:
- simapp/build/simd
1 change: 0 additions & 1 deletion e2e/forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func ForwardingSuite(t *testing.T) (ctx context.Context, noble *cosmos.CosmosCha
factory := interchaintest.NewBuiltinChainFactory(logger, []*interchaintest.ChainSpec{
{
Name: "forwarding",
Version: "local",
NumValidators: &numValidators,
NumFullNodes: &numFullNodes,
ChainConfig: ibc.ChainConfig{
Expand Down
2 changes: 1 addition & 1 deletion simapp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ BUILD_FLAGS := -ldflags '$(ldflags)'
build:
@go build -mod=readonly $(BUILD_FLAGS) -o $(PWD)/build/ ./...

.PHONY: build
.PHONY: build

0 comments on commit e7f9acd

Please sign in to comment.