Skip to content

Commit

Permalink
Merge pull request #142 from AsyncAlgoTrading/gha
Browse files Browse the repository at this point in the history
Setup GitHub Actions
  • Loading branch information
timkpaine committed Jan 25, 2021
2 parents d4d75b5 + 3c2d12e commit 1dee11a
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 6 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build Status

on:
push:
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.7, 3.8]
node-version: [12.x]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install yarn
run: npm install -g yarn

- name: Install system dependencies
run: |
sudo apt-get install libboost-dev
wget https://github.com/pybind/pybind11/archive/v2.5.0.tar.gz && tar xfz v2.5.0.tar.gz && cd pybind11-2.5.0 && mkdir build && cd build && cmake .. -DPYBIND11_TEST=OFF && sudo make -j4 install
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Install system dependencies
run: |
brew install boost cmake pybind11
if: ${{ matrix.os == 'macos-latest' }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine numpy pyarrow>=1. cpplint
python -m pip install -e .[dev]
cd js; yarn
- name: Lint Python
run: |
make lintpy
- name: Lint JS
run: |
make lintjs
- name: Lint C++
run: |
make lintcpp
- name: Type Annotate
run: |
make annotate
- name: Test
run: |
make tests
- name: Test C++
run: |
make testpycpp
- name: Live tests
run: |
make testruns
- 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
85 changes: 85 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# 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]
node-version: [12.x]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install yarn
run: npm install -g yarn

- name: Install system dependencies
run: |
sudo apt-get install libboost-dev
wget https://github.com/pybind/pybind11/archive/v2.5.0.tar.gz && tar xfz v2.5.0.tar.gz && cd pybind11-2.5.0 && mkdir build && cd build && cmake .. -DPYBIND11_TEST=OFF && sudo make -j4 install
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Install system dependencies
run: |
brew install boost cmake pybind11
if: ${{ matrix.os == 'macos-latest' }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine numpy pyarrow>=1. cpplint
python -m pip install -e .[dev]
cd js; yarn
- name: Lint Python
run: |
make lintpy
- name: Lint JS
run: |
make lintjs
- name: Lint C++
run: |
make lintcpp
- name: Type Annotate
run: |
make annotate
- name: Test
run: |
make tests
- name: Test C++
run: |
make testpycpp
- name: Live tests
run: |
make testruns
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
make publish
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,14 @@ docs: ## Build the sphinx docs
make -C docs html
open ./docs/_build/html/index.html

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

publish: dist ## dist to pypi and npm
python -m twine upload dist/* --skip-existing
cd js; npm publish || echo "can't publish - might already exist"

clean: ## clean the repository
find . -name "__pycache__" | xargs rm -rf
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

<img src="https://raw.githubusercontent.com/AsyncAlgoTrading/aat/main/docs/img/icon.png" width="200px"></img>

[![Build Status](https://dev.azure.com/tpaine154/aat/_apis/build/status/AsyncAlgoTrading.aat?branchName=main)](https://dev.azure.com/tpaine154/aat/_build/latest?definitionId=19&branchName=main)
[![Coverage](https://img.shields.io/azure-devops/coverage/tpaine154/aat/19/main)](https://dev.azure.com/tpaine154/aat/_apis/build/status/AsyncAlgoTrading.aat?branchName=main)
[![Build Status](https://github.com/AsyncAlgoTrading/aat/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/AsyncAlgoTrading/aat/actions?query=workflow%3A%22Build+Status%22)
[![Coverage](https://codecov.io/gh/AsyncAlgoTrading/aat/branch/main/graph/badge.svg)](https://codecov.io/gh/AsyncAlgoTrading/aat)
[![License](https://img.shields.io/github/license/timkpaine/aat.svg)](https://pypi.python.org/pypi/aat)
[![PyPI](https://img.shields.io/pypi/v/aat.svg)](https://pypi.python.org/pypi/aat)
[![Docs](https://img.shields.io/readthedocs/aat.svg)](http://aat.readthedocs.io/en/latest/)
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[metadata]
description-file = README.md
long_description_content_type=text/markdown

[flake8]
ignore=E203, W503
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_version(file, name="__version__"):
version = get_version(pjoin(here, name, "_version.py"))

with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()
long_description = f.read().replace("\r\n", "\n")

if sys.version_info.major < 3 or sys.version_info.minor < 7:
raise Exception("Must be python3.7 or above")
Expand Down

0 comments on commit 1dee11a

Please sign in to comment.