-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BC-4569 use secrets from 1pwd instead of github secrets for cypress a…
…utomation (#139)
- Loading branch information
1 parent
bfb913d
commit 972d81d
Showing
5 changed files
with
215 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
name: configure, load secrets, run Cypress tests, generate and upload reports | ||
on: | ||
workflow_call: | ||
secrets: | ||
service-account-token: | ||
required: true | ||
inputs: | ||
cypress_brb: | ||
description: "brb url from remote workflow" | ||
type: string | ||
cypress_nbc: | ||
description: "nbc url from remote workflow" | ||
type: string | ||
cypress_default: | ||
description: "default url from remote workflow" | ||
type: string | ||
|
||
jobs: | ||
configure-load-secrets-and-run_tests: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag: ${{ steps.setting_url.outputs.TAG }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: hpi-schul-cloud/e2e-system-tests | ||
path: e2e-system-tests | ||
|
||
- name: Configure 1Password Service Account | ||
uses: 1password/load-secrets-action/configure@v1 | ||
with: | ||
service-account-token: ${{ secrets.service-account-token }} | ||
|
||
- name: Setting URL's | ||
id: setting_url | ||
run: | | ||
workflow_name="${{ github.workflow }}" | ||
if [[ $workflow_name == *"manual"* ]]; then | ||
echo "This is a manual workflow" | ||
echo "CYPRESS_BRB=${{ github.event.inputs.instance1 }}" >> $GITHUB_ENV | ||
echo "$CYPRESS_BRB" | ||
echo "CYPRESS_NBC=${{ github.event.inputs.instance2 }}" >> $GITHUB_ENV | ||
echo "$CYPRESS_NBC" | ||
echo "CYPRESS_DEFAULT=${{ github.event.inputs.instance3 }}" >> $GITHUB_ENV | ||
echo "$CYPRESS_DEFAULT" | ||
echo "TAG=tag:stable" >> $GITHUB_OUTPUT | ||
echo "$TAG" | ||
elif [[ $workflow_name == *"automatic"* || $workflow_name == *"scheduled"* ]]; then | ||
echo "This is an automatic or scheduled workflow" | ||
echo "CYPRESS_BRB=op://cy-dev-brb/cypress/CYPRESS_BRB" >> $GITHUB_ENV | ||
echo "$CYPRESS_BRB" | ||
echo "CYPRESS_NBC=op://cy-dev-nbc/cypress/CYPRESS_NBC" >> $GITHUB_ENV | ||
echo "$CYPRESS_NBC" | ||
echo "CYPRESS_DEFAULT=op://cy-dev-dbc/cypress/CYPRESS_DEFAULT" >> $GITHUB_ENV | ||
echo "$CYPRESS_DEFAULT" | ||
echo "TAG=tag:stable" >> $GITHUB_OUTPUT | ||
echo "$TAG" | ||
else | ||
echo "This is an remote workflow" | ||
echo "CYPRESS_BRB=${{ inputs.cypress_brb }}" >> $GITHUB_ENV | ||
echo "$CYPRESS_BRB" | ||
echo "CYPRESS_NBC=${{ inputs.cypress_nbc }}" >> $GITHUB_ENV | ||
echo "$CYPRESS_NBC" | ||
echo "CYPRESS_DEFAULT=${{ inputs.cypress_default }}" >> $GITHUB_ENV | ||
echo "$CYPRESS_DEFAULT" | ||
echo "TAG=tag:stable:pr" >> $GITHUB_OUTPUT | ||
echo "$TAG" | ||
fi | ||
- name: Load secret | ||
id: op-load-secret | ||
uses: 1password/load-secrets-action@v1 | ||
with: | ||
export-env: true | ||
env: | ||
CYPRESS_TEACHER_1_EMAIL: op://cy-dev-brb/cypress/CYPRESS_TEACHER_1_EMAIL | ||
CYPRESS_TEACHER_1_PASSWORD: op://cy-dev-brb/cypress/CYPRESS_TEACHER_1_PASSWORD | ||
CYPRESS_TEACHER_2_EMAIL: op://cy-dev-brb/cypress/CYPRESS_TEACHER_2_EMAIL | ||
CYPRESS_TEACHER_2_PASSWORD: op://cy-dev-brb/cypress/CYPRESS_TEACHER_2_PASSWORD | ||
CYPRESS_STUDENT_1_EMAIL: op://cy-dev-brb/cypress/CYPRESS_STUDENT_1_EMAIL | ||
CYPRESS_STUDENT_1_PASSWORD: op://cy-dev-brb/cypress/CYPRESS_STUDENT_1_PASSWORD | ||
CYPRESS_STUDENT_2_EMAIL: op://cy-dev-brb/cypress/CYPRESS_STUDENT_2_EMAIL | ||
CYPRESS_STUDENT_2_PASSWORD: op://cy-dev-brb/cypress/CYPRESS_STUDENT_2_PASSWORD | ||
CYPRESS_ADMIN_1_EMAIL: op://cy-dev-brb/cypress/CYPRESS_ADMIN_1_EMAIL | ||
CYPRESS_ADMIN_1_PASSWORD: op://cy-dev-brb/cypress/CYPRESS_ADMIN_1_PASSWORD | ||
CYPRESS_EXPERT_1_EMAIL: op://cy-dev-brb/cypress/CYPRESS_EXPERT_1_EMAIL | ||
CYPRESS_EXPERT_1_PASSWORD: op://cy-dev-brb/cypress/CYPRESS_EXPERT_1_PASSWORD | ||
CYPRESS_STUDENT_EXTERN: op://cy-dev-brb/cypress/CYPRESS_STUDENT_EXTERN | ||
CYPRESS_STUDENT_EXTERN_PASSWORD: op://cy-dev-brb/cypress/CYPRESS_STUDENT_EXTERN_PASSWORD | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_EMAIL: op://cy-dev-brb/cypress/CYPRESS_STUDENT_PASSWORD_CHANGE_EMAIL | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_OLD_PWD: op://cy-dev-brb/cypress/CYPRESS_STUDENT_PASSWORD_CHANGE_OLD_PWD | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_NEW_PWD: op://cy-dev-brb/cypress/CYPRESS_STUDENT_PASSWORD_CHANGE_NEW_PWD | ||
CYPRESS_TEACHER_1_FIRST_NAME: op://cy-dev-brb/cypress/CYPRESS_TEACHER_1_FIRST_NAME | ||
CYPRESS_TEACHER_1_LAST_NAME: op://cy-dev-brb/cypress/CYPRESS_TEACHER_1_LAST_NAME | ||
CYPRESS_TEACHER_2_FIRST_NAME: op://cy-dev-brb/cypress/CYPRESS_TEACHER_2_FIRST_NAME | ||
CYPRESS_TEACHER_2_LAST_NAME: op://cy-dev-brb/cypress/CYPRESS_TEACHER_2_LAST_NAME | ||
|
||
- name: Clean up previous report | ||
uses: cypress-io/github-action@v5 | ||
with: | ||
working-directory: e2e-system-tests | ||
command: npm run pretest | ||
|
||
- name: Cypress run | ||
uses: cypress-io/github-action@v5 | ||
with: | ||
working-directory: e2e-system-tests | ||
command: npm run ${{ steps.setting_url.outputs.tag }} | ||
browser: chrome | ||
env: | ||
CYPRESS_BRB: ${{ env.CYPRESS_BRB }} | ||
CYPRESS_NBC: ${{ env.CYPRESS_NBC }} | ||
CYPRESS_DEFAULT: ${{ env.CYPRESS_DEFAULT }} | ||
CYPRESS_TEACHER_1_EMAIL: ${{ env.CYPRESS_TEACHER_1_EMAIL }} | ||
CYPRESS_TEACHER_1_PASSWORD: ${{ env.CYPRESS_TEACHER_1_PASSWORD }} | ||
CYPRESS_TEACHER_2_EMAIL: ${{ env.CYPRESS_TEACHER_2_EMAIL }} | ||
CYPRESS_TEACHER_2_PASSWORD: ${{ env.CYPRESS_TEACHER_2_PASSWORD }} | ||
CYPRESS_STUDENT_1_EMAIL: ${{ env.CYPRESS_STUDENT_1_EMAIL }} | ||
CYPRESS_STUDENT_1_PASSWORD: ${{ env.CYPRESS_STUDENT_1_PASSWORD }} | ||
CYPRESS_STUDENT_2_EMAIL: ${{ env.CYPRESS_STUDENT_2_EMAIL }} | ||
CYPRESS_STUDENT_2_PASSWORD: ${{ env.CYPRESS_STUDENT_2_PASSWORD }} | ||
CYPRESS_ADMIN_1_EMAIL: ${{ env.CYPRESS_ADMIN_1_EMAIL }} | ||
CYPRESS_ADMIN_1_PASSWORD: ${{ env.CYPRESS_ADMIN_1_PASSWORD }} | ||
CYPRESS_EXPERT_1_EMAIL: ${{ env.CYPRESS_EXPERT_1_EMAIL }} | ||
CYPRESS_EXPERT_1_PASSWORD: ${{ env.CYPRESS_EXPERT_1_PASSWORD }} | ||
CYPRESS_STUDENT_EXTERN: ${{ env.CYPRESS_STUDENT_EXTERN }} | ||
CYPRESS_STUDENT_EXTERN_PASSWORD: ${{ env.CYPRESS_STUDENT_EXTERN_PASSWORD }} | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_EMAIL: ${{ env.CYPRESS_STUDENT_PASSWORD_CHANGE_EMAIL }} | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_OLD_PWD: ${{ env.CYPRESS_STUDENT_PASSWORD_CHANGE_OLD_PWD }} | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_NEW_PWD: ${{ env.CYPRESS_STUDENT_PASSWORD_CHANGE_NEW_PWD }} | ||
CYPRESS_TEACHER_1_FIRST_NAME: ${{ env.CYPRESS_TEACHER_1_FIRST_NAME }} | ||
CYPRESS_TEACHER_1_LAST_NAME: ${{ env.CYPRESS_TEACHER_1_LAST_NAME }} | ||
CYPRESS_TEACHER_2_FIRST_NAME: ${{ env.CYPRESS_TEACHER_2_FIRST_NAME }} | ||
CYPRESS_TEACHER_2_LAST_NAME: ${{ env.CYPRESS_TEACHER_2_LAST_NAME }} | ||
DEBUG: "@cypress/github-action" | ||
|
||
- name: Generate Report | ||
if: always() | ||
working-directory: e2e-system-tests | ||
run: | | ||
npm run generate:report | ||
- name: Upload Report | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: my-report | ||
path: ${{ github.workspace }}/e2e-system-tests/reports/ | ||
|
||
- name: Upload Video Artifact | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: my-video-artifact | ||
path: ${{ github.workspace }}/e2e-system-tests/cypress/videos/ | ||
retention-days: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,16 @@ on: | |
workflow_dispatch: | ||
inputs: | ||
instance1: | ||
description: 'Please enter a valid BRB instance URL to run the tests on' | ||
default: 'https://brb-main.cd.dbildungscloud.dev' | ||
description: "Please enter a valid BRB instance URL to run the tests on" | ||
default: "https://brb-main.cd.dbildungscloud.dev" | ||
required: true | ||
instance2: | ||
description: 'Please enter a valid NBC instance URL to run the tests on' | ||
default: 'https://nbc-main.cd.dbildungscloud.dev' | ||
description: "Please enter a valid NBC instance URL to run the tests on" | ||
default: "https://nbc-main.cd.dbildungscloud.dev" | ||
required: true | ||
instance3: | ||
description: 'Please enter a valid DEFAULT instance URL to run the tests on' | ||
default: 'https://default-main.cd.dbildungscloud.dev' | ||
description: "Please enter a valid DEFAULT instance URL to run the tests on" | ||
default: "https://default-main.cd.dbildungscloud.dev" | ||
required: true | ||
|
||
jobs: | ||
|
@@ -28,67 +28,17 @@ jobs: | |
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Clean up previous report | ||
uses: cypress-io/github-action@v5 | ||
with: | ||
command: npm run pretest | ||
|
||
- name: Cypress run | ||
uses: cypress-io/github-action@v5 | ||
env: | ||
CYPRESS_BRB: ${{ github.event.inputs.instance1 }} | ||
CYPRESS_NBC: ${{ github.event.inputs.instance2 }} | ||
CYPRESS_DEFAULT: ${{ github.event.inputs.instance3 }} | ||
CYPRESS_TEACHER_1_EMAIL: ${{ secrets.CYPRESS_TEACHER_1_EMAIL }} | ||
CYPRESS_TEACHER_1_PASSWORD: ${{ secrets.CYPRESS_TEACHER_1_PASSWORD }} | ||
CYPRESS_TEACHER_2_EMAIL: ${{ secrets.CYPRESS_TEACHER_2_EMAIL }} | ||
CYPRESS_TEACHER_2_PASSWORD: ${{ secrets.CYPRESS_TEACHER_2_PASSWORD }} | ||
CYPRESS_STUDENT_1_EMAIL: ${{ secrets.CYPRESS_STUDENT_1_EMAIL }} | ||
CYPRESS_STUDENT_1_PASSWORD: ${{ secrets.CYPRESS_STUDENT_1_PASSWORD }} | ||
CYPRESS_STUDENT_2_EMAIL: ${{ secrets.CYPRESS_STUDENT_2_EMAIL }} | ||
CYPRESS_STUDENT_2_PASSWORD: ${{ secrets.CYPRESS_STUDENT_2_PASSWORD }} | ||
CYPRESS_ADMIN_1_EMAIL: ${{ secrets.CYPRESS_ADMIN_1_EMAIL }} | ||
CYPRESS_ADMIN_1_PASSWORD: ${{ secrets.CYPRESS_ADMIN_1_PASSWORD }} | ||
CYPRESS_EXPERT_1_EMAIL: ${{ secrets.CYPRESS_EXPERT_1_EMAIL }} | ||
CYPRESS_EXPERT_1_PASSWORD": ${{ secrets.CYPRESS_EXPERT_1_PASSWORD }} | ||
CYPRESS_STUDENT_EXTERN: ${{ secrets.CYPRESS_STUDENT_EXTERN }} | ||
CYPRESS_STUDENT_EXTERN_PASSWORD: ${{ secrets.CYPRESS_STUDENT_EXTERN_PASSWORD }} | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_EMAIL: ${{ secrets.CYPRESS_STUDENT_PASSWORD_CHANGE_EMAIL }} | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_OLD_PWD: ${{ secrets.CYPRESS_STUDENT_PASSWORD_CHANGE_OLD_PWD }} | ||
CYPRESS_STUDENT_PASSWORD_CHANGE_NEW_PWD: ${{ secrets.CYPRESS_STUDENT_PASSWORD_CHANGE_NEW_PWD }} | ||
CYPRESS_TEACHER_1_FIRST_NAME: ${{ secrets.CYPRESS_TEACHER_1_FIRST_NAME }} | ||
CYPRESS_TEACHER_1_LAST_NAME: ${{ secrets.CYPRESS_TEACHER_1_LAST_NAME }} | ||
CYPRESS_TEACHER_2_FIRST_NAME: ${{ secrets.CYPRESS_TEACHER_2_FIRST_NAME }} | ||
CYPRESS_TEACHER_2_LAST_NAME: ${{ secrets.CYPRESS_TEACHER_2_LAST_NAME }} | ||
DEBUG: '@cypress/github-action' | ||
with: | ||
command: npm run tag:stable | ||
browser: chrome | ||
|
||
- name: Generate Report | ||
uses: cypress-io/github-action@v5 | ||
if: always() | ||
with: | ||
command: npm run generate:report | ||
|
||
- name: Upload Report | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: my-report | ||
path: ${{ github.workspace }}/reports | ||
|
||
- name: Upload Video Artifact | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: my-video-artifact | ||
path: ${{ github.workspace }}/cypress/videos/ | ||
retention-days: 3 | ||
configuring-loading-secrets-running-tests: | ||
needs: e2e-system-tests | ||
uses: ./.github/workflows/main.yml | ||
secrets: | ||
service-account-token: ${{ secrets.CYPRESS_ONEPWD_SERVICE_ACCOUNT_TOKEN }} | ||
|
||
notify_RC: | ||
runs-on: ubuntu-latest | ||
needs: [e2e-system-tests] | ||
needs: | ||
- e2e-system-tests | ||
- configuring-loading-secrets-running-tests | ||
if: | | ||
always() | ||
|
@@ -99,6 +49,6 @@ jobs: | |
uses: RocketChat/[email protected] | ||
with: | ||
type: ${{ env.WORKFLOW_CONCLUSION }} | ||
job_name: 'Cypress Tests' | ||
job_name: "Cypress Tests" | ||
url: ${{ secrets.RC_WEBHOOK_URL }} | ||
username: Manual Trigger Test Run |
Oops, something went wrong.