Skip to content

Commit

Permalink
Merge pull request #60 from madflojo/actions-optimization
Browse files Browse the repository at this point in the history
Optimizing GitHub Actions by splitting tests that require containers
  • Loading branch information
madflojo authored Sep 30, 2023
2 parents feb2b38 + 3474d61 commit 8a3f1d1
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 136 deletions.
93 changes: 86 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,90 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Execute Tests
run: make tests
- name: Update Coveralls
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=coverage/coverage.out -service=github
run: make build tests-nodeps
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

redis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Execute Tests
run: make build tests-redis
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

cassandra:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Execute Tests
run: make build tests-cassandra
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3


boltdb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Build Test WASM Modules
run: make build
- name: Execute Tests
run: make build tests-boltdb
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3


in-memory:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Execute Tests
run: make build tests-inmemory
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3


mysql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Execute Tests
run: make build tests-mysql
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

postgres:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Execute Tests
run: make build tests-postgres
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
45 changes: 37 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,46 @@ build-testdata:
$(MAKE) -C testdata/logger build
$(MAKE) -C testdata/function build

tests: build
tests: build tests-nobuild
tests-nobuild: tests-nodeps tests-redis tests-cassandra tests-mysql tests-postgres tests-boltdb tests-inmemory

tests-nodeps:
@echo "Launching Tests in Docker Compose"
docker-compose -f dev-compose.yml up --exit-code-from tests-nodeps --build tests-nodeps
docker-compose -f dev-compose.yml down

tests-boltdb:
@echo "Launching Tests in Docker Compose"
docker-compose -f dev-compose.yml up --exit-code-from tests-boltdb tests-boltdb
docker-compose -f dev-compose.yml down

tests-inmemory:
@echo "Launching Tests in Docker Compose"
docker-compose -f dev-compose.yml up --exit-code-from tests-inmemory tests-inmemory
docker-compose -f dev-compose.yml down

tests-redis:
@echo "Launching Tests in Docker Compose"
docker-compose -f dev-compose.yml up --exit-code-from tests-redis tests-redis
docker-compose -f dev-compose.yml down

tests-cassandra:
@echo "Launching Tests in Docker Compose"
docker-compose -f dev-compose.yml up -d cassandra-primary cassandra
docker-compose -f dev-compose.yml up --exit-code-from tests-cassandra tests-cassandra
docker-compose -f dev-compose.yml down

tests-mysql:
@echo "Launching Tests in Docker Compose"
docker-compose -f dev-compose.yml up -d cassandra-primary cassandra mysql consul consulator
sleep 120
docker-compose -f dev-compose.yml up --exit-code-from tests --build tests
docker-compose -f dev-compose.yml up -d mysql
docker-compose -f dev-compose.yml up --exit-code-from tests-mysql tests-mysql
docker-compose -f dev-compose.yml down

tests-nobuild:
tests-postgres:
@echo "Launching Tests in Docker Compose"
docker-compose -f dev-compose.yml up -d cassandra-primary cassandra mysql consul consulator
sleep 120
docker-compose -f dev-compose.yml up --exit-code-from tests --build tests
docker-compose -f dev-compose.yml up -d postgres
docker-compose -f dev-compose.yml up --exit-code-from tests-postgres tests-postgres
docker-compose -f dev-compose.yml down

benchmarks:
@echo "Launching Tests in Docker Compose"
Expand Down
126 changes: 124 additions & 2 deletions dev-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,71 @@ services:
- "REDIS_SERVER=redis:6379"
volumes:
- "./testdata:/testdata"
depends_on:
- mysql
- redis
- consul
- consulator
tests-nodeps:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -skip "TestFullService/.*" ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
environment:
- "APP_ENABLE_TLS=false"
- "APP_CONSUL_ADDR=consul:8500"
- "APP_CONSUL_KEYS_PREFIX=tarmac/config"
- "CONSUL_HTTP_ADDR=consul:8500"
- "CONSUL_HTTP_SSL=false"
depends_on:
- redis
- consul
- consulator
tests:
- mysql
tests-inmemory:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/In-Memory.*" ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
environment:
- "APP_ENABLE_TLS=false"
- "APP_CONSUL_ADDR=consul:8500"
- "APP_CONSUL_KEYS_PREFIX=tarmac/config"
- "CONSUL_HTTP_ADDR=consul:8500"
- "CONSUL_HTTP_SSL=false"
depends_on:
- consul
- consulator
tests-boltdb:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/BoltDB.*" ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
environment:
- "APP_ENABLE_TLS=false"
- "APP_CONSUL_ADDR=consul:8500"
- "APP_CONSUL_KEYS_PREFIX=tarmac/config"
- "CONSUL_HTTP_ADDR=consul:8500"
- "CONSUL_HTTP_SSL=false"
depends_on:
- consul
- consulator
tests-redis:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -covermode=count -coverprofile=/tmp/coverage/coverage.out ./...
entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/Redis.*" ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
Expand All @@ -54,11 +111,66 @@ services:
- "CONSUL_HTTP_SSL=false"
depends_on:
- redis
- consul
- consulator
tests-cassandra:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/Cassandra.*" ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
environment:
- "APP_ENABLE_TLS=false"
- "APP_CONSUL_ADDR=consul:8500"
- "APP_CONSUL_KEYS_PREFIX=tarmac/config"
- "CONSUL_HTTP_ADDR=consul:8500"
- "CONSUL_HTTP_SSL=false"
depends_on:
- cassandra-primary
- cassandra
- consul
- consulator
tests-mysql:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/MySQL.*" ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
environment:
- "APP_ENABLE_TLS=false"
- "APP_CONSUL_ADDR=consul:8500"
- "APP_CONSUL_KEYS_PREFIX=tarmac/config"
- "CONSUL_HTTP_ADDR=consul:8500"
- "CONSUL_HTTP_SSL=false"
depends_on:
- mysql
- consul
- consulator
tests-postgres:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/Postgres.*" ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
environment:
- "APP_ENABLE_TLS=false"
- "APP_CONSUL_ADDR=consul:8500"
- "APP_CONSUL_KEYS_PREFIX=tarmac/config"
- "CONSUL_HTTP_ADDR=consul:8500"
- "CONSUL_HTTP_SSL=false"
depends_on:
- postgres
- consul
- consulator
benchmarks:
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
Expand All @@ -81,6 +193,7 @@ services:
- consul
- consulator
- mysql
- postgres
redis:
image: bitnami/redis:latest
environment:
Expand Down Expand Up @@ -118,6 +231,15 @@ services:
MYSQL_DATABASE: example
ports:
- 3306:3306
postgres:
image: bitnami/postgresql:latest
restart: always
environment:
- POSTGRESQL_USERNAME=example
- POSTGRESQL_PASSWORD=example
- POSTGRESQL_DATABASE=example
ports:
- 5432:5432
consul:
image: bitnami/consul:latest
ports:
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/madflojo/tarmac
go 1.18

require (
github.com/glebarez/go-sqlite v1.21.2
github.com/go-sql-driver/mysql v1.7.1
github.com/julienschmidt/httprouter v1.3.0
github.com/lib/pq v1.10.9
Expand All @@ -29,6 +30,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gocql/gocql v1.6.0 // indirect
Expand All @@ -39,6 +41,7 @@ require (
github.com/gomodule/redigo v1.8.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
Expand Down Expand Up @@ -70,6 +73,7 @@ require (
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/sagikazarmark/crypt v0.14.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
Expand Down Expand Up @@ -105,4 +109,8 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/libc v1.22.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.23.1 // indirect
)
Loading

0 comments on commit 8a3f1d1

Please sign in to comment.