Skip to content

Commit

Permalink
Merge pull request #183 from EventStore/yoeight/update-gha
Browse files Browse the repository at this point in the history
Support different runtime environments out-of-the-box.
  • Loading branch information
YoEight authored Aug 15, 2024
2 parents edd3c4f + 800de42 commit d6170b6
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 32 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docker-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Get ESDB Docker repo
on:
workflow_call:
inputs:
runtime_env:
description: The runtime environment we want to run like release or staging
type: string
default: release

outputs:
docker_repo:
description: ESDB docker repository
value: ${{ jobs.provide_docker.outputs.docker_repo }}

docker_container:
description: ESDB docker container
value: ${{ jobs.provide_docker.outputs.docker_container }}

jobs:
provide_docker:
runs-on: ubuntu-latest
outputs:
docker_repo: ${{ steps.set_docker.outputs.docker_repo }}
docker_container: ${{ steps.set_docker.outputs.docker_container }}
steps:
- name: Set ESDB docker repo
id: set_docker
run: |
case ${{ inputs.runtime_env }} in
"release")
echo "docker_repo=eventstore-ce" >> $GITHUB_OUTPUT
echo "docker_container=eventstoredb-ce" >> $GITHUB_OUTPUT
;;
"staging")
echo "docker_repo=eventstore-staging-ce" >> $GITHUB_OUTPUT
echo "docker_container=eventstoredb-oss" >> $GITHUB_OUTPUT
;;
"enterprise")
echo "docker_repo=eventstore-ee" >> $GITHUB_OUTPUT
echo "docker_container=eventstoredb-commercial" >> $GITHUB_OUTPUT
;;
*)
echo "docker_repo=eventstore-ce" >> $GITHUB_OUTPUT
echo "docker_container=eventstoredb-ce" >> $GITHUB_OUTPUT
;;
esac
10 changes: 5 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ jobs:
name: Build
strategy:
matrix:
os: [ubuntu-latest, windows-2019, macos-11]
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, beta, nightly]
exclude:
- os: windows-2019
- os: windows-latest
rust: beta

- os: windows-2019
- os: windows-latest
rust: nightly

- os: macos-11
- os: macos-latest
rust: beta

- os: macos-11
- os: macos-latest
rust: nightly


Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: "Dispatch"
on:
workflow_dispatch:
inputs:
runtime_env:
description: The runtime environment. release, staging or enterprise
type: string
default: release

version:
description: "Version tag"
required: true
Expand All @@ -14,4 +19,5 @@ jobs:
uses: ./.github/workflows/tests.yml
with:
esdb_version: ${{ inputs.version }}
runtime_env: ${{ inputs.runtime_env }}
secrets: inherit
26 changes: 22 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: tests workflow
on:
workflow_call:
inputs:
runtime_env:
type: string
default: release

esdb_version:
required: true
type: string
Expand All @@ -11,7 +15,13 @@ env:
CARGO_TERM_COLOR: always

jobs:
provide_docker:
uses: ./.github/workflows/docker-repo.yml
with:
runtime_env: ${{ inputs.runtime_env }}

single_node:
needs: provide_docker
name: Single node

strategy:
Expand All @@ -30,7 +40,9 @@ jobs:
run: cargo test --package eventstore --test integration single_node_${{ matrix.test }}
continue-on-error: ${{ matrix.test == 'auto_resub_on_connection_drop' }}
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}
ESDB_DOCKER_REPO: ${{ needs.provide_docker.outputs.docker_repo }}
ESDB_DOCKER_CONTAINER: ${{ needs.provide_docker.outputs.docker_container }}
ESDB_DOCKER_CONTAINER_VERSION: ${{ inputs.esdb_version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1

Expand All @@ -41,6 +53,7 @@ jobs:
path: eventstore/esdb_logs

secure:
needs: provide_docker
name: Secure

strategy:
Expand All @@ -61,7 +74,9 @@ jobs:
- name: Run test
run: cargo test --package eventstore --test integration single_node_${{ matrix.test }}
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}
ESDB_DOCKER_REPO: ${{ needs.provide_docker.outputs.docker_repo }}
ESDB_DOCKER_CONTAINER: ${{ needs.provide_docker.outputs.docker_container }}
ESDB_DOCKER_CONTAINER_VERSION: ${{ inputs.esdb_version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1
SECURE: true
Expand All @@ -73,6 +88,7 @@ jobs:
path: eventstore/esdb_logs

cluster:
needs: provide_docker
name: Cluster

strategy:
Expand All @@ -90,12 +106,14 @@ jobs:
- name: Set up cluster with Docker Compose
run: docker-compose up -d
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}
ESDB_DOCKER_REPO: ${{ needs.provide_docker.outputs.docker_repo }}
ESDB_DOCKER_CONTAINER: ${{ needs.provide_docker.outputs.docker_container }}
ESDB_DOCKER_CONTAINER_VERSION: ${{ inputs.esdb_version }}

- name: Run test
run: cargo test --package eventstore --test integration cluster_${{ matrix.test }}
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}
ESDB_DOCKER_CONTAINER_VERSION: ${{ inputs.esdb_version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1

Expand Down
24 changes: 4 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.5"

services:
volumes-provisioner:
image: hasnat/volumes-provisioner
Expand All @@ -25,8 +23,8 @@ services:
depends_on:
- volumes-provisioner

esdb-node1:
image: docker.eventstore.com/eventstore-ce/eventstoredb-ce:${CONTAINER_IMAGE_VERSION:-latest}
esdb-node1: &template
image: docker.eventstore.com/${ESDB_DOCKER_REPO:-eventstore-ce}/${ESDB_DOCKER_CONTAINER:-eventstoredb-ce}:${ESDB_DOCKER_CONTAINER_VERSION:-latest}
env_file:
- vars.env
environment:
Expand All @@ -47,9 +45,7 @@ services:
- cert-gen

esdb-node2:
image: docker.eventstore.com/eventstore-ce/eventstoredb-ce:${CONTAINER_IMAGE_VERSION:-latest}
env_file:
- vars.env
<<: *template
environment:
- EVENTSTORE_GOSSIP_SEED=172.30.240.11:2113,172.30.240.13:2113
- EVENTSTORE_INT_IP=172.30.240.12
Expand All @@ -61,16 +57,9 @@ services:
networks:
clusternetwork:
ipv4_address: 172.30.240.12
volumes:
- ./certs:/etc/eventstore/certs
restart: unless-stopped
depends_on:
- cert-gen

esdb-node3:
image: docker.eventstore.com/eventstore-ce/eventstoredb-ce:${CONTAINER_IMAGE_VERSION:-latest}
env_file:
- vars.env
<<: *template
environment:
- EVENTSTORE_GOSSIP_SEED=172.30.240.11:2113,172.30.240.12:2113
- EVENTSTORE_INT_IP=172.30.240.13
Expand All @@ -82,11 +71,6 @@ services:
networks:
clusternetwork:
ipv4_address: 172.30.240.13
volumes:
- ./certs:/etc/eventstore/certs
restart: unless-stopped
depends_on:
- cert-gen

networks:
clusternetwork:
Expand Down
14 changes: 11 additions & 3 deletions eventstore/tests/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
use std::collections::HashMap;
use testcontainers::{core::WaitFor, Image};

const CONTAINER_IDENTIFIER: &str = "docker.eventstore.com/eventstore-ce/eventstoredb-ce";
const REGISTRY: &str = "docker.eventstore.com";
const DEFAULT_REPO: &str = "eventstore-ce";
const DEFAULT_CONTAINER: &str = "eventstoredb-ce";
const DEFAULT_TAG: &str = "latest";

#[derive(Debug, Clone)]
pub struct ESDB {
tag: String,
repo: String,
container: String,
env_vars: HashMap<String, String>,
vol_vars: HashMap<String, String>,
}
Expand Down Expand Up @@ -107,7 +111,7 @@ impl Image for ESDB {
type Args = ();

fn name(&self) -> String {
CONTAINER_IDENTIFIER.to_string()
format!("{}/{}/{}", REGISTRY, self.repo, self.container)
}

fn tag(&self) -> String {
Expand All @@ -133,7 +137,9 @@ impl Image for ESDB {

impl Default for ESDB {
fn default() -> Self {
let tag = option_env!("CONTAINER_IMAGE_VERSION").unwrap_or(DEFAULT_TAG);
let tag = option_env!("ESDB_DOCKER_CONTAINER_VERSION").unwrap_or(DEFAULT_TAG);
let repo = option_env!("ESDB_DOCKER_REPO").unwrap_or(DEFAULT_REPO);
let container = option_env!("ESDB_DOCKER_CONTAINER").unwrap_or(DEFAULT_CONTAINER);
let mut env_vars = HashMap::new();

env_vars.insert(
Expand All @@ -143,6 +149,8 @@ impl Default for ESDB {

ESDB {
tag: tag.to_string(),
repo: repo.to_string(),
container: container.to_string(),
env_vars,
vol_vars: HashMap::new(),
}
Expand Down

0 comments on commit d6170b6

Please sign in to comment.