[Build] Update workflows for pr build (#1938)
authorWonYoung Choi <wy80.choi@samsung.com>
Mon, 24 Aug 2020 09:12:03 +0000 (18:12 +0900)
committerGitHub <noreply@github.com>
Mon, 24 Aug 2020 09:12:03 +0000 (18:12 +0900)
.github/branch-metadata.yml [new file with mode: 0644]
.github/workflows/build-branches.yml [new file with mode: 0644]
.github/workflows/build-pull-request.yml [new file with mode: 0644]
.github/workflows/build.yaml [deleted file]
.github/workflows/check-api-level.yml [new file with mode: 0644]
.github/workflows/postback-pull-request.yml [new file with mode: 0644]

diff --git a/.github/branch-metadata.yml b/.github/branch-metadata.yml
new file mode 100644 (file)
index 0000000..ae8f4c0
--- /dev/null
@@ -0,0 +1,29 @@
+master:
+  api-level: API8
+  labels: [ API8 ]
+  tizen-branch: tizen
+  version-prefix: 8.0.0
+
+API7:
+  api-level: API7
+  labels: [ API7 ]
+  tizen-branch: tizen_5.5
+  version-prefix: 7.0.0
+
+API6:
+  api-level: API6
+  labels: [ API6 ]
+  tizen-branch: tizen_5.5_tv
+  version-prefix: 6.0.0
+
+API5:
+  api-level: API5
+  labels: [ API5 ]
+  tizen-branch: tizen_5.0
+  version-prefix: 5.0.0
+
+API4:
+  api-level: API4
+  labels: [ API4 ]
+  tizen-branch: tizen_4.0
+  version-prefix: 4.0.1
diff --git a/.github/workflows/build-branches.yml b/.github/workflows/build-branches.yml
new file mode 100644 (file)
index 0000000..1cd9d39
--- /dev/null
@@ -0,0 +1,28 @@
+name: Build Branches
+
+on:
+  push:
+    branches:
+    - master
+    - API*
+
+    paths:
+    - 'build/**'
+    - 'internals/**'
+    - 'src/**'
+    - 'tools/**'
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Setup .NET Core
+      uses: actions/setup-dotnet@v1
+      with:
+        dotnet-version: 3.1.x
+
+    - name: Build
+      run: ./build.sh full
+
diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml
new file mode 100644 (file)
index 0000000..2b83fe8
--- /dev/null
@@ -0,0 +1,110 @@
+name: "Build Pull Request"
+
+on:
+  pull_request:
+    branches:
+    - master
+    - API*
+
+jobs:
+
+  build:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Setup .NET Core
+      uses: actions/setup-dotnet@v1
+      with:
+        dotnet-version: 3.1.x
+
+    - name: Get Changed Files
+      uses: lots0logs/gh-action-get-changed-files@2.1.4
+      id: getChangedFiles
+      with:
+        token: ${{ secrets.GITHUB_TOKEN }}
+
+    - name: Build
+      id: build
+      uses: TizenAPI/tizenfx-build-actions/problem-filter@master
+      with:
+        run: ./build.sh full /p:BuildWithAnalyzer=True -consoleloggerparameters:NoSummary
+        files: ${{ steps.getChangedFiles.outputs.all }}
+
+    - name: Save Error Report
+      if: ${{ failure() && steps.build.outputs.errors }}
+      env:
+        BUILD_ERRORS: ${{ steps.build.outputs.errors }}
+      run: |
+        mkdir Artifacts
+        echo $BUILD_ERRORS > Artifacts/errors.json
+
+    - name: Pack
+      run: ./build.sh pack
+
+    - name: Checkout APITool
+      uses: actions/checkout@v2
+      with:
+        repository: TizenAPI/APITool
+        path: .apitool
+
+    - name: Extract API
+      run: |
+        dotnet run -p .apitool/ \
+            -- print --format=json --include-hidden \
+            -o Artifacts/api.json Artifacts/bin/public/
+
+    - uses: actions/upload-artifact@v2
+      if: ${{ always() }}
+      with:
+        name: reports
+        if-no-files-found: ignore
+        path: Artifacts/*.json
+
+  check-api:
+    needs: [build]
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+      with:
+        ref: ${{ github.base_ref }}
+
+    - name: Setup .NET Core
+      uses: actions/setup-dotnet@v1
+      with:
+        dotnet-version: 3.1.x
+
+    - name: Build Base Branch
+      uses: TizenAPI/tizenfx-build-actions/problem-filter@master
+      with:
+        run: ./build.sh full
+
+    - name: Checkout APITool
+      uses: actions/checkout@v2
+      with:
+        repository: TizenAPI/APITool
+        path: .apitool
+
+    - name: Extract Base API
+      run: |
+        dotnet run -p .apitool/ \
+            -- print --format=json --include-hidden \
+            -o Artifacts/base-api.json Artifacts/bin/public/
+
+    - name: Download Artifacts
+      uses: actions/download-artifact@v2
+      with:
+        name: reports
+        path: Artifacts
+
+    - name: Check API Compatibilities
+      uses: TizenAPI/tizenfx-build-actions/apidb-compare@master
+      with:
+        file: Artifacts/api.json
+        base-file: Artifacts/base-api.json
+        output: Artifacts/api-comp.json
+
+    - uses: actions/upload-artifact@v2
+      with:
+        name: reports
+        path: Artifacts/api-comp.json
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
deleted file mode 100644 (file)
index 843a35c..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-name: Build
-
-on:
-  pull_request:
-    branches:
-    - master
-    - API*
-
-  push:
-    branches:
-    - master
-    - API*
-    paths:
-    - 'build/**'
-    - 'internals/**'
-    - 'src/**'
-    - 'tools/**'
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-
-    - name: Setup .NET Core
-      uses: actions/setup-dotnet@v1
-      with:
-        dotnet-version: 3.1.x
-
-    - uses: lots0logs/gh-action-get-changed-files@2.1.4
-      id: getChangedFiles
-      with:
-        token: ${{ secrets.GITHUB_TOKEN }}
-
-    - name: Build
-      uses: TizenAPI/tizenfx-build-actions/problem-filter@v1
-      with:
-        run: ./build.sh full /p:BuildWithAnalyzer=True
-        files: ${{ steps.getChangedFiles.outputs.all }}
diff --git a/.github/workflows/check-api-level.yml b/.github/workflows/check-api-level.yml
new file mode 100644 (file)
index 0000000..7232766
--- /dev/null
@@ -0,0 +1,33 @@
+name: "Check API Level"
+
+on:
+  pull_request_target:
+    branches:
+    - master
+    - API*
+
+jobs:
+  add-labels:
+    runs-on: ubuntu-latest
+    steps:
+
+    - name: Get Branch Metadata
+      uses: TizenAPI/tizenfx-build-actions/branch-metadata@master
+      id: metadata
+      with:
+        ref: ${{ github.base_ref }}
+
+    - name: Add Labels
+      if: ${{ steps.metadata.outputs.data }}
+      uses: actions/github-script@v2
+      env:
+        BRANCH_METADATA: ${{ steps.metadata.outputs.data }}
+      with:
+        script: |
+          var metadata = JSON.parse(process.env.BRANCH_METADATA)
+          github.issues.addLabels({
+            issue_number: context.issue.number,
+            owner: context.repo.owner,
+            repo: context.repo.repo,
+            labels: metadata.labels
+          })
diff --git a/.github/workflows/postback-pull-request.yml b/.github/workflows/postback-pull-request.yml
new file mode 100644 (file)
index 0000000..2e20e2f
--- /dev/null
@@ -0,0 +1,66 @@
+name: "Postback Pull Request"
+
+on:
+  workflow_run:
+    workflows: ["Build Pull Request"]
+    types:
+      - completed
+
+jobs:
+  postback:
+    runs-on: ubuntu-latest
+    steps:
+
+    - name: Download Artifacts from Build
+      uses: TizenAPI/tizenfx-build-actions/download-workflow-artifacts@master
+      with:
+        token: ${{ secrets.TIZENAPI_GITHUB_TOKEN }}
+        run-id: ${{ github.event.workflow_run.id }}
+        name: reports
+        path: Artifacts
+
+    - name: Find Pull Request
+      id: pull_request
+      uses: actions/github-script@v2
+      env:
+        WORKFLOW_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
+      with:
+        script: |
+          const res = await github.pulls.list({
+            owner: context.repo.owner,
+            repo: context.repo.repo,
+            state: 'open'
+          });
+          if (res.status === 200) {
+            const pr = res.data.find(d => d.head.sha == process.env.WORKFLOW_HEAD_SHA);
+            if (pr) {
+              core.setOutput('number', pr.number);
+              core.setOutput('base_ref', pr.base.ref);
+            }
+          }
+
+    - name: Report Error if Failure
+      if: ${{ github.event.workflow_run.conclusion == 'failure' }}
+      uses: actions/github-script@v2
+      env:
+        PR_NUMBER: ${{ steps.pull_request.outputs.number }}
+      with:
+        github-token: ${{ secrets.TIZENAPI_GITHUB_TOKEN }}
+        script: |
+          const fs = require('fs');
+          const json = fs.readFileSync('Artifacts/errors.json', 'utf8');
+          const errors = JSON.parse(json).join('\n');
+          github.issues.createComment({
+            issue_number: process.env.PR_NUMBER,
+            owner: context.repo.owner,
+            repo: context.repo.repo,
+            body: '## Build Error:\n```\n' + errors + '\n```'
+          });
+
+    - name: Report API comparison result
+      if: ${{ github.event.workflow_run.conclusion == 'success' }}
+      uses: TizenAPI/tizenfx-build-actions/apidb-report@master
+      with:
+        token: ${{ secrets.TIZENAPI_GITHUB_TOKEN }}
+        issue-number: ${{ steps.pull_request.outputs.number }}
+        path: Artifacts/api-comp.json