From a76263f505264feb615aa470bd5a03f345e5f163 Mon Sep 17 00:00:00 2001 From: Uzaeir Khan Date: Fri, 24 Nov 2023 03:03:15 +0100 Subject: [PATCH] BC-5468 update all ymls after review --- .github/workflows/automatic-trigger.yml | 9 ------- .github/workflows/main.yml | 6 ++--- .github/workflows/manual-trigger.yml | 29 ++++++++++++++++++++++ .github/workflows/remote-trigger.yml | 13 ++++++++++ .github/workflows/scheduled-trigger.yml | 33 +++++++++++++++++++++++++ README.md | 2 +- scripts/aggregate-json-files.sh | 4 +-- 7 files changed, 81 insertions(+), 15 deletions(-) diff --git a/.github/workflows/automatic-trigger.yml b/.github/workflows/automatic-trigger.yml index 7a18f42d..f5efad8d 100644 --- a/.github/workflows/automatic-trigger.yml +++ b/.github/workflows/automatic-trigger.yml @@ -41,15 +41,6 @@ jobs: echo "tag=tag:stable:ci" >> $GITHUB_OUTPUT echo "environment=dev" >> $GITHUB_OUTPUT - - name: Print output results - shell: bash - run: | - echo "cypress brb result: ${{steps.set_variables.outputs.cypress_brb}}" - echo "cypress dbc result: ${{steps.set_variables.outputs.cypress_dbc}}" - echo "cypress nbc result: ${{steps.set_variables.outputs.cypress_nbc}}" - echo "tag result: ${{steps.set_variables.outputs.tag}}" - echo "environment result: ${{steps.set_variables.outputs.environment}}" - configuring-loading-secrets-running-tests: needs: e2e-system-tests uses: ./.github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b5debb07..d0e3d7a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,13 +6,13 @@ on: required: true inputs: cypress_brb: - description: "brb url from remote workflow" + description: "brb url from the workflow" type: string cypress_nbc: - description: "nbc url from remote workflow" + description: "nbc url from the workflow" type: string cypress_default: - description: "default url from remote workflow" + description: "default url from the workflow" type: string tag: description: "tag for running cypress tests" diff --git a/.github/workflows/manual-trigger.yml b/.github/workflows/manual-trigger.yml index 378fed21..bb55713e 100644 --- a/.github/workflows/manual-trigger.yml +++ b/.github/workflows/manual-trigger.yml @@ -18,6 +18,12 @@ on: jobs: e2e-system-tests: runs-on: ubuntu-latest + outputs: + cypress_brb: ${{steps.set_variables.outputs.cypress_brb}} + cypress_dbc: ${{steps.set_variables.outputs.cypress_dbc}} + cypress_nbc: ${{steps.set_variables.outputs.cypress_nbc}} + tag: ${{steps.set_variables.outputs.tag}} + environment: ${{steps.set_variables.outputs.environment}} steps: - name: Setup Node @@ -28,11 +34,34 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Set all parameters for next job + id: set_variables + shell: bash + run: | + echo "cypress_brb=${{inputs.instance1}}" + echo "cypress_nbc=${{inputs.instance2}}" + echo "cypress_dbc=${{inputs.instance3}}" + + if [[ ! $cypress_brb =~ (staging|schulportal) && ! $cypress_dbc =~ (staging|schulportal) && ! $cypress_nbc =~ (staging|schulportal) ]]; then + environment="dev" + else + environment="ref" + fi + + echo "tag=tag:stable:ci" >> $GITHUB_OUTPUT + echo "environment=$environment" >> $GITHUB_OUTPUT + configuring-loading-secrets-running-tests: needs: e2e-system-tests uses: ./.github/workflows/main.yml secrets: service-account-token: ${{ secrets.CYPRESS_ONEPWD_SERVICE_ACCOUNT_TOKEN }} + with: + cypress_brb: ${{needs.e2e-system-tests.outputs.cypress_brb}} + cypress_default: ${{needs.e2e-system-tests.outputs.cypress_dbc}} + cypress_nbc: ${{needs.e2e-system-tests.outputs.cypress_nbc}} + tag: ${{needs.e2e-system-tests.outputs.tag}} + environment: ${{needs.e2e-system-tests.outputs.environment}} notify_RC: runs-on: ubuntu-latest diff --git a/.github/workflows/remote-trigger.yml b/.github/workflows/remote-trigger.yml index 74a64906..73963570 100644 --- a/.github/workflows/remote-trigger.yml +++ b/.github/workflows/remote-trigger.yml @@ -16,6 +16,8 @@ jobs: cypress_brb: ${{ steps.set_target.outputs.CYPRESS_BRB }} cypress_nbc: ${{ steps.set_target.outputs.CYPRESS_NBC }} cypress_default: ${{ steps.set_target.outputs.CYPRESS_DEFAULT }} + tag: ${{steps.set_target.outputs.tag}} + environment: ${{steps.set_target.outputs.environment}} steps: - name: Setup Node @@ -69,6 +71,15 @@ jobs: echo "CYPRESS_DEFAULT=https://default-${cleaned_branch_name}.cd.dbildungscloud.dev" >> $GITHUB_OUTPUT echo "Set CYPRESS_DEFAULT=https://default-${cleaned_branch_name}.cd.dbildungscloud.dev" + if [[ ! $CYPRESS_BRB =~ (staging|schulportal) && ! $CYPRESS_DEFAULT =~ (staging|schulportal) && ! $CYPRESS_NBC =~ (staging|schulportal) ]]; then + environment="dev" + else + environment="ref" + fi + + echo "tag=tag:stable:ci" >> $GITHUB_OUTPUT + echo "environment=$environment" >> $GITHUB_OUTPUT + - name: Check if all apps are running shell: bash run: | @@ -105,3 +116,5 @@ jobs: cypress_brb: ${{ needs.e2e-system-tests.outputs.cypress_brb }} cypress_nbc: ${{ needs.e2e-system-tests.outputs.cypress_nbc }} cypress_default: ${{ needs.e2e-system-tests.outputs.cypress_default }} + tag: ${{needs.e2e-system-tests.outputs.tag}} + environment: ${{needs.e2e-system-tests.outputs.environment}} diff --git a/.github/workflows/scheduled-trigger.yml b/.github/workflows/scheduled-trigger.yml index 7c8d591f..9309b052 100644 --- a/.github/workflows/scheduled-trigger.yml +++ b/.github/workflows/scheduled-trigger.yml @@ -5,6 +5,12 @@ on: jobs: e2e-system-tests: runs-on: ubuntu-latest + outputs: + cypress_brb: ${{steps.set_variables.outputs.cypress_brb}} + cypress_dbc: ${{steps.set_variables.outputs.cypress_dbc}} + cypress_nbc: ${{steps.set_variables.outputs.cypress_nbc}} + tag: ${{steps.set_variables.outputs.tag}} + environment: ${{steps.set_variables.outputs.environment}} steps: - name: Setup Node @@ -15,11 +21,38 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Install 1Password CLI + uses: 1password/install-cli-action@v1 + + - name: Verify 1Password was Installed + run: op --version + + - name: Configure 1Password Service Account + uses: 1password/load-secrets-action/configure@v1 + with: + service-account-token: ${{ secrets.CYPRESS_ONEPWD_SERVICE_ACCOUNT_TOKEN }} + + - name: Set all parameters for next job + id: set_variables + shell: bash + run: | + echo "cypress_brb=$(op document get cypress-json --vault cy-dev-brb | jq -r '.BRB')" >> $GITHUB_OUTPUT + echo "cypress_dbc=$(op document get cypress-json --vault cy-dev-dbc | jq -r '.DEFAULT')" >> $GITHUB_OUTPUT + echo "cypress_nbc=$(op document get cypress-json --vault cy-dev-nbc | jq -r '.NBC')" >> $GITHUB_OUTPUT + echo "tag=tag:stable:ci" >> $GITHUB_OUTPUT + echo "environment=dev" >> $GITHUB_OUTPUT + configuring-loading-secrets-running-tests: needs: e2e-system-tests uses: ./.github/workflows/main.yml secrets: service-account-token: ${{ secrets.CYPRESS_ONEPWD_SERVICE_ACCOUNT_TOKEN }} + with: + cypress_brb: ${{needs.e2e-system-tests.outputs.cypress_brb}} + cypress_default: ${{needs.e2e-system-tests.outputs.cypress_dbc}} + cypress_nbc: ${{needs.e2e-system-tests.outputs.cypress_nbc}} + tag: ${{needs.e2e-system-tests.outputs.tag}} + environment: ${{needs.e2e-system-tests.outputs.environment}} notify_RC: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 7d9e35f1..92617237 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Install or make sure Chrome browser (at least) have it in your development machi |---- logs(contains logs of the test run) |---- node_modules |---- scripts -| |____ aggregate-json-files.sh (Aggregate all json file into one json file in CI) +| |____ aggregate-json-files.sh (Aggregate all json files into one json file in CI) |---- .editorconfig |---- .gitattributes |---- .gitignore diff --git a/scripts/aggregate-json-files.sh b/scripts/aggregate-json-files.sh index d124a8ae..91fb8554 100644 --- a/scripts/aggregate-json-files.sh +++ b/scripts/aggregate-json-files.sh @@ -49,8 +49,8 @@ declare -A key_value_pairs for instance in "${instances[@]}"; do if [[ $workflow_name == *"manual"* || $workflow_name == *"remote"* ]]; then file_path="$workspace_path/e2e-system-tests/env_variables/file-${environment}-${instance}.json" - else - file_path="$workspace_path/e2e-system-tests/env_variables/file-dev-${instance}.json" + # else + # file_path="$workspace_path/e2e-system-tests/env_variables/file-dev-${instance}.json" fi file_paths+=("$file_path")