diff --git a/.github/workflows/dev-integration.yaml b/.github/workflows/dev-integration.yaml index fda00881..e473fdc2 100644 --- a/.github/workflows/dev-integration.yaml +++ b/.github/workflows/dev-integration.yaml @@ -42,23 +42,23 @@ jobs: rm migrate.linux-amd64.deb - name: deploy to dev cloud environment run: | - for app in $(echo $(bash scripts/list-dir-paths.sh --type app | grep -v client) | xargs basename); do + for app in $(bash scripts/list-dir-paths.sh --type app | grep -v client | xargs basename -a); do # tag newly pushed dev images with develop merge commit sha bash scripts/tag-merge-commit.sh --app-name $app --env dev --env-id ${{ secrets.DEV_ENV_ID }}; # deploy newly tagged images to dev cloud bash scripts/deploy-last-image.sh --app-name $app --env dev --env-id ${{ secrets.DEV_ENV_ID }}; done - name: reset rds database for integration tests - run: make --no-print-directory -C ./migrations resetrds ENV=dev DB=test + run: ENV_ID=${{ secrets.DEV_ENV_ID }} make --no-print-directory -C ./migrations resetrds ENV=dev DB=test - name: dump rds database locally for restore between integration tests run: make --no-print-directory -C ./migrations/dumps dump-rds-testseed - name: get secrets for dev integration tests - run: make --no-print-directory -C ./tests get-secrets ENV=dev + run: ENV_ID=${{ secrets.DEV_ENV_ID }} make --no-print-directory -C ./tests get-secrets ENV=dev - name: run dev cloud integration tests - run: cargo test --manifest-path ./tests/Cargo.toml --features integration_tests -- --test-threads=1 + run: ENV_ID=${{ secrets.DEV_ENV_ID }} cargo test --manifest-path ./tests/Cargo.toml --features integration_tests -- --test-threads=1 - name: tag and push dev images to prod ecr run: | - for app in $(echo $(bash scripts/list-dir-paths.sh --type app | grep -v client) | xargs basename); do + for app in $(bash scripts/list-dir-paths.sh --type app | grep -v client | xargs basename -a); do # tag newly tested dev images with prod and push to prod ecr bash scripts/push-prod-image.sh --app-name $app --env dev --env-id ${{ secrets.DEV_ENV_ID }}; done \ No newline at end of file diff --git a/.github/workflows/prod-services-deploy.yaml b/.github/workflows/prod-services-deploy.yaml index c4a6504f..de06d516 100644 --- a/.github/workflows/prod-services-deploy.yaml +++ b/.github/workflows/prod-services-deploy.yaml @@ -15,7 +15,7 @@ jobs: run: echo "::add-mask::${{ secrets.AWS_ACCOUNT_ID }}" - name: deploy services to prod cloud environment run: | - for app in $(echo $(bash scripts/list-dir-paths.sh --type app | grep -v client) | xargs basename); do + for app in $(bash scripts/list-dir-paths.sh --type app | grep -v client | xargs basename -a); do # tag newly pushed prod images with master merge commit sha bash scripts/tag-merge-commit.sh --app-name $app --env prod --env-id ${{ secrets.PROD_ENV_ID }}; # deploy newly tagged images to prod cloud diff --git a/migrations/dumps/makefile b/migrations/dumps/makefile index bbf7d186..cb9e20bb 100644 --- a/migrations/dumps/makefile +++ b/migrations/dumps/makefile @@ -5,8 +5,7 @@ dump-testseed: bash scripts/dump-db.sh restore-testseed: - $(MAKE) -C '..' downdocker DB=test # drops functions - $(MAKE) -C '..' dropdocker DB=test # drops migration tables + $(MAKE) -C '..' dropdocker DB=test @cd $(RELATIVE_PROJECT_ROOT_PATH); \ bash scripts/restore-db.sh @@ -15,7 +14,6 @@ dump-rds-testseed: bash scripts/dump-db.sh --rds restore-rds-testseed: - $(MAKE) -C '..' downrds DB=test # drops functions - $(MAKE) -C '..' droprds DB=test # drops migration tables + $(MAKE) -C '..' droprds DB=test @cd $(RELATIVE_PROJECT_ROOT_PATH); \ bash scripts/restore-db.sh --rds \ No newline at end of file diff --git a/scripts/delete-ecr-repos.sh b/scripts/delete-ecr-repos.sh index fdf31028..a8d731df 100644 --- a/scripts/delete-ecr-repos.sh +++ b/scripts/delete-ecr-repos.sh @@ -5,7 +5,7 @@ ENV=dev ENV_ID=$(source scripts/print-env-id.sh) REGION=$(yq '.infrastructure.terraform.aws.modules.environment.env_var.set.REGION.default' $PROJECT_CONF) -for APP_NAME in $(echo $(bash scripts/list-dir-paths.sh --type app | grep -v client) | xargs basename); do +for APP_NAME in $(bash scripts/list-dir-paths.sh --type app | grep -v client | xargs basename -a); do IMAGE_NAME="$ENV_ID/$ENV/$APP_NAME" aws ecr delete-repository --repository-name $IMAGE_NAME --region $REGION --force done \ No newline at end of file diff --git a/tests/src/helpers.rs b/tests/src/helpers.rs index e2a50cfa..6f99a1ae 100644 --- a/tests/src/helpers.rs +++ b/tests/src/helpers.rs @@ -8,8 +8,10 @@ use serde_json::json; use std::{env, fs::File, io::BufReader, process::Command}; pub fn restore_testseed() { + // cloud dev env if env::var("AWS_LAMBDA_FUNCTION_NAME").ok().is_some() { let restore_output = Command::new("make") + .arg("--no-print-directory") .arg("-C") .arg("../migrations/dumps") .arg("restore-rds-testseed") @@ -18,10 +20,18 @@ pub fn restore_testseed() { .expect("failed to execute process"); // cargo test -- --show-output - let restore_output_str = String::from_utf8(restore_output.stdout).expect("Not UTF8"); - println!("{}", restore_output_str); + if !restore_output.clone().stderr.is_empty() { + let restore_output_str = String::from_utf8(restore_output.stderr).expect("Not UTF8"); + println!("{}", restore_output_str); + } + if !restore_output.stdout.is_empty() { + let _restore_output_str = String::from_utf8(restore_output.stdout).expect("Not UTF8"); + // println!("{}", _restore_output_str); + } } else { + // local env let restore_output = Command::new("make") + .arg("--no-print-directory") .arg("-C") .arg("../migrations/dumps") .arg("restore-testseed") @@ -29,8 +39,14 @@ pub fn restore_testseed() { .expect("failed to execute process"); // cargo test -- --show-output - let _restore_output_str = String::from_utf8(restore_output.stdout).expect("Not UTF8"); - // println!("{}", _restore_output_str); // comment in to print db restore output + if !restore_output.clone().stderr.is_empty() { + let restore_output_str = String::from_utf8(restore_output.stderr).expect("Not UTF8"); + println!("{}", restore_output_str); + } + if !restore_output.stdout.is_empty() { + let _restore_output_str = String::from_utf8(restore_output.stdout).expect("Not UTF8"); + // println!("{}", _restore_output_str); // comment in to print db restore output + } } }