From 13e6ba4360e9b7fda36b01c7f4490c205b06d180 Mon Sep 17 00:00:00 2001 From: Freedisch Date: Thu, 27 Jul 2023 19:49:55 +0300 Subject: [PATCH] code_refactor Signed-off-by: Freedisch --- action.yml | 55 ++++++++++--------------------------------- cypress-artifacts.yml | 11 +++++++++ cypress-ss.yml | 24 +++++++++++++++++++ cypress.yml | 28 ++++++++++++++++++++++ token-provider.sh | 12 ++++++++++ 5 files changed, 88 insertions(+), 42 deletions(-) create mode 100644 cypress-artifacts.yml create mode 100644 cypress-ss.yml create mode 100644 cypress.yml create mode 100644 token-provider.sh diff --git a/action.yml b/action.yml index e9e2a8b..843cebf 100644 --- a/action.yml +++ b/action.yml @@ -1,12 +1,12 @@ -name: 'MeshMap-Snapshot' -description: 'Walks in application and takes a shot of your infrastructure using Meshery Extension MeshMap' +name: "MeshMap-Snapshot" +description: "Walks in application and takes a shot of your infrastructure using Meshery Extension MeshMap" author: Layer5 inputs: - designId: # id of input #deprecated + designId: # id of input #deprecated description: "The design uuid, example: 3c116d0a-49ea-4294-addc-d9ab34210662" required: false - default: '{}' - applicationId: #deprecated + default: "{}" + applicationId: #deprecated description: "The application uuid, example: 3c116d0a-49ea-4294-addc-d9ab34210662" required: false githubToken: @@ -19,7 +19,7 @@ inputs: description: "The Pull request on which comment has to be made" required: false default: 0 - filePath: + filePath: description: "The relative filepath of the location where the manifests are stored" required: false application_type: @@ -30,7 +30,7 @@ inputs: required: false outputs: mardownResult: # id of output - description: 'The markdown result' + description: "The markdown result" runs: using: "composite" steps: @@ -56,7 +56,7 @@ runs: cluster_name: "kind-cluster" - run: echo ${{ steps.ping-playground.outputs.IS_PLAYGROUND_RUNNING }} shell: bash - - run: + - run: working-directory: action/cypress-action/ if: ${{ !steps.ping-playground.outputs.IS_PLAYGROUND_RUNNING }} shell: bash @@ -78,35 +78,16 @@ runs: - run: echo $APPLICATION_ID && echo ${{env.APPLICATION_ID}} shell: bash - name: Cypress run - uses: cypress-io/github-action@v4 - with: - working-directory: action/cypress-action - spec: cypress/e2e/e2e/**/* - browser: chrome - # record: true - env: - GITHUB_TOKEN: ${{ inputs.githubToken }} - CYPRESS_token: ${{ inputs.providerToken }} - CYPRESS_releasetag: ${{env.tag}} - CYPRESS_applicationId: ${{ env.APPLICATION_ID }} - # CYPRESS_RECORD_KEY: ${{ inputs.cypressRecordKey }} + uses: action/cypress-job #reference to cypress workflow - run: ls shell: bash - run: tree action/cypress-action/cypress/ -L 2me shell: bash - name: Upload Cypress artifacts - if: always() - uses: actions/upload-artifact@v3 - with: - name: cypress-ss - path: action/cypress-action/cypress/videos + uses: cypress-ss - name: Upload Cypress artifacts - if: always() - uses: actions/upload-artifact@v3 - with: - name: cypress-ss - path: action/cypress-action/cypress/screenshots - - run: echo "SCREENSHOT_NAME=$(ls)" >> $GITHUB_ENV # Assumption: There is only one screenshot in the download directory + uses: cypress-artifacts + - run: echo "SCREENSHOT_NAME=$(ls)" >> $GITHUB_ENV # Assumption: There is only one screenshot in the download directory working-directory: action/cypress-action/cypress/downloads shell: bash - run: mv "$SCREENSHOT_NAME" screenshot.png @@ -117,17 +98,7 @@ runs: - run: npm ci working-directory: action/node-file-upload shell: bash - - run: | - PROVIDER_TOKEN=${{inputs.providerToken}} node node-file-upload/index.js > __fileResponse.txt - outputstr=$(head -n 1 __fileResponse.txt) - required_string="https" - echo $outputstr - - if [[ "$outputstr" == "$required_string"* ]]; then - echo "RESOURCE_URL=$outputstr" >> $GITHUB_ENV - else - echo "RESOURCE_URL=false" >> $GITHUB_ENV - fi + - run: ./token-provider.sh working-directory: action/ shell: bash - name: Comment Success Status diff --git a/cypress-artifacts.yml b/cypress-artifacts.yml new file mode 100644 index 0000000..881b12e --- /dev/null +++ b/cypress-artifacts.yml @@ -0,0 +1,11 @@ +name: cypress-artifacts + +on: + pull_request_target: + types: [opened, synchronize, reopened] +jobs: + cypress-artifacts: + runs-on: ubuntu-latest + + steps: + diff --git a/cypress-ss.yml b/cypress-ss.yml new file mode 100644 index 0000000..4ed186a --- /dev/null +++ b/cypress-ss.yml @@ -0,0 +1,24 @@ +name: Cypress-ss + +on: + pull_request_target: + types: [opened, synchronize, reopened] + +jobs: + cypress-ss: + runs-on: ubuntu-latest + + steps: + - name: Upload Cypress artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: cypress-ss + path: action/cypress-action/cypress/videos + + - name: Upload Cypress artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: cypress-ss + path: action/cypress-action/cypress/screenshots \ No newline at end of file diff --git a/cypress.yml b/cypress.yml new file mode 100644 index 0000000..00042ee --- /dev/null +++ b/cypress.yml @@ -0,0 +1,28 @@ +name: Cypress Run Workflow + +on: + pull_request_target: + types: [opened, synchronize, reopened] +jobs: + cypress-job: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Cypress run + uses: cypress-io/github-action@v4 + with: + working-directory: action/cypress-action + spec: cypress/e2e/e2e/**/* + browser: chrome + # record: true + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + CYPRESS_token: ${{ inputs.providerToken }} + CYPRESS_releasetag: ${{env.tag}} + CYPRESS_applicationId: ${{ env.APPLICATION_ID }} + # CYPRESS_RECORD_KEY: ${{ inputs.cypressRecordKey }} + + \ No newline at end of file diff --git a/token-provider.sh b/token-provider.sh new file mode 100644 index 0000000..193d1a1 --- /dev/null +++ b/token-provider.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +PROVIDER_TOKEN=${{inputs.providerToken}} node node-file-upload/index.js > __fileResponse.txt + outputstr=$(head -n 1 __fileResponse.txt) + required_string="https" + echo $outputstr + + if [[ "$outputstr" == "$required_string"* ]]; then + echo "RESOURCE_URL=$outputstr" >> $GITHUB_ENV + else + echo "RESOURCE_URL=false" >> $GITHUB_ENV + fi \ No newline at end of file