From b63130e41844dc1ee4f5674867b6b586229c3deb Mon Sep 17 00:00:00 2001 From: pwei1018 Date: Mon, 16 Nov 2020 08:34:35 -0800 Subject: [PATCH] Update for set environment variables issue of GHA. --- .github/workflows/account-mailer-cd.yml | 6 +- .github/workflows/auth-api-cd.yml | 6 +- .github/workflows/auth-web-cd.yml | 6 +- .github/workflows/events-listener-cd.yml | 6 +- .github/workflows/integration-testing-dev.yml | 271 ------------------ .github/workflows/notify-api&queue-cd.yml | 12 +- .github/workflows/status-api-cd.yml | 6 +- scripts/1pass.sh | 17 +- 8 files changed, 30 insertions(+), 300 deletions(-) delete mode 100644 .github/workflows/integration-testing-dev.yml diff --git a/.github/workflows/account-mailer-cd.yml b/.github/workflows/account-mailer-cd.yml index 1f194353f1..78b267d914 100644 --- a/.github/workflows/account-mailer-cd.yml +++ b/.github/workflows/account-mailer-cd.yml @@ -22,17 +22,17 @@ jobs: - uses: actions/checkout@v2 - name: Set env by input run: | - echo "::set-env name=TAG_NAME::${{ github.event.inputs.environement }}" + echo "TAG_NAME=${{ github.event.inputs.environement }}" >> $GITHUB_ENV - name: Set env by master branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/master' run: | - echo "::set-env name=TAG_NAME::test" + echo "TAG_NAME=test" >> $GITHUB_ENV - name: Set env by development branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/development' run: | - echo "::set-env name=TAG_NAME::dev" + echo "TAG_NAME=dev" >> $GITHUB_ENV - uses: pwei1018/bcrs-cd-action@latest with: diff --git a/.github/workflows/auth-api-cd.yml b/.github/workflows/auth-api-cd.yml index 31b413e697..61c3c1dc3b 100644 --- a/.github/workflows/auth-api-cd.yml +++ b/.github/workflows/auth-api-cd.yml @@ -22,17 +22,17 @@ jobs: - uses: actions/checkout@v2 - name: Set env by input run: | - echo "::set-env name=TAG_NAME::${{ github.event.inputs.environement }}" + echo "TAG_NAME=${{ github.event.inputs.environement }}" >> $GITHUB_ENV - name: Set env by master branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/master' run: | - echo "::set-env name=TAG_NAME::test" + echo "TAG_NAME=test" >> $GITHUB_ENV - name: Set env by development branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/development' run: | - echo "::set-env name=TAG_NAME::dev" + echo "TAG_NAME=dev" >> $GITHUB_ENV - uses: pwei1018/bcrs-cd-action@latest with: diff --git a/.github/workflows/auth-web-cd.yml b/.github/workflows/auth-web-cd.yml index ceee3a1e54..3f3d8900e0 100644 --- a/.github/workflows/auth-web-cd.yml +++ b/.github/workflows/auth-web-cd.yml @@ -22,17 +22,17 @@ jobs: - uses: actions/checkout@v2 - name: Set env by input run: | - echo "::set-env name=TAG_NAME::${{ github.event.inputs.environement }}" + echo "TAG_NAME=${{ github.event.inputs.environement }}" >> $GITHUB_ENV - name: Set env by master branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/master' run: | - echo "::set-env name=TAG_NAME::test" + echo "TAG_NAME=test" >> $GITHUB_ENV - name: Set env by development branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/development' run: | - echo "::set-env name=TAG_NAME::dev" + echo "TAG_NAME=dev" >> $GITHUB_ENV - uses: pwei1018/bcrs-cd-action@latest with: diff --git a/.github/workflows/events-listener-cd.yml b/.github/workflows/events-listener-cd.yml index f40c94b3da..190e780831 100644 --- a/.github/workflows/events-listener-cd.yml +++ b/.github/workflows/events-listener-cd.yml @@ -22,17 +22,17 @@ jobs: - uses: actions/checkout@v2 - name: Set env by input run: | - echo "::set-env name=TAG_NAME::${{ github.event.inputs.environement }}" + echo "TAG_NAME=${{ github.event.inputs.environement }}" >> $GITHUB_ENV - name: Set env by master branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/master' run: | - echo "::set-env name=TAG_NAME::test" + echo "TAG_NAME=test" >> $GITHUB_ENV - name: Set env by development branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/development' run: | - echo "::set-env name=TAG_NAME::dev" + echo "TAG_NAME=dev" >> $GITHUB_ENV - uses: pwei1018/bcrs-cd-action@latest with: diff --git a/.github/workflows/integration-testing-dev.yml b/.github/workflows/integration-testing-dev.yml deleted file mode 100644 index 357c92ee22..0000000000 --- a/.github/workflows/integration-testing-dev.yml +++ /dev/null @@ -1,271 +0,0 @@ -name: Integration Testing DEV - -on: - schedule: - # At 20:30. - - cron: "30 20 * * *" - -jobs: - setup-job: - runs-on: ubuntu-latest - if: github.repository == 'bcgov/sbc-auth' - - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: pip cache - uses: actions/cache@v2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('./integration-tests/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - basic-account: - needs: setup-job - runs-on: ubuntu-latest - - env: - TAG_NAME: dev - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Set Environement Variables - run: | - ./scripts/install_tools.sh - op --version - vaults='[{"vault": "relationship","application": ["integration-test"]}]' - ./scripts/1pass.sh ${{ secrets.op_parameters }} -m "env" -e "${TAG_NAME}" -v "${vaults}" - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: Run test - working-directory: ./integration-tests - if: steps.pip-cache.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pytest -x --suppress-no-test-exit-code --suppress-tests-failed-exit-code tests/suites/test_basic_account.py --junitxml=basic_account.xml - - uses: actions/upload-artifact@v2 - with: - name: test-result-artifact - path: ./integration-tests/basic_account.xml - - premium_account: - needs: setup-job - runs-on: ubuntu-latest - - env: - TAG_NAME: dev - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Set Environement Variables - run: | - ./scripts/install_tools.sh - op --version - vaults='[{"vault": "relationship","application": ["integration-test"]}]' - ./scripts/1pass.sh ${{ secrets.op_parameters }} -m "env" -e "${TAG_NAME}" -v "${vaults}" - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: Run test - working-directory: ./integration-tests - if: steps.pip-cache.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pytest -x --suppress-no-test-exit-code --suppress-tests-failed-exit-code tests/suites/test_premium_account.py --junitxml=premium_account.xml - - uses: actions/upload-artifact@v2 - with: - name: test-result-artifact - path: ./integration-tests/premium_account.xml - - out-of-province: - needs: setup-job - runs-on: ubuntu-latest - - env: - TAG_NAME: dev - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Set Environement Variables - run: | - ./scripts/install_tools.sh - op --version - vaults='[{"vault": "relationship","application": ["integration-test"]}]' - ./scripts/1pass.sh ${{ secrets.op_parameters }} -m "env" -e "${TAG_NAME}" -v "${vaults}" - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: Run test - working-directory: ./integration-tests - if: steps.pip-cache.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pytest -x --suppress-no-test-exit-code --suppress-tests-failed-exit-code tests/suites/test_out_of_province.py --junitxml=out_of_province.xml - - uses: actions/upload-artifact@v2 - with: - name: test-result-artifact - path: ./integration-tests/out_of_province.xml - - staff: - needs: setup-job - runs-on: ubuntu-latest - - env: - TAG_NAME: dev - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Set Environement Variables - run: | - ./scripts/install_tools.sh - op --version - vaults='[{"vault": "relationship","application": ["integration-test"]}]' - ./scripts/1pass.sh ${{ secrets.op_parameters }} -m "env" -e "${TAG_NAME}" -v "${vaults}" - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: Run test - working-directory: ./integration-tests - if: steps.pip-cache.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pytest -x --suppress-no-test-exit-code --suppress-tests-failed-exit-code tests/suites/test_staff.py --junitxml=staff.xml - - uses: actions/upload-artifact@v2 - with: - name: test-result-artifact - path: ./integration-tests/staff.xml - - anonymouse: - needs: setup-job - runs-on: ubuntu-latest - - env: - TAG_NAME: dev - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Set Environement Variables - run: | - ./scripts/install_tools.sh - op --version - vaults='[{"vault": "relationship","application": ["integration-test"]}]' - ./scripts/1pass.sh ${{ secrets.op_parameters }} -m "env" -e "${TAG_NAME}" -v "${vaults}" - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: pip cache - uses: actions/cache@v2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('./integration-tests/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip-- - - name: Run test - working-directory: ./integration-tests - if: steps.pip-cache.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pytest -x --suppress-no-test-exit-code --suppress-tests-failed-exit-code tests/suites/test_anonymous.py --junitxml=anonymous.xml - - uses: actions/upload-artifact@v2 - with: - name: test-result-artifact - path: ./integration-tests/anonymous.xml - - analysis-test-results: - needs: [basic-account, premium_account, out-of-province, staff, anonymouse] - runs-on: ubuntu-latest - - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - uses: actions/download-artifact@v2 - with: - name: test-result-artifact - path: ./integration-tests/test_results - - name: analysis results - id: analysis - working-directory: ./integration-tests - run: | - ls -l - pip install junitparser - output=$(python analysis_test_results.py) - echo "::set-output name=summary::$output" - - if: steps.analysis.outputs.summary != '' - run: | - exit 1 - - uses: LouisBrunner/checks-action@v0.1.0 - if: always() - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: Test results - conclusion: ${{ job.status }} - output: '{ "summary": "${{ steps.analysis.outputs.summary }}" }' - annotations: ${{ steps.annotations.outputs.summary }} - - name: Rocket.Chat Notification - uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master - if: failure() - with: - type: ${{ job.status }} - job_name: "*Integration Testing failed*" - channel: "#relationship-developers" - url: ${{ secrets.ROCKETCHAT_WEBHOOK }} - commit: false - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/notify-api&queue-cd.yml b/.github/workflows/notify-api&queue-cd.yml index 90f367a6a7..6c83d3654e 100644 --- a/.github/workflows/notify-api&queue-cd.yml +++ b/.github/workflows/notify-api&queue-cd.yml @@ -27,17 +27,17 @@ jobs: - uses: actions/checkout@v2 - name: Set env by input run: | - echo "::set-env name=TAG_NAME::${{ github.event.inputs.environement }}" + echo "TAG_NAME=${{ github.event.inputs.environement }}" >> $GITHUB_ENV - name: Set env by master branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/master' run: | - echo "::set-env name=TAG_NAME::test" + echo "TAG_NAME=test" >> $GITHUB_ENV - name: Set env by development branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/development' run: | - echo "::set-env name=TAG_NAME::dev" + echo "TAG_NAME=dev" >> $GITHUB_ENV - uses: pwei1018/bcrs-cd-action@latest with: @@ -76,17 +76,17 @@ jobs: - uses: actions/checkout@v2 - name: Set env by input run: | - echo "::set-env name=TAG_NAME::${{ github.event.inputs.environement }}" + echo "TAG_NAME=${{ github.event.inputs.environement }}" >> $GITHUB_ENV - name: Set env by master branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/master' run: | - echo "::set-env name=TAG_NAME::test" + echo "TAG_NAME=test" >> $GITHUB_ENV - name: Set env by development branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/development' run: | - echo "::set-env name=TAG_NAME::dev" + echo "TAG_NAME=dev" >> $GITHUB_ENV - uses: pwei1018/bcrs-cd-action@latest with: diff --git a/.github/workflows/status-api-cd.yml b/.github/workflows/status-api-cd.yml index 8feb5cb322..99531786c9 100644 --- a/.github/workflows/status-api-cd.yml +++ b/.github/workflows/status-api-cd.yml @@ -22,17 +22,17 @@ jobs: - uses: actions/checkout@v2 - name: Set env by input run: | - echo "::set-env name=TAG_NAME::${{ github.event.inputs.environement }}" + echo "TAG_NAME=${{ github.event.inputs.environement }}" >> $GITHUB_ENV - name: Set env by master branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/master' run: | - echo "::set-env name=TAG_NAME::test" + echo "TAG_NAME=test" >> $GITHUB_ENV - name: Set env by development branch if: env.TAG_NAME == '' && github.ref == 'refs/heads/development' run: | - echo "::set-env name=TAG_NAME::dev" + echo "TAG_NAME=dev" >> $GITHUB_ENV - uses: pwei1018/bcrs-cd-action@latest with: diff --git a/scripts/1pass.sh b/scripts/1pass.sh index 41e6e92264..fcfdff3049 100755 --- a/scripts/1pass.sh +++ b/scripts/1pass.sh @@ -185,8 +185,8 @@ for env_name in "${envs[@]}"; do ;; env) echo "Setting environment variable $(_envvars '.t')" - echo ::add-mask::$(_envvars '.v') - echo ::set-env name=$(_envvars '.t')::$(_envvars '.v') +echo ::add-mask::$(_envvars '.v') + echo ::echo "$(_envvars '.t')=$(_envvars '.v')" >> $GITHUB_ENV ;; compare) #read the vault's key to a txt file @@ -210,15 +210,15 @@ case ${METHOD} in result2=$(comm -23 <(sort t2.txt) <(sort t1.txt)) if [[ -z ${result} ]]; then if [[ -z ${result2} ]]; then - echo ::set-env name=approval::true - echo ::set-env name=message::The vault items between ${envs[0]} and ${envs[1]} are matched. + echo ::echo "approval=true" >> $GITHUB_ENV + echo ::echo "message=The vault items between ${envs[0]} and ${envs[1]} are matched." >> $GITHUB_ENV else - echo ::set-env name=approval::false - echo ::set-env name=message::The following vault items between ${envs[1]} and ${envs[0]} does not match. ${result2} + echo ::echo "approval=false" >> $GITHUB_ENV + echo ::echo "message=The following vault items between ${envs[1]} and ${envs[0]} does not match. ${result2}" >> $GITHUB_ENV fi else - echo ::set-env name=approval::false - echo ::set-env name=message::The following vault items between ${envs[0]} and ${envs[1]} does not match. ${result} + echo ::echo "approval=false" >> $GITHUB_ENV + echo ::echo "message=The following vault items between ${envs[0]} and ${envs[1]} does not match. ${result}" >> $GITHUB_ENV fi rm t*.txt @@ -226,3 +226,4 @@ case ${METHOD} in esac +