diff --git a/.github/workflows/docker-repo.yml b/.github/workflows/docker-repo.yml new file mode 100644 index 0000000..8300d40 --- /dev/null +++ b/.github/workflows/docker-repo.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ece8827..9f88bca 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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 diff --git a/.github/workflows/test-dispatch.yml b/.github/workflows/test-dispatch.yml index 071980d..ab1403a 100644 --- a/.github/workflows/test-dispatch.yml +++ b/.github/workflows/test-dispatch.yml @@ -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 @@ -14,4 +19,5 @@ jobs: uses: ./.github/workflows/tests.yml with: esdb_version: ${{ inputs.version }} + runtime_env: ${{ inputs.runtime_env }} secrets: inherit \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e4e2d23..938c50f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,6 +3,10 @@ name: tests workflow on: workflow_call: inputs: + runtime_env: + type: string + default: release + esdb_version: required: true type: string @@ -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: @@ -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 @@ -41,6 +53,7 @@ jobs: path: eventstore/esdb_logs secure: + needs: provide_docker name: Secure strategy: @@ -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 @@ -73,6 +88,7 @@ jobs: path: eventstore/esdb_logs cluster: + needs: provide_docker name: Cluster strategy: @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 16da5dd..1484653 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.5" - services: volumes-provisioner: image: hasnat/volumes-provisioner @@ -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: @@ -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 @@ -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 @@ -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: diff --git a/eventstore/tests/images.rs b/eventstore/tests/images.rs index 0101403..41f8f02 100644 --- a/eventstore/tests/images.rs +++ b/eventstore/tests/images.rs @@ -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, vol_vars: HashMap, } @@ -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 { @@ -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( @@ -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(), }