Repository: kubeflow/kfp-tekton (language: python)

Issue:
Move Travis unit tests to Github Actions
/kind feature

**Description:**
Kubeflow community is moving away from Travis and we don't have control of what Travis plan we can choose. Thus, moving to Github Actions can give us more flexibility on what to enable since the committers are also the repo editor right now.

One tricky thing with this change is the Docker build because Github Actions has a different mechanism for running the Docker daemon.


**Additional information:**
[Miscellaneous information that will assist in solving the issue.]



Discussion / hints:
/assign

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index e6cfcd1c59..8f674e9eb3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -93,101 +93,3 @@ matrix:
         - echo "Changes detected - continue running job"
       script:
         - make build-backend-images
-
-
-# =================================
-# TODO: merge with config from KFP
-# =================================
-#matrix:
-#  include:
-#    - language: python
-#      python: "3.5"
-#      env: TOXENV=py35
-#      before_install:
-#        - export PYTHONPATH=$PYTHONPATH:/home/travis/.local/lib/python3.5/site-packages/
-#      install: &0
-#        - python3 -m pip install --upgrade pip
-#        - python3 -m pip install -r $TRAVIS_BUILD_DIR/sdk/python/requirements.txt
-#        # Additional dependencies
-#        - pip3 install coverage==4.5.4 coveralls==1.9.2 six>=1.13.0
-#        # Sample test infra dependencies
-#        - pip3 install minio
-#        - pip3 install junit_xml
-#        # Visualization test dependencies
-#        - cd $TRAVIS_BUILD_DIR/backend/src/apiserver/visualization
-#        - pip3 install -r requirements-test.txt
-#        # Using Argo to lint all compiled workflows
-#        - export LOCAL_BIN="${HOME}/.local/bin"
-#        - mkdir -p "$LOCAL_BIN"
-#        - export PATH="${PATH}:$LOCAL_BIN" # Unnecessary - Travis already has it in PATH
-#        - wget --quiet -O "${LOCAL_BIN}/argo" https://github.com/argoproj/argo/releases/download/v2.4.3/argo-linux-amd64 && chmod +x "${LOCAL_BIN}/argo"
-#      script: &1 # DSL tests
-#        - cd $TRAVIS_BUILD_DIR/sdk/python
-#        - python3 -m pip install -e .
-#        - cd $TRAVIS_BUILD_DIR # Changing the current directory to the repo root for correct coverall paths
-#        - coverage run --source=kfp --append -m unittest discover --verbose --start-dir sdk/python/tests --top-level-directory=sdk/python
-#        #- coveralls
-#
-#        # Test against TFX
-#        # Compile and setup protobuf
-#        - PROTOC_ZIP=protoc-3.7.1-linux-x86_64.zip
-#        - curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
-#        - sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
-#        - sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
-#        - rm -f $PROTOC_ZIP
-#        # Install TFX from head
-#        - cd $TRAVIS_BUILD_DIR
-#        - git clone https://github.com/tensorflow/tfx.git
-#        - cd $TRAVIS_BUILD_DIR/tfx
-#        - pip3 install --upgrade pip
-#        - pip3 install --upgrade 'numpy>=1.16,<1.17'
-#        # Specify transitive dependency to get around: https://github.com/pypa/pip/issues/8583
-#        - pip3 install --upgrade 'google-auth>=1.18.0'
-#        - set -x
-#        - set -e
-#        - python3 setup.py bdist_wheel
-#        - WHEEL_PATH=$(find dist -name "tfx-*.whl")
-#        - python3 -m pip install "${WHEEL_PATH}" --upgrade
-#        - set +e
-#        - set +x
-#        # Three KFP-related unittests
-#        - cd $TRAVIS_BUILD_DIR/tfx/tfx/orchestration/kubeflow
-#        - python3 kubeflow_dag_runner_test.py
-#        - cd $TRAVIS_BUILD_DIR/tfx/tfx/examples/chicago_taxi_pipeline
-#        - python3 taxi_pipeline_kubeflow_gcp_test.py
-#        - python3 taxi_pipeline_kubeflow_local_test.py
-#
-#        # Visualization test
-#        - cd $TRAVIS_BUILD_DIR/backend/src/apiserver/visualization
-#        - python3 test_exporter.py
-#        - python3 test_server.py
-#
-#        # Test loading all component.yaml definitions
-#        - $TRAVIS_BUILD_DIR/components/test_load_all_components.sh
-#
-#        # Component SDK tests
-#        - cd $TRAVIS_BUILD_DIR/components/gcp/container/component_sdk/python
-#        - ./run_test.sh
-#
-#        # Sample test unittests.
-#        - cd $TRAVIS_BUILD_DIR/test/sample-test/unittests
-#        - python3 -m unittest utils_tests.py
-#    - language: python
-#      python: "3.6"
-#      env: TOXENV=py36
-#      before_install:
-#        - export PYTHONPATH=$PYTHONPATH:/home/travis/.local/lib/python3.6/site-packages/
-#      install: *0
-#      script: *1
-#    - language: python
-#      python: "3.7"
-#      env: TOXENV=py37
-#      before_install:
-#        - export PYTHONPATH=$PYTHONPATH:/home/travis/.local/lib/python3.7/site-packages/
-#      install: *0
-#      script: *1
-#    - name: "Lint Python code with flake8"
-#      language: python
-#      python: "3.7"
-#      install: pip install flake8
-#      script: flake8 . --count --exclude=backend/src/apiserver/visualization/types/*.py --select=E9,F63,F7,F82 --show-source --statistics || true
diff --git a/Makefile b/Makefile
index f28e435232..802c6c7217 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ KFP_TEKTON_RELEASE ?= v0.8.0
 export VIRTUAL_ENV := $(abspath ${VENV})
 export PATH := ${VIRTUAL_ENV}/bin:${PATH}
 DOCKER_REGISTRY ?= aipipeline
+GITHUB_ACTION ?= false
 
 .PHONY: help
 help: ## Display the Make targets
@@ -35,7 +36,7 @@ $(VENV)/bin/activate: sdk/python/setup.py
 	@echo "VENV=$(VENV)"
 	@test -d $(VENV) || python3 -m venv $(VENV)
 	@$(VENV)/bin/pip show kfp-tekton >/dev/null 2>&1 || $(VENV)/bin/pip install -e sdk/python
-	@touch $(VENV)/bin/activate
+	@if [ "$(GITHUB_ACTION)" = "false" ]; then touch $(VENV)/bin/activate; fi
 
 .PHONY: install
 install: venv ## Install the kfp_tekton compiler in a virtual environment


Test patch:
diff --git a/.github/workflows/kfp-tekton-unittests.yml b/.github/workflows/kfp-tekton-unittests.yml
new file mode 100644
index 0000000000..b8ccd492e0
--- /dev/null
+++ b/.github/workflows/kfp-tekton-unittests.yml
@@ -0,0 +1,80 @@
+name: KFP Tekton Unit Tests
+
+on:
+  push:
+    branches: [master, pull_request]
+
+env:
+  GITHUB_ACTION: "true"
+
+jobs:
+  python-unittest:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.6, 3.7, 3.8]
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install dependencies
+        run: python -m pip install -e sdk/python
+      - name: Unit Tests
+        run: VENV=$VIRTUAL_ENV make unit_test
+  progress-report:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python 3.7
+      uses: actions/setup-python@v2
+      with:
+        python-version: 3.7
+    - name: Install dependencies
+      run: python -m pip install -e sdk/python
+    - name: "Progress report on compiling KFP DSL test scripts"
+      run: VENV=$VIRTUAL_ENV make report
+  python-lint:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python 3.7
+      uses: actions/setup-python@v2
+      with:
+        python-version: 3.7
+    - name: "Lint Python code with flake8"
+      run: VENV=$VIRTUAL_ENV make lint
+  check-license:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v2
+    - name: "Verify source files contain the license header"
+      run: make check_license
+  check-mdtoc:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v2
+    - name: "Verify Markdown files have current table of contents"
+      run: make check_mdtoc
+  check-doc-links:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: "Verify Markdown files have valid links"
+      run: make check_doc_links
+  run-go-unittests:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Install Go
+      uses: actions/setup-go@v2
+      with:
+        go-version: 1.15.x
+    - name: Checkout code
+      uses: actions/checkout@v2
+    - name: "run go unit tests"
+      run: make run-go-unittests
+    - name: "Verify apiserver, agent, and workflow build"
+      run: make build-backend
diff --git a/sdk/python/tests/test_kfp_samples.sh b/sdk/python/tests/test_kfp_samples.sh
index 817526b008..de6ccd4281 100755
--- a/sdk/python/tests/test_kfp_samples.sh
+++ b/sdk/python/tests/test_kfp_samples.sh
@@ -134,6 +134,12 @@ if ! (pip show "kfp-tekton" | grep Location | grep -q "${PROJECT_DIR}"); then
   pip install -q -e "${PROJECT_DIR}/sdk/python"
 fi
 
+# install pytest, unless already installed
+if ! (pip show "pytest" | grep -q Version); then
+  echo "Installing pytest ..."
+  pip install -q pytest
+fi
+
 # install 3rd party dependencies required for certain pipeline samples
 if [[ "${ALL_SAMPLES}" == "TRUE" ]]; then
   echo "Installing 3rd-party dependencies ..."