Skip to content

Commit

Permalink
move to gha, black (#10)
Browse files Browse the repository at this point in the history
* move to gha

* update python

* .

* .
  • Loading branch information
timkpaine committed Dec 12, 2021
1 parent 2aee731 commit 4e3c2f1
Show file tree
Hide file tree
Showing 23 changed files with 525 additions and 427 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Status

on:
push:
branches:
- main
pull_request:
schedule:
# run on sunday nights
- cron: '0 0 * * 0'

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9]
event-name: [push]

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 --upgrade pip setuptools wheel twine jupyter-packaging
python -m pip install -e .[dev]
- name: Lint
run: |
make lint
- name: Test
run: |
make tests
if: ${{ github.event_name == matrix.event-name || matrix.os == 'ubuntu-latest' }}

- name: Twine check
run: |
make dist
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: python_junit.xml
if: ${{ always() }}

- name: Upload coverage
uses: codecov/codecov-action@v1
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '35 22 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
44 changes: 44 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Publish Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]

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 -U pip setuptools wheel twine jupyter-packaging
python -m pip install -e .[dev]
- name: Lint
run: |
make lint
- name: Test
run: |
make tests
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
make publish
33 changes: 18 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
PYTHON=python3.7

TEMPLATE=1

build: ## build a sample pdf report
buildtpl: ## build a sample pdf report
NBCX_CONTEXT=pdf jupyter nbconvert --to nbcx_pdf example_notebooks/template${TEMPLATE}.ipynb --execute --template nbcx_template${TEMPLATE}_pdf && open example_notebooks/template${TEMPLATE}.pdf

html: ## build a sample html report
Expand All @@ -12,7 +10,7 @@ tex: ## build a sample latext report
NBCX_CONTEXT=pdf jupyter nbconvert --to nbcx_latex example_notebooks/template${TEMPLATE}.ipynb --execute --template nbcx_template${TEMPLATE}_pdf && code example_notebooks/template${TEMPLATE}.tex

build1: ## build pdf first template
make build TEMPLATE=1
make buildtpl TEMPLATE=1

html1: ## build html first template
make html TEMPLATE=1
Expand All @@ -21,19 +19,25 @@ tex1: ## build tex first template
make tex TEMPLATE=1

build2: ## build pdf first template
make build TEMPLATE=2
make buildtpl TEMPLATE=2

html2: ## build html first template
make html TEMPLATE=2

tex2: ## build tex first template
make tex TEMPLATE=2

build: ## build python
python setup.py build

tests: lint ## run the tests
${PYTHON} -m pytest -vv nbcx/tests --cov=nbcx --junitxml=python_junit.xml --cov-report=xml --cov-branch
python -m pytest -vv nbcx/tests --cov=nbcx --junitxml=python_junit.xml --cov-report=xml --cov-branch

lint: ## run linter
python3.7 -m flake8 nbcx
python -m flake8 nbcx setup.py docs/conf.py

fix: ## run black fix
python -m black nbcx/ setup.py docs/conf.py

clean: ## clean the repository
find . -name "__pycache__" | xargs rm -rf
Expand All @@ -49,16 +53,15 @@ docs: ## make documentation
open ./docs/_build/html/index.html

install: ## install to site-packages
${PYTHON} -m pip install .

fix: ## run autopep8/tslint fix
python3.7 -m autopep8 --in-place -r -a -a nbcx/
python -m pip install .

dist: ## dist to pypi
dist: ## create dists
rm -rf dist build
${PYTHON} setup.py sdist
${PYTHON} setup.py bdist_wheel
twine check dist/* && twine upload dist/*
python setup.py sdist bdist_wheel
python -m twine check dist/*

publish: dist ## dist to pypi
python -m twine upload dist/* --skip-existing

# Thanks to Francoise at marmelab.com for this
.DEFAULT_GOAL := help
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# nbconvertX
A framework for customizing NBConvert templates and building reports

[![Build Status](https://dev.azure.com/tpaine154/jupyter/_apis/build/status/timkpaine.nbcx?branchName=master)](https://dev.azure.com/tpaine154/jupyter/_build/latest?definitionId=25&branchName=master)
[![Coverage](https://img.shields.io/azure-devops/coverage/tpaine154/jupyter/25/master)](https://dev.azure.com/tpaine154/jupyter/_build?definitionId=25&_a=summary)
[![Build Status](https://github.com/timkpaine/nbcx/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/timkpaine/nbcx/actions?query=workflow%3A%22Build+Status%22)
[![Coverage](https://codecov.io/gh/timkpaine/nbcx/branch/main/graph/badge.svg?token=ag2j2TV2wE)](https://codecov.io/gh/timkpaine/nbcx)
[![GitHub issues](https://img.shields.io/github/issues/timkpaine/nbcx.svg)]()
[![PyPI](https://img.shields.io/pypi/l/nbcx.svg)](https://pypi.python.org/pypi/nbcx)
[![PyPI](https://img.shields.io/pypi/v/nbcx.svg)](https://pypi.python.org/pypi/nbcx)
Expand Down
128 changes: 0 additions & 128 deletions azure-pipelines.yml

This file was deleted.

Loading

0 comments on commit 4e3c2f1

Please sign in to comment.