Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Introduce E2E tests execution GH workflow #14

Merged
merged 9 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: E2E tests
on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
workflow_dispatch:
workflow_call:
outputs:
workflow_output:
description: "E2E output"
value: ${{ jobs.execution.outputs.run_e2e_failure }}

jobs:
execution:
runs-on: ubuntu-latest
env:
CI_VERBOSE: true
outputs:
e2e_output_failure: ${{ steps.run_e2e_failure.outputs.test_output }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run tests
run: make e2e-tests

- name: Run tests failed
if: failure()
id: run_e2e_failure
run: echo "test_output=false" >> $GITHUB_OUTPUT

# TODO: Uncomment when we establish writing to log files in E2E framework
# - name: Archive test logs
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: e2e-logs
# path: e2e-logs-*/
# retention-days: 30
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ lint: ## Runs the linter
.DEFAULT_GOAL := help

.PHONY: help
help: ## Prints this help
help: ## Prints the help
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: e2e-tests
e2e-tests: ## Runs E2E tests
go test -v -timeout=30m github.com/0xPolygon/beethoven/test
11 changes: 0 additions & 11 deletions test/Makefile

This file was deleted.

124 changes: 0 additions & 124 deletions test/docker-compose.yml

This file was deleted.

12 changes: 8 additions & 4 deletions test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package test
import (
"context"
"math/big"
"os/exec"
"testing"
"time"

Expand All @@ -20,15 +19,20 @@ func TestEthTransfer(t *testing.T) {
if testing.Short() {
t.Skip()
}

cluster, err := newTestCluster("")
require.NoError(t, err)

ctx := context.Background()
defer func() {
msg, err := exec.Command("make", "stop").CombinedOutput()
msg, err := cluster.stop()
require.NoError(t, err, string(msg))
}()

log.Info("restarting docker containers for the test")
msg, err := exec.Command("make", "stop").CombinedOutput()
msg, err := cluster.stop()
require.NoError(t, err, string(msg))
msg, err = exec.Command("make", "run").CombinedOutput()
msg, err = cluster.start()
require.NoError(t, err, string(msg))
time.Sleep(5 * time.Second)

Expand Down
39 changes: 39 additions & 0 deletions test/test-cluster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package test

import (
"os"
"os/exec"
"path/filepath"
)

// testCluster represents abstraction that enables Docker containers management
type testCluster struct {
path string
}

// newTestCluster is a constructor function for testCluster instance
func newTestCluster(path string) (*testCluster, error) {
if path == "" {
workDir, err := os.Getwd()
if err != nil {
return nil, err
}
path = filepath.Dir(workDir)
}

if err := os.Chdir(path); err != nil {
return nil, err
}

return &testCluster{path: path}, nil
}

// start starts required Docker containers
func (t *testCluster) start() ([]byte, error) {
return exec.Command("make", "run-docker").CombinedOutput()
}

// stop stop and destroys running Docker containers
func (t *testCluster) stop() ([]byte, error) {
return exec.Command("make", "destroy-docker").CombinedOutput()
}