Skip to content

Commit

Permalink
Squashed 'subtrees/z_quantum_actions/' changes from 5d4c008..5b664df
Browse files Browse the repository at this point in the history
5b664df Removed code associated with codecov.
5bfa0bc ci: Windows Support (#30)
f19a9ee Show offline code coverage report in 'TestCoverage' workflow (#28)

git-subtree-dir: subtrees/z_quantum_actions
git-subtree-split: 5b664dfaa021497c8745b92cb7a42f21e81f2575
  • Loading branch information
mstechly committed Sep 8, 2022
1 parent 1c4fa03 commit 3746d11
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 50 deletions.
39 changes: 31 additions & 8 deletions Makefile
@@ -1,7 +1,7 @@
################################################################################
# © Copyright 2021-2022 Zapata Computing Inc.
################################################################################
TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
TOP_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
include $(TOP_DIR)/variables.mk

# This target will list the possible valid targets available.
Expand All @@ -12,9 +12,22 @@ default:
@grep -E '^\w+(\-default)?:' $(TOP_DIR)/$(firstword $(MAKEFILE_LIST)) \
| sed -r 's/-default//g; /default/d ; s/(.*)/\t make \1/g ; s/:.*$$//g'


export VENV_NAME := my_little_venv
PYTHON := $(shell PATH="${VENV_NAME}/bin:${PATH}" python3 -c 'import sys; print(sys.executable)')
ifeq ($(OS), Windows_NT)
VENV_BINDIR := Scripts
PYTHON_EXE := python.exe
# A workaround for Windows and Bash:
# By default, PATH will give the Windows Path, but we need to get the Path for the shell we'll be using
SHELL_PATH := $(shell env echo $$PATH)
PYTHON := $(shell env PATH="${VENV_NAME}/${VENV_BINDIR}:${SHELL_PATH}" ${PYTHON_EXE} -c 'import sys; print(sys.executable)')
# Convert a Windows path to a Unix path for Windows Github Actions
PYTHON := /$(subst \,/,$(subst :\,/,$(PYTHON)))
else
VENV_BINDIR := bin
PYTHON_EXE := python3
PYTHON := $(shell env PATH="${VENV_NAME}/${VENV_BINDIR}:${PATH}" ${PYTHON_EXE} -c 'import sys; print(sys.executable)')
endif

REPO := $(shell git config --get remote.origin.url)
PYTHON_MOD := $(shell find src -maxdepth 3 -mindepth 3 -type d | sed '/.*cache/d; s/src\/python\/// ; s/\//./')
PACKAGE_NAME := "foo"
Expand Down Expand Up @@ -59,9 +72,9 @@ dev-default: clean
# `python3` here as it's more explicit, because $(PYTHON) would evaluate to
# something else after executing this task, which might be confusing.
github_actions-default:
python3 -m venv ${VENV_NAME} && \
${VENV_NAME}/bin/python3 -m pip install --upgrade pip && \
${VENV_NAME}/bin/python3 -m pip install -e '.[dev]'
${PYTHON_EXE} -m venv ${VENV_NAME}
"${VENV_NAME}/${VENV_BINDIR}/${PYTHON_EXE}" -m pip install --upgrade pip
"${VENV_NAME}/${VENV_BINDIR}/${PYTHON_EXE}" -m pip install -e '.[dev]'

# flake8p is a wrapper library that runs flake8 from config in pyproject.toml
# we can now use it instead of flake8 to lint the code
Expand All @@ -81,15 +94,25 @@ isort-default: clean
test-default:
$(PYTHON) -m pytest tests


# Option explanation:
# - '--cov=src' - turn on measuring code coverage. It outputs the results in a
# '.coverage' binary file. It's passed to other commands like
# 'python -m coverage report'
coverage-default:
$(PYTHON) -m pytest \
--cov=src \
--cov-fail-under=$(MIN_COVERAGE) tests \
--no-cov-on-fail \
--cov-report xml \
&& echo Code coverage Passed the $(MIN_COVERAGE)% mark!


# Reads the code coverage stats from '.coverage' file and prints a textual,
# human-readable report to stdout.
show-coverage-text-report-default:
$(PYTHON) -m coverage report --show-missing


style-default: flake8p mypy black isort
@echo This project passes style!

Expand All @@ -100,7 +123,7 @@ build-system-deps-default:
:

get-next-version-default: github_actions
${VENV_NAME}/bin/python3 subtrees/z_quantum_actions/bin/get_next_version.py $(PACKAGE_NAME)
$(PYTHON) subtrees/z_quantum_actions/bin/get_next_version.py $(PACKAGE_NAME)

# This is what converts the -default targets into base target names.
# Do not remove!!!
Expand Down
34 changes: 0 additions & 34 deletions actions/coverage/action.yml

This file was deleted.

36 changes: 28 additions & 8 deletions workflow-templates/coverage.yml
Expand Up @@ -17,25 +17,45 @@ on:
jobs:
# The job ID has to match repo settings for PR required checks
TestCoverage:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

# Run jobs for a couple of Python versions.
# Run jobs for a couple of Python versions and OSes.
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
python: ["3.8", "3.9", "3.10"]

name: TestCoverage - Python ${{ matrix.python }}
name: Coverage - Python ${{ matrix.python }} - ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

# Load a specific version of Python
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: x64

# ------------------------------------------------------------------------
# Loads private SSH key to the SSH agent. Allows to install dependencies
# from private git repos, but requires setting `secrets.SSH_PRIVATE_KEY`
# in repo settings.
# ------------------------------------------------------------------------
# - uses: ./subtrees/z_quantum_actions/actions/ssh_setup
# with:
# ssh_key: ${{ secrets.SSH_PRIVATE_KEY }}

- uses: ./subtrees/z_quantum_actions/actions/coverage
- uses: ./subtrees/z_quantum_actions/actions/ssh_setup
with:
ssh_key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Install deps
shell: bash
run: make github_actions
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock

- name: Run tests and gather coverage stats
shell: bash
run: make coverage

- name: Print code coverage report
shell: bash
run: make show-coverage-text-report

0 comments on commit 3746d11

Please sign in to comment.