d-g-town 2 роки тому
батько
коміт
a3d3ca2f7c

+ 59 - 0
.github/workflows/app_tests_base.yml

@@ -0,0 +1,59 @@
+on:
+  workflow_call:
+    inputs:
+      stage:
+        required: true
+        type: string
+      project:
+        required: true
+        type: string
+      cluster:
+        required: true
+        type: string
+      host:
+        required: true
+        type: string
+    secrets:
+      token:
+        required: true
+      slack_webhook_url:
+        required: true
+
+env:
+  repo: porter
+
+name: Run app tests
+jobs:
+  integration-tests:
+    name: Run app tests
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        yaml: ['js-test-app-buildpack', 'js-test-app-dockerfile', 'nginx', 'next-test-app-dockerfile']
+      fail-fast: false
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+        with:
+          repository: porter-dev/app-integration-tests
+          ref: refs/heads/main
+      - name: Run test
+        uses: ./.github/actions
+        with:
+          host: ${{ inputs.host }}
+          project: ${{ inputs.project }}
+          cluster: ${{ inputs.cluster }}
+          token: ${{ secrets.token }}
+          yaml_file: ./test-yamls/${{ matrix.yaml }}.yaml
+          app_name: ${{ env.repo }}-${{ matrix.yaml }}
+  notify-on-failure:
+    name: Notify on failure
+    needs: integration-tests
+    runs-on: ubuntu-latest
+    if: failure()
+    steps:
+      - name: Notify Slack on failure
+        env:
+          RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+        run: |
+          curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"<!subteam^S05LXJ5DU9L> \`${{ env.repo }}\` integration tests failed in \`${{ inputs.STAGE }}\`: $RUN_URL \"}" ${{ secrets.slack_webhook_url }}

+ 10 - 42
.github/workflows/app_tests_internal_tools.yml

@@ -4,48 +4,16 @@ on:
     branches: [master]
     branches: [master]
     types:
     types:
       - completed
       - completed
-env:
-  REPO: porter
-  STAGE: internal-tools
-  PROJECT: "301"
-  CLUSTER: "142"
-  HOST: https://dashboard.internal-tools.porter.run
-  TOKEN: ${{ secrets.APP_INTEGRATION_PROJECT_TOKEN }}
-  SLACK_WEBHOOK_URL: ${{ secrets.APP_INTEGRATION_SLACK_WEBHOOK }}
 
 
 name: Run internal tools app tests
 name: Run internal tools app tests
 jobs:
 jobs:
-  integration-tests:
-    name: Run app tests
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        yaml: ['js-test-app-buildpack', 'js-test-app-dockerfile', 'nginx', 'next-test-app-dockerfile']
-      fail-fast: false
-    steps:
-      - name: Checkout code
-        uses: actions/checkout@v4
-        with:
-          repository: porter-dev/app-integration-tests
-          ref: refs/heads/main
-      - name: Run test
-        uses: ./.github/actions
-        with:
-          host: $HOST
-          project: $PROJECT
-          cluster: $CLUSTER
-          token: $TOKEN
-          yaml_file: ./test-yamls/${{ matrix.yaml }}.yaml
-          app_name: $REPO-${{ matrix.yaml }}
-  notify-on-failure:
-    name: Notify on failure
-    needs: integration-tests
-    runs-on: ubuntu-latest
-    if: failure()
-    steps:
-      - name: Notify Slack on failure
-        env:
-          SLACK_WEBHOOK_URL: $SLACK_WEBHOOK_URL
-          RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
-        run: |
-          curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"<!subteam^S05LXJ5DU9L> \`$REPO\` integration tests failed in \`$STAGE\`: $RUN_URL \"}" $SLACK_WEBHOOK_URL
+  call-base-workflow:
+    uses: ./.github/workflows/app_tests_base.yml
+    with:
+      stage: internal-tools
+      project: "301"
+      cluster: "142"
+      host: https://dashboard.internal-tools.porter.run
+    secrets:
+      token: ${{ secrets.APP_INTEGRATION_PROJECT_TOKEN }}
+      slack_webhook_url: ${{ secrets.APP_INTEGRATION_SLACK_WEBHOOK }}

+ 10 - 43
.github/workflows/app_tests_production.yml

@@ -5,48 +5,15 @@ on:
     types:
     types:
       - completed
       - completed
 
 
-env:
-  REPO: porter
-  STAGE: production
-  PROJECT: "11646"
-  CLUSTER: "3618"
-  HOST: https://dashboard.getporter.dev
-  TOKEN: ${{ secrets.APP_TESTS_PRODUCTION_TOKEN }}
-  SLACK_WEBHOOK_URL: ${{ secrets.APP_INTEGRATION_SLACK_WEBHOOK }}
-
 name: Run production app tests
 name: Run production app tests
 jobs:
 jobs:
-  integration-tests:
-    name: Run app tests
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        yaml: ['js-test-app-buildpack', 'js-test-app-dockerfile', 'nginx', 'next-test-app-dockerfile']
-      fail-fast: false
-    steps:
-      - name: Checkout code
-        uses: actions/checkout@v4
-        with:
-          repository: porter-dev/app-integration-tests
-          ref: refs/heads/main
-      - name: Run test
-        uses: ./.github/actions
-        with:
-          host: $HOST
-          project: $PROJECT
-          cluster: $CLUSTER
-          token: $TOKEN
-          yaml_file: ./test-yamls/${{ matrix.yaml }}.yaml
-          app_name: $REPO-${{ matrix.yaml }}
-  notify-on-failure:
-    name: Notify on failure
-    needs: integration-tests
-    runs-on: ubuntu-latest
-    if: failure()
-    steps:
-      - name: Notify Slack on failure
-        env:
-          SLACK_WEBHOOK_URL: $SLACK_WEBHOOK_URL
-          RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
-        run: |
-          curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"<!subteam^S05LXJ5DU9L> \`$REPO\` integration tests failed in \`$STAGE\`: $RUN_URL \"}" $SLACK_WEBHOOK_URL
+  call-base-workflow:
+    uses: ./.github/workflows/app_tests_base.yml
+    with:
+      stage: production
+      project: "11646"
+      cluster: "3618"
+      host: https://dashboard.getporter.dev
+    secrets:
+      token: ${{ secrets.APP_TESTS_PRODUCTION_TOKEN }}
+      slack_webhook_url: ${{ secrets.APP_INTEGRATION_SLACK_WEBHOOK }}

+ 10 - 43
.github/workflows/app_tests_sandbox.yml

@@ -5,48 +5,15 @@ on:
     types:
     types:
       - completed
       - completed
 
 
-env:
-  REPO: porter
-  STAGE: sandbox
-  PROJECT: "242"
-  CLUSTER: "240"
-  HOST: https://sandbox.porter.run
-  TOKEN: ${{ secrets.APP_TESTS_SANDBOX_TOKEN }}
-  SLACK_WEBHOOK_URL: ${{ secrets.APP_INTEGRATION_SLACK_WEBHOOK }}
-
 name: Run sandbox app tests
 name: Run sandbox app tests
 jobs:
 jobs:
-  integration-tests:
-    name: Run app tests
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        yaml: ['js-test-app-buildpack', 'js-test-app-dockerfile', 'nginx', 'next-test-app-dockerfile']
-      fail-fast: false
-    steps:
-      - name: Checkout code
-        uses: actions/checkout@v4
-        with:
-          repository: porter-dev/app-integration-tests
-          ref: refs/heads/main
-      - name: Run test
-        uses: ./.github/actions
-        with:
-          host: $HOST
-          project: $PROJECT
-          cluster: $CLUSTER
-          token: $TOKEN
-          yaml_file: ./test-yamls/${{ matrix.yaml }}.yaml
-          app_name: $REPO-${{ matrix.yaml }}
-  notify-on-failure:
-    name: Notify on failure
-    needs: integration-tests
-    runs-on: ubuntu-latest
-    if: failure()
-    steps:
-      - name: Notify Slack on failure
-        env:
-          SLACK_WEBHOOK_URL: $SLACK_WEBHOOK_URL
-          RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
-        run: |
-          curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"<!subteam^S05LXJ5DU9L> \`$REPO\` integration tests failed in \`$STAGE\`: $RUN_URL \"}" $SLACK_WEBHOOK_URL
+  call-base-workflow:
+    uses: ./.github/workflows/app_tests_base.yml
+    with:
+      stage: sandbox
+      project: "242"
+      cluster: "240"
+      host: https://sandbox.porter.run
+    secrets:
+      token: ${{ secrets.APP_TESTS_SANDBOX_TOKEN }}
+      slack_webhook_url: ${{ secrets.APP_INTEGRATION_SLACK_WEBHOOK }}