Repository: spack/spack

Issue:
Work around MacOS failures on Github Actions
There's a test that started failing consistently around yesterday on MacOS. The issue is a `git diff` command that can't find the merge base to compute the list of files which changed in a PR:
```console
'/usr/local/bin/git' 'diff' '--name-only' '--diff-filter=ACMR' 'develop...'
fatal: develop...HEAD: no merge base
```
Oddly enough the same command succeeds on linux for the same merge commit and repository. An example of a failure can be found [here](https://github.com/spack/spack/pull/17732/checks?check_run_id=919374994).


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/zlib/package.py b/var/spack/repos/builtin/packages/zlib/package.py
--- a/var/spack/repos/builtin/packages/zlib/package.py
+++ b/var/spack/repos/builtin/packages/zlib/package.py
@@ -3,14 +3,13 @@
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
-from spack import *
-
 
 # Although zlib comes with a configure script, it does not use Autotools
 # The AutotoolsPackage causes zlib to fail to build with PGI
 class Zlib(Package):
     """A free, general-purpose, legally unencumbered lossless
-       data-compression library."""
+    data-compression library.
+    """
 
     homepage = "http://zlib.net"
     # URL must remain http:// so Spack can bootstrap curl


Test patch:
diff --git a/.github/workflows/linux_build_tests.yaml b/.github/workflows/linux_build_tests.yaml
--- a/.github/workflows/linux_build_tests.yaml
+++ b/.github/workflows/linux_build_tests.yaml
@@ -23,23 +23,19 @@ on:
 
 jobs:
   build:
-
     runs-on: ubuntu-latest
     strategy:
-      max-parallel: 4
       matrix:
         package: [lz4, mpich, tut, py-setuptools, openjpeg, r-rcpp]
     steps:
     - uses: actions/checkout@v2
-    - name: Cache ccache's store
-      uses: actions/cache@v1
+    - uses: actions/cache@v2
       with:
         path: ~/.ccache
         key: ccache-build-${{ matrix.package }}
         restore-keys: |
           ccache-build-${{ matrix.package }}
-    - name: Setup Python
-      uses: actions/setup-python@v1
+    - uses: actions/setup-python@v2
       with:
         python-version: 3.8
     - name: Install System Packages
diff --git a/.github/workflows/linux_unit_tests.yaml b/.github/workflows/linux_unit_tests.yaml
--- a/.github/workflows/linux_unit_tests.yaml
+++ b/.github/workflows/linux_unit_tests.yaml
@@ -19,8 +19,9 @@ jobs:
 
     steps:
     - uses: actions/checkout@v2
-    - name: Setup Python ${{ matrix.python-version }}
-      uses: actions/setup-python@v2
+      with:
+        fetch-depth: 0
+    - uses: actions/setup-python@v2
       with:
         python-version: ${{ matrix.python-version }}
     - name: Install System packages
@@ -36,9 +37,7 @@ jobs:
       run: |
           # Need this for the git tests to succeed.
           git --version
-          git config --global user.email "spack@example.com"
-          git config --global user.name "Test User"
-          git fetch -u origin develop:develop
+          . .github/workflows/setup_git.sh
     - name: Install kcov for bash script coverage
       env:
           KCOV_VERSION: 34
@@ -56,34 +55,15 @@ jobs:
           share/spack/qa/run-unit-tests
           coverage combine
           coverage xml
-    - name: Upload to codecov.io
-      uses: codecov/codecov-action@v1
+    - uses: codecov/codecov-action@v1
       with:
         flags: unittests,linux
-  flake8:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-    - uses: actions/setup-python@v2
-      with:
-        python-version: 3.8
-    - name: Install Python packages
-      run: |
-        pip install --upgrade pip six setuptools flake8
-    - name: Setup git configuration
-      run: |
-        # Need this for the git tests to succeed.
-        git --version
-        git config --global user.email "spack@example.com"
-        git config --global user.name "Test User"
-        git fetch -u origin develop:develop
-    - name: Run flake8 tests
-      run: |
-          share/spack/qa/run-flake8-tests
   shell:
     runs-on: ubuntu-latest
     steps:
     - uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
     - uses: actions/setup-python@v2
       with:
         python-version: 3.8
@@ -100,9 +80,7 @@ jobs:
       run: |
           # Need this for the git tests to succeed.
           git --version
-          git config --global user.email "spack@example.com"
-          git config --global user.name "Test User"
-          git fetch -u origin develop:develop
+          . .github/workflows/setup_git.sh
     - name: Install kcov for bash script coverage
       env:
           KCOV_VERSION: 38
@@ -118,25 +96,6 @@ jobs:
           COVERAGE: true
       run: |
           share/spack/qa/run-shell-tests
-    - name: Upload to codecov.io
-      uses: codecov/codecov-action@v1
+    - uses: codecov/codecov-action@v1
       with:
         flags: shelltests,linux
-  documentation:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-    - uses: actions/setup-python@v2
-      with:
-        python-version: 3.8
-    - name: Install System packages
-      run: |
-        sudo apt-get -y update
-        sudo apt-get install -y coreutils ninja-build graphviz
-    - name: Install Python packages
-      run: |
-        pip install --upgrade pip six setuptools
-        pip install --upgrade -r lib/spack/docs/requirements.txt
-    - name: Build documentation
-      run: |
-          share/spack/qa/run-doc-tests
diff --git a/.github/workflows/macos_unit_tests.yaml b/.github/workflows/macos_unit_tests.yaml
--- a/.github/workflows/macos_unit_tests.yaml
+++ b/.github/workflows/macos_unit_tests.yaml
@@ -11,18 +11,14 @@ on:
       - releases/**
 jobs:
   build:
-
     runs-on: macos-latest
-    strategy:
-      matrix:
-        python-version: [3.7]
-
     steps:
     - uses: actions/checkout@v2
-    - name: Setup Python ${{ matrix.python-version }}
-      uses: actions/setup-python@v2
       with:
-        python-version: ${{ matrix.python-version }}
+        fetch-depth: 0
+    - uses: actions/setup-python@v2
+      with:
+        python-version: 3.7
     - name: Install Python packages
       run: |
           pip install --upgrade pip six setuptools
@@ -36,13 +32,12 @@ jobs:
     - name: Run unit tests
       run: |
         git --version
-        git fetch -u origin develop:develop
+        . .github/workflows/setup_git.sh
         . share/spack/setup-env.sh
         coverage run $(which spack) test
         coverage combine
         coverage xml
-    - name: Upload to codecov.io
-      uses: codecov/codecov-action@v1
+    - uses: codecov/codecov-action@v1
       with:
         file: ./coverage.xml
         flags: unittests,macos