Skip to content

Commit

Permalink
Merge c72c463 into 0a4f0c6
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Mar 11, 2021
2 parents 0a4f0c6 + c72c463 commit 680a419
Show file tree
Hide file tree
Showing 60 changed files with 1,022 additions and 897 deletions.
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/question.md
Expand Up @@ -6,5 +6,3 @@ labels: question
assignees: ''

---


55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
@@ -0,0 +1,55 @@
name: Publish Python distributions to PyPI

on:
push:
branches:
- 'master'
- 'test_deploy'
tags:
- '*'

jobs:
build-n-publish:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master

- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install pypa/build
run: >-
cd python &&
python -m
pip install
build
--user &&
cd ..
- name: Build a binary wheel and a source tarball
run: >-
cd python &&
python -m
build
--sdist
--wheel
--outdir dist/
. &&
cd ..
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/

- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
94 changes: 94 additions & 0 deletions .github/workflows/pre-commit.yml
@@ -0,0 +1,94 @@
name: pre-commit
on:
push:
branches-ignore:
- 'master'

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up environment
run: |
echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV
mkdir -p .local/R/site-packages
echo "R_LIBS_USER=`pwd`/.local/R/site-packages" >> $GITHUB_ENV
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y libcurl4-openssl-dev
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
architecture: "x64"

- name: Cache pre-commit
uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-

- name: Run pre-commit
uses: pre-commit/action@v2.0.0

- name: Cache R packages
uses: actions/cache@v2
if: startsWith(runner.os, 'Linux')
with:
path: ${{env.R_LIBS_USER}}
key: precommit-${{env.UBUNTU_VERSION}}-renv-${{ hashFiles('Rmagic/.pre-commit.r_requirements.txt') }}-${{ hashFiles('Rmagic/DESCRIPTION') }}-
restore-keys: |
precommit-${{env.UBUNTU_VERSION}}-renv-${{ hashFiles('Rmagic/.pre-commit.r_requirements.txt') }}-
precommit-${{env.UBUNTU_VERSION}}-renv-
- name: Install R packages
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
con = file("Rmagic/.pre-commit.r_requirements.txt", "r")
while ( length(pkg <- readLines(con, n = 1)) > 0 ) {
renv::install(pkg)
}
close(con)
if (!require("devtools")) install.packages("devtools", repos="http://cloud.r-project.org")
devtools::install_dev_deps("./Rmagic", upgrade=TRUE)
devtools::install("./Rmagic")
shell: Rscript {0}

- name: Run pre-commit for R
run: |
cd Rmagic
git init
git add *
pre-commit run --all-files
rm -rf .git
cd ..
- name: Commit files
if: failure()
run: |
git checkout -- .github/workflows
if [[ `git status --porcelain --untracked-files=no` ]]; then
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "pre-commit" -a
fi
- name: Push changes
if: failure()
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
172 changes: 172 additions & 0 deletions .github/workflows/run_tests.yml
@@ -0,0 +1,172 @@
name: Unit Tests

on:
push:
branches-ignore:
- 'test_deploy'
pull_request:
branches:
- '*'

jobs:

test_python:
runs-on: ${{ matrix.config.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"

strategy:
fail-fast: false
matrix:
config:
- {name: '3.9', os: ubuntu-latest, python: '3.9' }
- {name: '3.8', os: ubuntu-latest, python: '3.8' }
- {name: '3.7', os: ubuntu-latest, python: '3.7' }
- {name: '3.6', os: ubuntu-latest, python: '3.6' }

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}

- name: Check Ubuntu version
run: |
echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV
- uses: actions/checkout@v2

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

- name: Cache Python packages
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('python/setup.py') }}
restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}-

- name: Install package & dependencies
run: |
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install -U ./python[test]
python -c "import magic"
- name: Run Python tests
run: |
cd python
nose2 -vvv
cd ..
- name: Build docs
run: |
cd python
pip install .[doc]
cd doc
make html
cd ../..
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
run: |
coveralls
- name: Upload check results on fail
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ matrix.config.name }}_results
path: check

test_r:
runs-on: ${{ matrix.config.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"

strategy:
fail-fast: false
matrix:
config:
- {name: 'devel', os: ubuntu-latest, r: 'devel' }
- {name: 'release', os: ubuntu-latest, r: 'release' }

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}

- name: Set up environment
run: |
echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV
mkdir -p .local/R/site-packages
echo "R_LIBS_USER=`pwd`/.local/R/site-packages" >> $GITHUB_ENV
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y libcurl4-openssl-dev pandoc
- name: Cache Python packages
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('python/setup.py') }}
restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}-

- name: Install package & dependencies
run: |
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install -U ./python
python -c "import magic"
- name: Set up R
id: setup-r
uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}

- name: Cache R packages
uses: actions/cache@v2
if: startsWith(runner.os, 'Linux')
with:
path: ${{env.R_LIBS_USER}}
key: test-${{env.UBUNTU_VERSION}}-renv-${{ steps.setup-r.outputs.installed-r-version }}-${{ hashFiles('Rmagic/DESCRIPTION') }}-
restore-keys: |
test-${{env.UBUNTU_VERSION}}-renv-${{ steps.setup-r.outputs.installed-r-version }}-
- name: Install R packages
run: |
if (!require("devtools")) install.packages("devtools", repos="http://cloud.r-project.org")
devtools::install_dev_deps("./Rmagic", upgrade=TRUE)
devtools::install("./Rmagic")
shell: Rscript {0}

- name: Install tinytex
uses: r-lib/actions/setup-tinytex@v1

- name: Run R tests
run: |
cd Rmagic
R CMD build .
R CMD check --as-cran *.tar.gz
cd ..
- name: Upload check results on fail
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ matrix.config.name }}_results
path: check
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: \.(ai|gz)$
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ['--target-version', 'py36']
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.4
hooks:
- id: autopep8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies: ['hacking']

0 comments on commit 680a419

Please sign in to comment.