Jelajahi Sumber

Merge pull request #458 from docker/optional_ci_tests

CI : Optional tests for ACI / Windows
Guillaume Tardif 5 tahun lalu
induk
melakukan
37a547de59
2 mengubah file dengan 32 tambahan dan 1 penghapusan
  1. 7 1
      .github/PULL_REQUEST_TEMPLATE.md
  2. 25 0
      .github/workflows/optional-ci.yml

+ 7 - 1
.github/PULL_REQUEST_TEMPLATE.md

@@ -1,6 +1,12 @@
 **What I did**
 **What I did**
 
 
 **Related issue**
 **Related issue**
-<-- If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" -->
+<!-- If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" -->
+
+<!-- optional tests
+You can add a @ mention to run tests executed by default only on main branch : 
+* `test-aci` to run ACI E2E tests
+* `test-windows` to run tests & E2E tests on windows
+-->
 
 
 **(not mandatory) A picture of a cute animal, if possible in relation with what you did**
 **(not mandatory) A picture of a cute animal, if possible in relation with what you did**

+ 25 - 0
.github/workflows/main-ci.yml → .github/workflows/optional-ci.yml

@@ -4,13 +4,36 @@ on:
   push:
   push:
     branches:
     branches:
       - main
       - main
+  pull_request:
 
 
 jobs:
 jobs:
+  check-optional-tests:
+    name: Check if needs to run ACI or Windows tests
+    runs-on: ubuntu-latest
+    outputs:
+      trigger-aci: ${{steps.runacitest.outputs.triggered}}
+      trigger-windows: ${{steps.runwindowstest.outputs.triggered}}
+    steps:
+      - uses: khan/pull-request-comment-trigger@master
+        name: Check if test ACI
+        if: github.event_name == 'pull_request'
+        id: runacitest
+        with:
+          trigger: '@test-aci'
+      - uses: khan/pull-request-comment-trigger@master
+        name: Check if test Windows
+        if: github.event_name == 'pull_request'
+        id: runwindowstest
+        with:
+          trigger: '@test-windows'
+
   build:
   build:
     name: ACI e2e tests
     name: ACI e2e tests
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     env:
     env:
       GO111MODULE: "on"
       GO111MODULE: "on"
+    needs: check-optional-tests
+    if: github.ref == 'refs/heads/main' || needs.check-optional-tests.outputs.trigger-aci == 'true'
     steps:
     steps:
       - name: Set up Go 1.14
       - name: Set up Go 1.14
         uses: actions/setup-go@v1
         uses: actions/setup-go@v1
@@ -41,6 +64,8 @@ jobs:
     runs-on: windows-latest
     runs-on: windows-latest
     env:
     env:
       GO111MODULE: "on"
       GO111MODULE: "on"
+    needs: check-optional-tests
+    if: github.ref == 'refs/heads/main' || needs.check-optional-tests.outputs.trigger-windows == 'true'
     steps:
     steps:
       - name: Set up Go 1.14
       - name: Set up Go 1.14
         uses: actions/setup-go@v1
         uses: actions/setup-go@v1