Просмотр исходного кода

Fix tests.yaml to execute tests when there's a mix of code and ignored files. (#3472)

Fix an error in tests.yaml where tests wouldn't be run if *any* file was
ignored. Instead, only skip tests if *all* files are ignored.

Example run:
https://github.com/carbon-language/carbon-lang/actions/runs/7132705321/job/19423815707
Jon Ross-Perkins 2 лет назад
Родитель
Сommit
226b653e11
2 измененных файлов с 32 добавлено и 25 удалено
  1. 16 0
      .github/workflows/README.md
  2. 16 25
      .github/workflows/tests.yaml

+ 16 - 0
.github/workflows/README.md

@@ -0,0 +1,16 @@
+# Testing workflows
+
+<!--
+Part of the Carbon Language project, under the Apache License v2.0 with LLVM
+Exceptions. See /LICENSE for license information.
+SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+-->
+
+We keep around an `action-test` branch in carbon-lang, which can be used to test
+triggers with `push:` configurations. For example:
+
+```
+on:
+  push:
+    branches: [action-test]
+```

+ 16 - 25
.github/workflows/tests.yaml

@@ -62,29 +62,22 @@ jobs:
         uses: dorny/paths-filter@v2
         with:
           filters: |
-            ignore:
-              - '**/*.md'
-              - 'LICENSE'
-              - 'CODEOWNERS'
-              - '.git*'
+            has_code:
+              - '!{**/*.md,LICENSE,CODEOWNERS,.git*}'
 
       # Setup Python and related tools.
       - uses: actions/setup-python@v4
-        if: steps.filter.outputs.ignore == 'false'
+        if: steps.filter.outputs.has_code == 'true'
         with:
           # Match the min version listed in docs/project/contribution_tools.md
           python-version: '3.9'
 
       # Use LLVM following:
       # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
-      # Both 14 and 15 are candidates because GitHub is testing new images.
       - name: Setup LLVM and Clang (macOS)
-        if: steps.filter.outputs.ignore == 'false' && matrix.os == 'macos-12'
+        if: steps.filter.outputs.has_code == 'true' && matrix.os == 'macos-12'
         run: |
           LLVM_PATH="$(brew --prefix llvm@15)"
-          if [[ ! -e "${LLVM_PATH}" ]]; then
-            LLVM_PATH="$(brew --prefix llvm@14)"
-          fi
           echo "Using ${LLVM_PATH}"
           echo "${LLVM_PATH}/bin" >> $GITHUB_PATH
           echo '*** ls "${LLVM_PATH}"'
@@ -94,11 +87,9 @@ jobs:
 
       # Use LLVM following:
       # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
-      # Both 14 and 15 are candidates for forwards compatibility, although 15
-      # isn't provided.
       - name: Setup LLVM and Clang (Ubuntu)
         if:
-          steps.filter.outputs.ignore == 'false' && matrix.os == 'ubuntu-22.04'
+          steps.filter.outputs.has_code == 'true' && matrix.os == 'ubuntu-22.04'
         run: |
           # TODO: Re-enable once llvm-15 is working.
           # https://github.com/actions/runner-images/issues/8253
@@ -115,7 +106,7 @@ jobs:
 
       # Print the various tool paths and versions to help in debugging.
       - name: Print tool debugging info
-        if: steps.filter.outputs.ignore == 'false'
+        if: steps.filter.outputs.has_code == 'true'
         run: |
           echo '*** PATH'
           echo $PATH
@@ -135,7 +126,7 @@ jobs:
       # Disable uploads when the remote cache is read-only.
       - name: Set up remote cache access (read-only)
         if:
-          steps.filter.outputs.ignore == 'false' && github.event_name ==
+          steps.filter.outputs.has_code == 'true' && github.event_name ==
           'pull_request'
         run: |
           echo "remote_cache_upload=--remote_upload_local_results=false" \
@@ -144,7 +135,7 @@ jobs:
       # Provide a cache key when the remote cache is read-write.
       - name: Set up remote cache access (read-write)
         if:
-          steps.filter.outputs.ignore == 'false' && github.event_name !=
+          steps.filter.outputs.has_code == 'true' && github.event_name !=
           'pull_request'
         env:
           REMOTE_CACHE_KEY: ${{ secrets.CARBON_BUILDS_GITHUB }}
@@ -155,18 +146,18 @@ jobs:
 
       # We need to replace the `.` with a `_` for the build cache.
       - name: Setup LLVM and Clang (macOS)
-        if: steps.filter.outputs.ignore == 'false' && matrix.os == 'macos-12'
+        if: steps.filter.outputs.has_code == 'true' && matrix.os == 'macos-12'
         run: |
           echo "os_for_cache=macos-12" >> $GITHUB_ENV
       - name: Setup LLVM and Clang (Ubuntu)
         if:
-          steps.filter.outputs.ignore == 'false' && matrix.os == 'ubuntu-22.04'
+          steps.filter.outputs.has_code == 'true' && matrix.os == 'ubuntu-22.04'
         run: |
           echo "os_for_cache=ubuntu-22_04" >> $GITHUB_ENV
 
       # Add our bazel configuration and print basic info to ease debugging.
       - name: Configure Bazel and print info
-        if: steps.filter.outputs.ignore == 'false'
+        if: steps.filter.outputs.has_code == 'true'
         env:
           # Add a cache version for changes that bazel won't otherwise detect,
           # like llvm version changes.
@@ -209,7 +200,7 @@ jobs:
 
       # Just for visibility, print space before and after the build.
       - name: Disk space before build
-        if: steps.filter.outputs.ignore == 'false'
+        if: steps.filter.outputs.has_code == 'true'
         run: df -h
 
       # Build and run all targets on branch pushes to ensure we always have a
@@ -217,7 +208,7 @@ jobs:
       # optimize the latency of this step.
       - name: Compute impacted pull request targets (for push)
         if:
-          steps.filter.outputs.ignore == 'false' && github.event_name == 'push'
+          steps.filter.outputs.has_code == 'true' && github.event_name == 'push'
         env:
           TARGETS_FILE: ${{ runner.temp }}/targets
         run: |
@@ -229,7 +220,7 @@ jobs:
       # all of the unaffected Bazel targets.
       - name: Compute impacted pull request targets
         if:
-          steps.filter.outputs.ignore == 'false' && github.event_name != 'push'
+          steps.filter.outputs.has_code == 'true' && github.event_name != 'push'
         env:
           # Compute the base SHA from the different event structures.
           GIT_BASE_SHA:
@@ -246,7 +237,7 @@ jobs:
 
       # Build and run just the tests impacted by the PR or merge group.
       - name: Test (${{ matrix.build_mode }})
-        if: steps.filter.outputs.ignore == 'false'
+        if: steps.filter.outputs.has_code == 'true'
         env:
           # 'libtool_check_unique failed to generate' workaround.
           # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
@@ -302,5 +293,5 @@ jobs:
 
       # See "Disk space before build".
       - name: Disk space after build
-        if: steps.filter.outputs.ignore == 'false'
+        if: steps.filter.outputs.has_code == 'true'
         run: df -h