From 05203ec3fb027f7e5e167bb362bda3a21db4afa9 Mon Sep 17 00:00:00 2001
From: Massimiliano Culpo <massimiliano.culpo@gmail.com>
Date: Sat, 9 May 2020 22:35:14 +0200
Subject: [PATCH] Add unit test on MacOS using Github Actions (#14220)

- Remove macos tests from travis
- Add macos tests in github actions.
---
 .codecov.yml                            |  3 +-
 .github/workflows/macos_unit_tests.yaml | 48 +++++++++++++++++++++++++
 .travis.yml                             | 20 -----------
 README.md                               |  1 +
 4 files changed, 50 insertions(+), 22 deletions(-)
 create mode 100644 .github/workflows/macos_unit_tests.yaml

diff --git a/.codecov.yml b/.codecov.yml
index a70b19c39c..cc4954132f 100644
--- a/.codecov.yml
+++ b/.codecov.yml
@@ -4,8 +4,7 @@ coverage:
   range: 60...90
   status:
     project:
-      default:
-        threshold: 0.3%
+      default: yes
 
 ignore:
   - lib/spack/spack/test/.*
diff --git a/.github/workflows/macos_unit_tests.yaml b/.github/workflows/macos_unit_tests.yaml
new file mode 100644
index 0000000000..f903daa034
--- /dev/null
+++ b/.github/workflows/macos_unit_tests.yaml
@@ -0,0 +1,48 @@
+name: macos tests
+
+on:
+  push:
+    branches:
+      - master
+      - develop
+  pull_request:
+    branches:
+      - master
+      - develop
+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@v1
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install Python packages
+      run: |
+          pip install --upgrade pip six setuptools
+          pip install --upgrade codecov coverage==4.5.4
+          pip install --upgrade flake8 pep8-naming
+    - name: Setup Homebrew packages
+      run: |
+        brew update
+        brew upgrade
+        brew install gcc gnupg2 dash kcov
+    - name: Run unit tests
+      run: |
+        git --version
+        git fetch origin develop:develop
+        . share/spack/setup-env.sh
+        coverage run $(which spack) test
+        coverage combine
+        coverage xml
+    - name: Upload to codecov.io
+      uses: codecov/codecov-action@v1
+      with:
+        file: ./coverage.xml
+        flags: unittests,macos
diff --git a/.travis.yml b/.travis.yml
index bc914ef512..a11b00f34e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -76,10 +76,6 @@ jobs:
       os: linux
       language: python
       env: TEST_SUITE=doc
-    - os: osx
-      language: generic
-      env: [ TEST_SUITE=unit, PYTHON_VERSION=2.7, COVERAGE=true ]
-      if: type != pull_request
 
 stages:
   - 'style checks'
@@ -111,15 +107,6 @@ addons:
       - r-base-core
       - r-base-dev
       - zsh
-  # for Mac builds, we use Homebrew
-  homebrew:
-    packages:
-      - python@2
-      - gcc
-      - gnupg2
-      - ccache
-      - dash
-      - kcov
     update: true
 
 # ~/.ccache needs to be cached directly as Travis is not taking care of it
@@ -130,14 +117,7 @@ cache:
   directories:
     - ~/.ccache
 
-# Work around Travis's lack of support for Python on OSX
 before_install:
-  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-        pip2 install --upgrade pip;
-        pip2 install virtualenv;
-        virtualenv venv;
-        source venv/bin/activate;
-    fi
   - ccache -M 2G && ccache -z
 
 # Install various dependencies
diff --git a/README.md b/README.md
index 70913b33bc..a55828808d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
 # <img src="https://cdn.rawgit.com/spack/spack/develop/share/spack/logo/spack-logo.svg" width="64" valign="middle" alt="Spack"/> Spack
 
+[![](https://github.com/spack/spack/workflows/macos%20tests/badge.svg)](https://github.com/spack/spack/actions)
 [![Build Status](https://travis-ci.com/spack/spack.svg?branch=develop)](https://travis-ci.com/spack/spack)
 [![Linux Builds](https://github.com/spack/spack/workflows/linux%20builds/badge.svg)](https://github.com/spack/spack/actions)
 [![macOS Builds (nightly)](https://github.com/spack/spack/workflows/macOS%20builds%20nightly/badge.svg?branch=develop)](https://github.com/spack/spack/actions?query=workflow%3A%22macOS+builds+nightly%22)
-- 
GitLab