ci: add build and test job for arm64 oss cli migrations

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3128
GitOrigin-RevId: a8ab8fc8e022166e27fcc68199311b1626930759
This commit is contained in:
Vishnu Bharathi 2021-12-14 20:20:25 +05:30 committed by hasura-bot
parent 4121c1dd3d
commit 9b7495c4ae
9 changed files with 36 additions and 78 deletions

View File

@ -8,30 +8,6 @@ CLI_BUILD_OUTPUT := $(BUILD_DIR)/_cli_output
SHELL := /bin/bash
.SHELLFLAGS := -ce
.PHONY: build-cli-migrations-v2
.ONESHELL:
build-cli-migrations-v2:
cd v2
./build.sh $(SERVER_BUILD_OUTPUT) $(CLI_BUILD_OUTPUT) $(BUILD_OUTPUT)
.PHONY: test-cli-migrations-v2
.ONESHELL:
test-cli-migrations-v2:
cd v2/test
./test.sh
.PHONY: build-cli-migrations-v3
.ONESHELL:
build-cli-migrations-v3:
cd v3
./build.sh $(SERVER_BUILD_OUTPUT) $(CLI_BUILD_OUTPUT) $(BUILD_OUTPUT)
.PHONY: test-cli-migrations-v3
.ONESHELL:
test-cli-migrations-v3:
cd v3/test
./test.sh
.ONESHELL:
prepare-local-env:
# works on *nix systems
@ -48,6 +24,3 @@ prepare-local-env:
cd $$MAKEFILE_DIR && sed -i 's/BUILD_DIR ?= \/build/BUILD_DIR ?= \/tmp\/build/' Makefile
reset-local-env:
sed -i 's/BUILD_DIR ?= \/tmp\/build/BUILD_DIR ?= \/build/' Makefile
.PHONY: all
all: build-cli-migrations-v2 test-cli-migrations-v2 build-cli-migrations-v3 test-cli-migrations-v3

View File

@ -9,9 +9,9 @@ RUN apt-get update && apt-get install -y netcat
ENV HASURA_GRAPHQL_SHOW_UPDATE_NOTIFICATION=false
COPY docker-entrypoint.sh /bin/
COPY cli-hasura-linux-amd64 /bin/hasura-cli
COPY hasura-cli /bin/hasura-cli
RUN chmod +x /bin/hasura-cli
RUN chmod +x /bin/hasura-cli
# set an env var to let the cli know that
# it is running in server environment

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
set -evo pipefail
SERVER_BUILD_OUTPUT="$1"
CLI_BUILD_OUTPUT="$2"
BUILD_OUTPUT="$3"
CLI_MIGRATIONS_IMAGE="cli-migrations-v2"
SERVER_IMAGE=$(docker load -i "${SERVER_BUILD_OUTPUT}/image.tar" | grep "^Loaded image: " | sed "s/Loaded image: //g")
SERVER_IMAGE_TAG=$(echo "$SERVER_IMAGE" | sed "s/.*:\(.*\)$/\1/")
echo "SERVER_IMAGE is ${SERVER_IMAGE}"
echo "SERVER_IMAGE_TAG is ${SERVER_IMAGE_TAG}"
BINARY=${CLI_BUILD_OUTPUT}/binaries/cli-hasura-linux-amd64
cp ${BINARY} .
docker build -t "${CLI_MIGRATIONS_IMAGE}" . --build-arg SERVER_IMAGE_TAG=$SERVER_IMAGE_TAG
docker save -o "${BUILD_OUTPUT}/v2.tar" "${CLI_MIGRATIONS_IMAGE}"

View File

@ -7,7 +7,8 @@ services:
POSTGRES_PASSWORD: postgrespassword
graphql-engine:
container_name: graphql-engine
image: cli-migrations-v2
image: ${TEST_IMAGE_NAME}
platform: ${TEST_PLATFORM}
ports:
- "8080:8080"
depends_on:

View File

@ -4,11 +4,24 @@ set -evo pipefail
IFS=$'\n\t'
ROOT="$(readlink -f ${BASH_SOURCE[0]%/*}/../../)"
echo "TEST_IMAGE_NAME = $TEST_IMAGE_NAME"
echo "TEST_PLATFORM = $TEST_PLATFORM"
if [[ -z "$TEST_IMAGE_NAME" ]]; then
echo "please set TEST_IMAGE_NAME env to be a non-empty value and retry."
exit 1
fi
if [[ -z "$TEST_PLATFORM" ]]; then
echo "please set TEST_PLATFORM env to be a non-empty value and retry."
exit 1
fi
wait_for_server() {
echo "waiting for server"
for _ in $(seq 1 60);
do
docker run --network container:graphql-engine appropriate/curl http://127.0.0.1:8080/v1/version && return
docker run --rm --network container:graphql-engine curlimages/curl http://127.0.0.1:8080/v1/version && return
echo -n .
sleep 1
done
@ -25,8 +38,8 @@ docker cp metadata/. graphql-engine:/hasura-metadata
docker-compose up -d --no-recreate graphql-engine
wait_for_server
# export metadata and run diff with validation/metadata.json
docker run --network container:graphql-engine appropriate/curl -s -f -d'{"type" : "export_metadata", "args" : {} }' localhost:8080/v1/query | jq -j '.' | diff validation/metadata.json -
docker run --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "export_metadata", "args" : {} }' localhost:8080/v1/query | jq -j '.' | diff validation/metadata.json -
# get list of migrations applied from graphql-engine server
docker run --network container:graphql-engine appropriate/curl -s -f -d'{"type" : "run_sql", "args" : {"sql": "select * from hdb_catalog.schema_migrations"} }' localhost:8080/v1/query | jq -j '.' | diff validation/schema_migrations.json -
docker run --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "run_sql", "args" : {"sql": "select * from hdb_catalog.schema_migrations"} }' localhost:8080/v1/query | jq -j '.' | diff validation/schema_migrations.json -
# delete postgres and graphql-engine
docker-compose down -v

View File

@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y netcat
ENV HASURA_GRAPHQL_SHOW_UPDATE_NOTIFICATION=false
COPY docker-entrypoint.sh /bin/
COPY cli-hasura-linux-amd64 /bin/hasura-cli
COPY hasura-cli /bin/hasura-cli
RUN chmod +x /bin/hasura-cli

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
set -evo pipefail
SERVER_BUILD_OUTPUT="$1"
CLI_BUILD_OUTPUT="$2"
BUILD_OUTPUT="$3"
CLI_MIGRATIONS_IMAGE="cli-migrations-v3"
SERVER_IMAGE=$(docker load -i "${SERVER_BUILD_OUTPUT}/image.tar" | grep "^Loaded image: " | sed "s/Loaded image: //g")
SERVER_IMAGE_TAG=$(echo "$SERVER_IMAGE" | sed "s/.*:\(.*\)$/\1/")
echo "SERVER_IMAGE is ${SERVER_IMAGE}"
echo "SERVER_IMAGE_TAG is ${SERVER_IMAGE_TAG}"
BINARY=${CLI_BUILD_OUTPUT}/binaries/cli-hasura-linux-amd64
cp ${BINARY} .
docker build -t "${CLI_MIGRATIONS_IMAGE}" . --build-arg SERVER_IMAGE_TAG=$SERVER_IMAGE_TAG
docker save -o "${BUILD_OUTPUT}/v3.tar" "${CLI_MIGRATIONS_IMAGE}"

View File

@ -7,7 +7,8 @@ services:
POSTGRES_PASSWORD: postgrespassword
graphql-engine:
container_name: graphql-engine
image: cli-migrations-v3
image: ${TEST_IMAGE_NAME}
platform: ${TEST_PLATFORM}
ports:
- "8080:8080"
depends_on:

View File

@ -4,11 +4,21 @@ set -evo pipefail
IFS=$'\n\t'
ROOT="$(readlink -f ${BASH_SOURCE[0]%/*}/../../)"
if [[ -z "$TEST_IMAGE_NAME" ]]; then
echo "please set TEST_IMAGE_NAME env to be a non-empty value and retry."
exit 1
fi
if [[ -z "$TEST_PLATFORM" ]]; then
echo "please set TEST_PLATFORM env to be a non-empty value and retry."
exit 1
fi
wait_for_server() {
echo "waiting for server"
for _ in $(seq 1 60);
do
docker run --network container:graphql-engine appropriate/curl http://127.0.0.1:8080/v1/version && return
docker run --rm --network container:graphql-engine curlimages/curl http://127.0.0.1:8080/v1/version && return
echo -n .
sleep 1
done
@ -25,8 +35,8 @@ docker cp metadata/. graphql-engine:/hasura-metadata
docker-compose up -d --no-recreate graphql-engine
wait_for_server
# export metadata and run diff with validation/metadata.json
docker run --network container:graphql-engine appropriate/curl -s -f -d'{"type" : "export_metadata", "args" : {} }' localhost:8080/v1/metadata | jq -j '.' | diff validation/metadata.json -
docker run --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "export_metadata", "args" : {} }' localhost:8080/v1/metadata | jq -j '.' | diff validation/metadata.json -
# get list of migrations applied from graphql-engine server
docker run --network container:graphql-engine appropriate/curl -s -f -d'{"type" : "get_catalog_state", "args" : {} }' localhost:8080/v1/metadata | jq .cli_state | diff validation/catalog_cli_state.json -
docker run --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "get_catalog_state", "args" : {} }' localhost:8080/v1/metadata | jq .cli_state | diff validation/catalog_cli_state.json -
# delete postgres and graphql-engine
docker-compose down -v