Skip to content

Commit 6ff6aac

Browse files
outSHpetermetz
authored andcommitted
feat(iroha2-ledger): add Iroha V2 test ledger image and setup class
- Add a new test image for Iroha V2 (iroha2-all-in-one). It start a test ledger in single container, and also contains a proxy script for running iroha_client_cli. - Add the new image to the CI. - Add a new class for starting and interacting with Iroha V2 test ledger from typescript test - Iroha2TestLedger. - Add test for test setup class to ensure basic functions are working correctly. Relates to #2138 Signed-off-by: Michal Bajer <[email protected]>
1 parent d5919a7 commit 6ff6aac

File tree

16 files changed

+1067
-0
lines changed

16 files changed

+1067
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: iroha2-all-in-one-publish
2+
3+
on:
4+
push:
5+
# Publish `main` as Docker `latest` image.
6+
branches:
7+
- main
8+
9+
# Publish `v1.2.3` tags as releases.
10+
tags:
11+
- v*
12+
13+
env:
14+
IMAGE_NAME: cactus-iroha2-all-in-one
15+
16+
jobs:
17+
# Push image to GitHub Packages.
18+
# See also https://docs.docker.com/docker-hub/builds/
19+
build-tag-push-container:
20+
runs-on: ubuntu-20.04
21+
env:
22+
DOCKER_BUILDKIT: 1
23+
DOCKERFILE_PATH: ./tools/docker/iroha2-all-in-one/Dockerfile
24+
DOCKER_BUILD_DIR: ./tools/docker/iroha2-all-in-one/
25+
permissions:
26+
packages: write
27+
contents: read
28+
29+
steps:
30+
- uses: actions/[email protected]
31+
32+
- name: Build image
33+
run: docker build $DOCKER_BUILD_DIR --file $DOCKERFILE_PATH --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
34+
35+
- name: Log in to registry
36+
# This is where you will update the PAT to GITHUB_TOKEN
37+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
38+
39+
- name: Push image
40+
run: |
41+
SHORTHASH=$(git rev-parse --short "$GITHUB_SHA")
42+
TODAYS_DATE="$(date +%F)"
43+
DOCKER_TAG="$TODAYS_DATE-$SHORTHASH"
44+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
45+
# Change all uppercase to lowercase
46+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
47+
# Strip git ref prefix from version
48+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
49+
# Strip "v" prefix from tag name
50+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
51+
# Do not use the `latest` tag at all, tag with date + git short hash if there is no git tag
52+
[ "$VERSION" == "main" ] && VERSION=$DOCKER_TAG
53+
echo IMAGE_ID=$IMAGE_ID
54+
echo VERSION=$VERSION
55+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
56+
docker push $IMAGE_ID:$VERSION

packages/cactus-test-tooling/src/main/typescript/common/containers.ts

+19
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,25 @@ export class Containers {
653653
}
654654
});
655655
}
656+
657+
/**
658+
* Get all environment variables defined in container provided in argument.
659+
*
660+
* @param container Running dockerode container instance
661+
* @returns Map between environment variable name and it's value.
662+
*/
663+
public static async getEnvVars(
664+
container: Container,
665+
): Promise<Map<string, string>> {
666+
Checks.truthy(container);
667+
668+
const inspectInfo = await container.inspect();
669+
return new Map(
670+
inspectInfo.Config.Env.map(
671+
(entry) => entry.split("=") as [string, string],
672+
),
673+
);
674+
}
656675
}
657676

658677
export interface IStreamLogsRequest {

0 commit comments

Comments
 (0)