Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opencrvs/e2e
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: dafce85f65e7b7627e442e961a4e620ca10bbe46
Choose a base ref
..
head repository: opencrvs/e2e
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5d6dde6aadad6e27e1ec66adde04fb3aacc74c93
Choose a head ref
60 changes: 17 additions & 43 deletions .github/workflows/deploy-and-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Deploy & run E2E
run-name: Deploy & E2E, triggered by ${{ github.event.client_payload.actor || github.actor }} to ${{ github.event.inputs.stack }}
run-name: 'E2E by ${{ github.event.client_payload.actor || github.actor }} to ${{ github.event.client_payload.stack || github.event.inputs.stack }}. Images core: ${{ github.event.client_payload.core-image-tag || github.event.inputs.core-image-tag }} and farajaland: ${{ github.event.client_payload.countryconfig-image-tag || github.event.inputs.countryconfig-image-tag }}'
on:
repository_dispatch:
types: [run_e2e]
@@ -19,50 +19,16 @@ on:
required: true

concurrency:
group: ci-build
cancel-in-progress: false
group: ${{ github.event.client_payload.stack || github.event.inputs.stack }}
cancel-in-progress: true

jobs:
get-core-commit:
name: Resolve latest core tag
runs-on: ubuntu-latest
outputs:
latest_commit_sha: ${{ steps.get_latest_commit.outputs.commit_sha }}
steps:
- name: Checkout opencrvs-core repository
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
uses: actions/checkout@v3
with:
repository: 'opencrvs/opencrvs-core'
ref: 'develop'
- name: Get latest commit SHA
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
id: get_latest_commit
run: echo "::set-output name=commit_sha::$(git rev-parse HEAD | cut -c 1-7)"

get-country-config-commit:
name: Resolve latest Farajaland tag
runs-on: ubuntu-latest
needs: get-core-commit
outputs:
short_sha: ${{ steps.set_short_sha.outputs.short_sha }}
steps:
- name: Checkout code
uses: actions/checkout@v3
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
- name: Get short commit hash
id: set_short_sha
run: echo "::set-output name=short_sha::${GITHUB_SHA:0:7}"
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'

deploy:
needs: [get-country-config-commit, get-core-commit]
uses: ./.github/workflows/deploy.yml
with:
environment: qa
core-image-tag: ${{ github.event.inputs.core-image-tag || needs.get-core-commit.outputs.latest_commit_sha }}
countryconfig-image-tag: ${{ github.event.inputs.countryconfig-image-tag || needs.get-country-config-commit.outputs.short_sha }}
stack: ${{ github.event.inputs.stack }}
core-image-tag: ${{ github.event.client_payload.core-image-tag || github.event.inputs.core-image-tag }}
countryconfig-image-tag: ${{ github.event.client_payload.countryconfig-image-tag || github.event.inputs.countryconfig-image-tag }}
stack: ${{ github.event.client_payload.stack || github.event.inputs.stack }}
dependencies: false
reset: 'true'
secrets: inherit
@@ -87,13 +53,21 @@ jobs:
test:
needs: [deploy, discover-tests]
runs-on: ubuntu-22.04
environment: qa
environment: ${{ github.event.client_payload.stack || github.event.inputs.stack }}
strategy:
fail-fast: false
matrix:
test_dir: ${{ fromJson(needs.discover-tests.outputs.test_matrix) }}
steps:
- uses: actions/checkout@v4
with:
repository: 'opencrvs/opencrvs-farajaland'
fetch-depth: 0

- name: Checkout country branch
run: |
git checkout ${{ github.event.client_payload.countryconfig-image-tag || github.event.inputs.countryconfig-image-tag }}
- uses: actions/setup-node@v4
with:
node-version: 18
@@ -129,10 +103,10 @@ jobs:
if: steps.check-specs.outputs.has_spec_files == 'true'
run: npx playwright test ./e2e/testcases/${{ matrix.test_dir }}
env:
DOMAIN: '${{ inputs.stack }}.${{ vars.DOMAIN }}'
DOMAIN: '${{ github.event.client_payload.stack || inputs.stack }}.${{ vars.DOMAIN }}'

- uses: actions/upload-artifact@v4
if: steps.check-specs.outputs.has_spec_files == 'true'
if: always() && steps.check-specs.outputs.has_spec_files == 'true'
with:
name: playwright-report-${{ matrix.test_dir }}
path: playwright-report/
45 changes: 24 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: Deploy (development)
run-name: Deploy ${{ inputs.stack }} to ${{ inputs.environment }} with reset=${{ inputs.reset }} core=${{ inputs.core-image-tag }} country config=${{ inputs.countryconfig-image-tag }}
run-name: Deploy ${{ inputs.stack }} with reset=${{ inputs.reset }} core=${{ inputs.core-image-tag }} country config=${{ inputs.countryconfig-image-tag }}
on:
workflow_call:
inputs:
environment:
type: string
description: Environment to deploy to
required: true
core-image-tag:
type: string
description: Core DockerHub image tag
@@ -33,15 +29,6 @@ on:

workflow_dispatch:
inputs:
environment:
type: choice
description: Environment to deploy to
required: true
default: 'staging'
options:
- staging
- qa
- development
core-image-tag:
description: Core DockerHub image tag
required: true
@@ -64,12 +51,28 @@ on:
default: false
jobs:
deploy:
environment: ${{ inputs.environment }}
environment: ${{ inputs.stack }}
runs-on: ubuntu-22.04
outputs:
outcome: ${{ steps.deploy.outcome }}
timeout-minutes: 60
steps:
- name: Check if vars.BLOCK_NEW_DEPLOYMENTS is set to true
run: |
if [[ "${{ vars.BLOCK_NEW_DEPLOYMENTS }}" == "true" ]]; then
echo "BLOCK_NEW_DEPLOYMENTS in Github environment settings is set to true, exiting..."
echo "Set the variable to anything other than 'true' and redeploy"
echo "https://github.com/opencrvs/e2e/settings/environments"
exit 1
fi
- name: Generate summary
run: |
echo "Deploying environment to https://${{ inputs.stack }}.${{ vars.DOMAIN }}" >> $GITHUB_STEP_SUMMARY
echo "Core image tag: ${{ inputs.core-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "Country config image tag: ${{ inputs.countryconfig-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "Reset environment: ${{ inputs.reset }}" >> $GITHUB_STEP_SUMMARY
echo "Redeploy dependencies: ${{ inputs.dependencies }}" >> $GITHUB_STEP_SUMMARY
- name: Clone core
uses: actions/checkout@v3
with:
@@ -145,7 +148,7 @@ jobs:
# This includes SSH_KEY and KNOWN_HOSTS
#
while IFS= read -r secret; do
echo "$secret" >> .env.${{ inputs.environment }}
echo "$secret" >> .env.${{ inputs.stack }}
done < <(
jq -r '
to_entries |
@@ -161,7 +164,7 @@ jobs:
EOF)
while IFS= read -r var; do
echo "$var" >> .env.${{ inputs.environment }}
echo "$var" >> .env.${{ inputs.stack }}
done < <(
jq -r '
to_entries |
@@ -172,14 +175,14 @@ jobs:
.[]' <<< "$VARS_JSON_WITH_NEWLINES"
)
- name: Deploy to ${{ inputs.environment }}
- name: Deploy to ${{ inputs.stack }}
id: deploy
run: |
cd ./${{ github.event.repository.name }}
yarn install
yarn deploy \
--clear_data=no \
--environment=${{ inputs.environment }} \
--environment=${{ inputs.stack }} \
--host=${{ vars.DOMAIN }} \
--stack=${{ inputs.stack }} \
--update-dependencies=${{ inputs.dependencies }} \
@@ -195,7 +198,7 @@ jobs:
if: ${{ inputs.reset == 'true' && needs.deploy.outputs.outcome == 'success' }}
uses: ./.github/workflows/clear-environment.yml
with:
environment: ${{ inputs.environment }}
environment: ${{ inputs.stack }}
stack: ${{ inputs.stack }}
secrets: inherit

@@ -204,7 +207,7 @@ jobs:
if: ${{ inputs.reset == 'true' && needs.reset.outputs.outcome == 'success' }}
uses: ./.github/workflows/seed-data.yml
with:
environment: ${{ inputs.environment }}
environment: ${{ inputs.stack }}
core-image-tag: ${{ inputs.core-image-tag }}
stack: ${{ inputs.stack }}
secrets: inherit
11 changes: 8 additions & 3 deletions .github/workflows/seed-data.yml
Original file line number Diff line number Diff line change
@@ -48,8 +48,13 @@ jobs:
cd opencrvs-core
git checkout ${{ inputs.core-image-tag }}
# copy ./opencrvs-core/packages/data-seeder to a new temporary directory
- name: Copy data-seeder
run: |
cp -r ./opencrvs-core/packages/data-seeder ./data-seeder
- name: Install dependencies
working-directory: ./opencrvs-core
working-directory: ./data-seeder
run: yarn install

- name: Seed data on given environment
@@ -59,8 +64,8 @@ jobs:
timeout_minutes: 10
max_attempts: 5
command: |
cd ./opencrvs-core
yarn seed:prod
cd ./data-seeder
NODE_OPTIONS=--dns-result-order=ipv4first npx ts-node --transpile-only -r tsconfig-paths/register src/index.ts
env:
ACTIVATE_USERS: ${{ vars.ACTIVATE_USERS }}
GATEWAY_HOST: 'https://gateway.${{inputs.stack}}.opencrvs.dev'
2 changes: 1 addition & 1 deletion infrastructure/backups/backup.sh
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ elif [ "$REPLICAS" = "0" ]; then
NETWORK=opencrvs_default
echo "Working with no replicas"
else
NETWORK=dependencies_internal_net
NETWORK=dependencies_mongo_net
# Construct the HOST string rs0/mongo1,mongo2... based on the number of replicas
HOST="rs0/"
for (( i=1; i<=REPLICAS; i++ )); do
2 changes: 1 addition & 1 deletion infrastructure/backups/restore.sh
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ elif [ "$REPLICAS" = "0" ]; then
NETWORK=opencrvs_default
echo "Working with no replicas"
else
NETWORK=dependencies_internal_net
NETWORK=dependencies_mongo_net
# Construct the HOST string rs0/mongo1,mongo2... based on the number of replicas
HOST="rs0/"
for (( i=1; i<=REPLICAS; i++ )); do
13 changes: 9 additions & 4 deletions infrastructure/clear-all-data.sh
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ if [ "$REPLICAS" = "0" ]; then
NETWORK=opencrvs_default
echo "Working with no replicas"
else
NETWORK=dependencies_internal_net
NETWORK=dependencies_mongo_net
# Construct the HOST string rs0/mongo1,mongo2... based on the number of replicas
HOST="rs0/"
for (( i=1; i<=REPLICAS; i++ )); do
@@ -92,17 +92,22 @@ drop_database performance;

# Delete all data from elasticsearch
#-----------------------------------
docker run --rm --network=$NETWORK appropriate/curl curl -XDELETE "http://$(elasticsearch_host)/${STACK}__ocrvs" -v
docker run --rm --network=dependencies_elasticsearch_net appropriate/curl curl -XDELETE "http://$(elasticsearch_host)/${STACK}__ocrvs" -v

# Delete all data from metrics
#-----------------------------
docker run --rm --network=$NETWORK appropriate/curl curl -X POST "http://influxdb:8086/query?db=${STACK}__ocrvs" --data-urlencode "q=DROP SERIES FROM /.*/" -v
docker run --rm --network=dependencies_influx_net appropriate/curl curl -X POST "http://influxdb:8086/query?db=${STACK}__ocrvs" --data-urlencode "q=DROP SERIES FROM /.*/" -v

# Delete all data from minio
#-----------------------------
docker run --rm --network=$NETWORK --entrypoint=/bin/sh minio/mc -c "\
docker run --rm --network=dependencies_minio_net --entrypoint=/bin/sh minio/mc -c "\
mc alias set myminio http://minio:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD && \
mc rm --recursive --force myminio/${STACK}--ocrvs && \
mc rb myminio/${STACK}--ocrvs && \
mc mb myminio/${STACK}--ocrvs"

# Delete all data from redis
#-----------------------------
REDIS_CONTAINER_ID=$(docker ps --filter "name=^${STACK}_redis" --format '{{.ID}}' --latest)
echo "REDIS_CONTAINER_ID: $REDIS_CONTAINER_ID"
docker exec -i $REDIS_CONTAINER_ID redis-cli FLUSHDB
56 changes: 30 additions & 26 deletions infrastructure/deployment/deploy.sh
Original file line number Diff line number Diff line change
@@ -278,54 +278,49 @@ split_and_join() {
docker_stack_deploy() {
echo "Deploying this environment: $ENVIRONMENT_COMPOSE"

echo "Pulling all docker images. This might take a while"
if [ "$UPDATE_DEPENDENCIES" = false ]; then
echo "Pulling all docker images. This might take a while"

EXISTING_IMAGES=$(configured_ssh "docker images --format '{{.Repository}}:{{.Tag}}'")
IMAGE_TAGS_TO_DOWNLOAD=$(get_docker_tags_from_compose_files "$COMPOSE_FILES_USED")
EXISTING_IMAGES=$(configured_ssh "docker images --format '{{.Repository}}:{{.Tag}}'")
IMAGE_TAGS_TO_DOWNLOAD=$(get_docker_tags_from_compose_files "$COMPOSE_FILES_USED")

for tag in ${IMAGE_TAGS_TO_DOWNLOAD[@]}; do
if [[ $EXISTING_IMAGES == *"$tag"* ]]; then
echo "$tag already exists on the machine. Skipping..."
continue
fi
for tag in ${IMAGE_TAGS_TO_DOWNLOAD[@]}; do
if [[ $EXISTING_IMAGES == *"$tag"* ]]; then
echo "$tag already exists on the machine. Skipping..."
continue
fi

echo "Downloading $tag"
echo "Downloading $tag"

until configured_ssh "cd /opt/opencrvs && docker pull $tag"
do
echo "Server failed to download $tag. Retrying..."
sleep 5
until configured_ssh "cd /opt/opencrvs && docker pull $tag"
do
echo "Server failed to download $tag. Retrying..."
sleep 5
done &
done
done

wait
fi

echo "Updating docker swarm stack with new compose files"

EXISTING_STACKS=$(configured_ssh 'docker stack ls --format "{{ .Name }}" | grep -v "dependencies" | paste -sd "," -')

configured_rsync -rlD $SSH_USER@$SSH_HOST:/opt/opencrvs/infrastructure/docker-compose.dependencies.yml ./infrastructure/docker-compose.dependencies.yml

if echo $EXISTING_STACKS | grep -w $STACK > /dev/null; then
echo "Stack $STACK exists"
npx tsx infrastructure/deployment/add-networks.ts infrastructure/docker-compose.dependencies.yml "$EXISTING_STACKS" > ./docker-compose.dependencies.yml
else
echo "Stack $STACK doesnt exist. Creating"
UPDATE_DEPENDENCIES=true
npx tsx infrastructure/deployment/add-networks.ts infrastructure/docker-compose.dependencies.yml "$EXISTING_STACKS,$STACK" > ./docker-compose.dependencies.yml
fi

configured_rsync -rlD ./docker-compose.dependencies.yml $SSH_USER@$SSH_HOST:/opt/opencrvs/infrastructure/docker-compose.dependencies.yml


if [ "$UPDATE_DEPENDENCIES" = true ]; then
echo "Updating dependency stack"
configured_ssh 'cd /opt/opencrvs && \
docker stack deploy --prune -c '$(split_and_join " " " -c " "$(to_remote_paths $DEPENDENCY_COMPOSE_FILES)")' --with-registry-auth dependencies'
else
configured_ssh 'cd /opt/opencrvs && \
docker stack deploy --prune -c '$(split_and_join " " " -c " "$(to_remote_paths $APPLICATION_COMPOSE_FILES)")' --with-registry-auth '$STACK
fi

configured_ssh 'cd /opt/opencrvs && \
docker stack deploy --prune -c '$(split_and_join " " " -c " "$(to_remote_paths $APPLICATION_COMPOSE_FILES)")' --with-registry-auth '$STACK


}

validate_options
@@ -433,4 +428,13 @@ if [ "$UPDATE_DEPENDENCIES" = true ]; then
fi
sleep 5
done
else
echo 'Waiting for Elasticsearch to be ready'

while true; do
if configured_ssh "/opt/opencrvs/infrastructure/elasticsearch/wait-for-elasticsearch.sh"; then
break
fi
sleep 5
done
fi
Loading