All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 4/6] coverity: support building on Windows
Date: Fri, 22 Sep 2023 10:42:01 +0000	[thread overview]
Message-ID: <14cdefff08244f9b5e2ee1fa2a78cfd3e58c14d2.1695379323.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1588.git.1695379323.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

By adding the repository variable `ENABLE_COVERITY_SCAN_ON_OS` with a
value, say, `["windows-latest"]`, this GitHub workflow now runs on
Windows, allowing to analyze Windows-specific issues.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .github/workflows/coverity.yml | 56 ++++++++++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 8aac00bb20f..70ba3f97c18 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -12,31 +12,61 @@ name: Coverity
 # email to which the Coverity reports should be sent and the latter can be
 # obtained from the Project Settings tab of the Coverity project).
 #
+# The workflow runs on `ubuntu-latest` by default. This can be overridden by setting
+# the repository variable `ENABLE_COVERITY_SCAN_ON_OS` to a JSON string array specifying
+# the operating systems, e.g. `["ubuntu-latest", "windows-latest"]`.
+#
 # By default, the builds are submitted to the Coverity project `git`. To override this,
 # set the repository variable `COVERITY_PROJECT`.
 
 on:
   push:
 
+defaults:
+  run:
+    shell: bash
+
 jobs:
   coverity:
     if: contains(fromJSON(vars.ENABLE_COVERITY_SCAN_FOR_BRANCHES || '[""]'), github.ref_name)
-    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        os: ${{ fromJSON(vars.ENABLE_COVERITY_SCAN_ON_OS || '["ubuntu-latest"]') }}
+    runs-on: ${{ matrix.os }}
     env:
       COVERITY_PROJECT: ${{ vars.COVERITY_PROJECT || 'git' }}
       COVERITY_LANGUAGE: cxx
-      COVERITY_PLATFORM: linux64
     steps:
       - uses: actions/checkout@v3
+      - name: install minimal Git for Windows SDK
+        if: contains(matrix.os, 'windows')
+        uses: git-for-windows/setup-git-for-windows-sdk@v1
       - run: ci/install-dependencies.sh
+        if: contains(matrix.os, 'ubuntu')
         env:
-          runs_on_pool: ubuntu-latest
+          runs_on_pool: ${{ matrix.os }}
 
       # The Coverity site says the tool is usually updated twice yearly, so the
       # MD5 of download can be used to determine whether there's been an update.
       - name: get the Coverity Build Tool hash
         id: lookup
         run: |
+          case "${{ matrix.os }}" in
+          *windows*)
+            COVERITY_PLATFORM=win64
+            COVERITY_TOOL_FILENAME=cov-analysis.zip
+            ;;
+          *ubuntu*)
+            COVERITY_PLATFORM=linux64
+            COVERITY_TOOL_FILENAME=cov-analysis.tgz
+            ;;
+          *)
+            echo '::error::unhandled OS ${{ matrix.os }}' >&2
+            exit 1
+            ;;
+          esac
+          echo "COVERITY_PLATFORM=$COVERITY_PLATFORM" >>$GITHUB_ENV
+          echo "COVERITY_TOOL_FILENAME=$COVERITY_TOOL_FILENAME" >>$GITHUB_ENV
           MD5=$(curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
                    --data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=$COVERITY_PROJECT&md5=1")
           echo "hash=$MD5" >>$GITHUB_OUTPUT
@@ -54,13 +84,27 @@ jobs:
         run: |
           curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
             --no-progress-meter \
-            --output $RUNNER_TEMP/cov-analysis.tgz \
+            --output $RUNNER_TEMP/$COVERITY_TOOL_FILENAME \
             --data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=$COVERITY_PROJECT"
       - name: extract the Coverity Build Tool
         if: steps.cache.outputs.cache-hit != 'true'
         run: |
-          mkdir $RUNNER_TEMP/cov-analysis &&
-          tar -xzf $RUNNER_TEMP/cov-analysis.tgz --strip 1 -C $RUNNER_TEMP/cov-analysis
+          case "$COVERITY_TOOL_FILENAME" in
+          *.tgz)
+            mkdir $RUNNER_TEMP/cov-analysis &&
+            tar -xzf $RUNNER_TEMP/$COVERITY_TOOL_FILENAME --strip 1 -C $RUNNER_TEMP/cov-analysis
+            ;;
+          *.zip)
+            cd $RUNNER_TEMP &&
+            mkdir cov-analysis-tmp &&
+            unzip -d cov-analysis-tmp $COVERITY_TOOL_FILENAME &&
+            mv cov-analysis-tmp/* cov-analysis
+            ;;
+          *)
+            echo "::error::unhandled archive type: $COVERITY_TOOL_FILENAME" >&2
+            exit 1
+            ;;
+          esac
       - name: cache the Coverity Build Tool
         if: steps.cache.outputs.cache-hit != 'true'
         uses: actions/cache/save@v3
-- 
gitgitgadget


  parent reply	other threads:[~2023-09-22 10:42 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 10:41 [PATCH 0/6] Add a GitHub workflow to submit builds to Coverity Scan Johannes Schindelin via GitGitGadget
2023-09-22 10:41 ` [PATCH 1/6] ci: add a GitHub workflow to submit Coverity scans Johannes Schindelin via GitGitGadget
2023-09-23  6:49   ` Jeff King
2023-09-25 11:52     ` Johannes Schindelin
2023-09-25 12:09       ` Jeff King
2023-09-22 10:41 ` [PATCH 2/6] coverity: cache the Coverity Build Tool Johannes Schindelin via GitGitGadget
2023-09-23  6:58   ` Jeff King
2023-09-25 11:52     ` Johannes Schindelin
2023-09-22 10:42 ` [PATCH 3/6] coverity: allow overriding the Coverity project Johannes Schindelin via GitGitGadget
2023-09-23  7:00   ` Jeff King
2023-09-25 11:52     ` Johannes Schindelin
2023-09-25 12:11       ` Jeff King
2023-09-26 14:02         ` Johannes Schindelin
2023-09-26 14:19           ` Junio C Hamano
2023-09-26 14:39             ` Jeff King
2023-09-26 16:50               ` Junio C Hamano
2023-09-26 14:45           ` Jeff King
2023-09-22 10:42 ` Johannes Schindelin via GitGitGadget [this message]
2023-09-23  7:03   ` [PATCH 4/6] coverity: support building on Windows Jeff King
2023-09-22 10:42 ` [PATCH 5/6] coverity: allow running on macOS Johannes Schindelin via GitGitGadget
2023-09-23  7:06   ` Jeff King
2023-09-25 11:52     ` Johannes Schindelin
2023-09-25 12:13       ` Jeff King
2023-09-22 10:42 ` [PATCH 6/6] coverity: detect and report when the token or project is incorrect Johannes Schindelin via GitGitGadget
2023-09-23  7:07   ` Jeff King
2023-09-25 11:52     ` Johannes Schindelin
2023-09-25 12:17       ` Jeff King
2023-09-25 11:50 ` [PATCH v2 0/6] Add a GitHub workflow to submit builds to Coverity Scan Johannes Schindelin via GitGitGadget
2023-09-25 11:50   ` [PATCH v2 1/6] ci: add a GitHub workflow to submit Coverity scans Johannes Schindelin via GitGitGadget
2023-09-25 11:50   ` [PATCH v2 2/6] coverity: cache the Coverity Build Tool Johannes Schindelin via GitGitGadget
2023-09-25 11:50   ` [PATCH v2 3/6] coverity: allow overriding the Coverity project Johannes Schindelin via GitGitGadget
2023-09-25 11:51   ` [PATCH v2 4/6] coverity: support building on Windows Johannes Schindelin via GitGitGadget
2023-09-25 11:51   ` [PATCH v2 5/6] coverity: allow running on macOS Johannes Schindelin via GitGitGadget
2023-09-25 11:51   ` [PATCH v2 6/6] coverity: detect and report when the token or project is incorrect Johannes Schindelin via GitGitGadget
2023-09-25 12:25   ` [PATCH v2 0/6] Add a GitHub workflow to submit builds to Coverity Scan Jeff King
2023-09-25 17:20   ` Junio C Hamano
2023-09-26 13:57     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14cdefff08244f9b5e2ee1fa2a78cfd3e58c14d2.1695379323.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.