Skip to content

Commit 136169c

Browse files
authored
Merge pull request #195 from KrishnaswamyLab/dev
MAGIC v3.0
2 parents 0a4f0c6 + c72c463 commit 136169c

60 files changed

Lines changed: 1022 additions & 897 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/question.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ labels: question
66
assignees: ''
77

88
---
9-
10-

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish Python distributions to PyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'test_deploy'
8+
tags:
9+
- '*'
10+
11+
jobs:
12+
build-n-publish:
13+
name: Build and publish Python distributions to PyPI
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@master
18+
19+
- name: Set up Python 3.7
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.7
23+
24+
- name: Install pypa/build
25+
run: >-
26+
cd python &&
27+
python -m
28+
pip install
29+
build
30+
--user &&
31+
cd ..
32+
33+
- name: Build a binary wheel and a source tarball
34+
run: >-
35+
cd python &&
36+
python -m
37+
build
38+
--sdist
39+
--wheel
40+
--outdir dist/
41+
. &&
42+
cd ..
43+
44+
- name: Publish distribution to Test PyPI
45+
uses: pypa/gh-action-pypi-publish@master
46+
with:
47+
skip_existing: true
48+
password: ${{ secrets.test_pypi_password }}
49+
repository_url: https://test.pypi.org/legacy/
50+
51+
- name: Publish distribution to PyPI
52+
if: startsWith(github.ref, 'refs/tags')
53+
uses: pypa/gh-action-pypi-publish@master
54+
with:
55+
password: ${{ secrets.pypi_password }}

.github/workflows/pre-commit.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: pre-commit
2+
on:
3+
push:
4+
branches-ignore:
5+
- 'master'
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Cancel Previous Runs
13+
uses: styfle/cancel-workflow-action@0.6.0
14+
with:
15+
access_token: ${{ github.token }}
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up environment
21+
run: |
22+
echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV
23+
mkdir -p .local/R/site-packages
24+
echo "R_LIBS_USER=`pwd`/.local/R/site-packages" >> $GITHUB_ENV
25+
26+
- name: Install system dependencies
27+
if: runner.os == 'Linux'
28+
run: |
29+
sudo apt-get update -qq
30+
sudo apt-get install -y libcurl4-openssl-dev
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v2
34+
with:
35+
python-version: "3.8"
36+
architecture: "x64"
37+
38+
- name: Cache pre-commit
39+
uses: actions/cache@v2
40+
with:
41+
path: ~/.cache/pre-commit
42+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-
43+
44+
- name: Run pre-commit
45+
uses: pre-commit/action@v2.0.0
46+
47+
- name: Cache R packages
48+
uses: actions/cache@v2
49+
if: startsWith(runner.os, 'Linux')
50+
with:
51+
path: ${{env.R_LIBS_USER}}
52+
key: precommit-${{env.UBUNTU_VERSION}}-renv-${{ hashFiles('Rmagic/.pre-commit.r_requirements.txt') }}-${{ hashFiles('Rmagic/DESCRIPTION') }}-
53+
restore-keys: |
54+
precommit-${{env.UBUNTU_VERSION}}-renv-${{ hashFiles('Rmagic/.pre-commit.r_requirements.txt') }}-
55+
precommit-${{env.UBUNTU_VERSION}}-renv-
56+
57+
- name: Install R packages
58+
run: |
59+
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
60+
con = file("Rmagic/.pre-commit.r_requirements.txt", "r")
61+
while ( length(pkg <- readLines(con, n = 1)) > 0 ) {
62+
renv::install(pkg)
63+
}
64+
close(con)
65+
if (!require("devtools")) install.packages("devtools", repos="http://cloud.r-project.org")
66+
devtools::install_dev_deps("./Rmagic", upgrade=TRUE)
67+
devtools::install("./Rmagic")
68+
shell: Rscript {0}
69+
70+
- name: Run pre-commit for R
71+
run: |
72+
cd Rmagic
73+
git init
74+
git add *
75+
pre-commit run --all-files
76+
rm -rf .git
77+
cd ..
78+
79+
- name: Commit files
80+
if: failure()
81+
run: |
82+
git checkout -- .github/workflows
83+
if [[ `git status --porcelain --untracked-files=no` ]]; then
84+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
85+
git config --local user.name "github-actions[bot]"
86+
git commit -m "pre-commit" -a
87+
fi
88+
89+
- name: Push changes
90+
if: failure()
91+
uses: ad-m/github-push-action@master
92+
with:
93+
github_token: ${{ secrets.GITHUB_TOKEN }}
94+
branch: ${{ github.ref }}

.github/workflows/run_tests.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'test_deploy'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
13+
test_python:
14+
runs-on: ${{ matrix.config.os }}
15+
if: "!contains(github.event.head_commit.message, 'ci skip')"
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
config:
21+
- {name: '3.9', os: ubuntu-latest, python: '3.9' }
22+
- {name: '3.8', os: ubuntu-latest, python: '3.8' }
23+
- {name: '3.7', os: ubuntu-latest, python: '3.7' }
24+
- {name: '3.6', os: ubuntu-latest, python: '3.6' }
25+
26+
steps:
27+
- name: Cancel Previous Runs
28+
uses: styfle/cancel-workflow-action@0.6.0
29+
with:
30+
access_token: ${{ github.token }}
31+
32+
- name: Check Ubuntu version
33+
run: |
34+
echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV
35+
36+
- uses: actions/checkout@v2
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: ${{ matrix.config.python }}
42+
43+
- name: Cache Python packages
44+
uses: actions/cache@v2
45+
with:
46+
path: ${{ env.pythonLocation }}
47+
key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('python/setup.py') }}
48+
restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}-
49+
50+
- name: Install package & dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install -U wheel setuptools
54+
pip install -U ./python[test]
55+
python -c "import magic"
56+
57+
- name: Run Python tests
58+
run: |
59+
cd python
60+
nose2 -vvv
61+
cd ..
62+
63+
- name: Build docs
64+
run: |
65+
cd python
66+
pip install .[doc]
67+
cd doc
68+
make html
69+
cd ../..
70+
71+
- name: Coveralls
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
COVERALLS_SERVICE_NAME: github
75+
run: |
76+
coveralls
77+
78+
- name: Upload check results on fail
79+
if: failure()
80+
uses: actions/upload-artifact@master
81+
with:
82+
name: ${{ matrix.config.name }}_results
83+
path: check
84+
85+
test_r:
86+
runs-on: ${{ matrix.config.os }}
87+
if: "!contains(github.event.head_commit.message, 'ci skip')"
88+
89+
strategy:
90+
fail-fast: false
91+
matrix:
92+
config:
93+
- {name: 'devel', os: ubuntu-latest, r: 'devel' }
94+
- {name: 'release', os: ubuntu-latest, r: 'release' }
95+
96+
steps:
97+
- name: Cancel Previous Runs
98+
uses: styfle/cancel-workflow-action@0.6.0
99+
with:
100+
access_token: ${{ github.token }}
101+
102+
- name: Set up environment
103+
run: |
104+
echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV
105+
mkdir -p .local/R/site-packages
106+
echo "R_LIBS_USER=`pwd`/.local/R/site-packages" >> $GITHUB_ENV
107+
108+
- uses: actions/checkout@v2
109+
110+
- name: Set up Python
111+
uses: actions/setup-python@v2
112+
with:
113+
python-version: "3.8"
114+
115+
- name: Install system dependencies
116+
if: runner.os == 'Linux'
117+
run: |
118+
sudo apt-get update -qq
119+
sudo apt-get install -y libcurl4-openssl-dev pandoc
120+
121+
- name: Cache Python packages
122+
uses: actions/cache@v2
123+
with:
124+
path: ${{ env.pythonLocation }}
125+
key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('python/setup.py') }}
126+
restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}-
127+
128+
- name: Install package & dependencies
129+
run: |
130+
python -m pip install --upgrade pip
131+
pip install -U wheel setuptools
132+
pip install -U ./python
133+
python -c "import magic"
134+
135+
- name: Set up R
136+
id: setup-r
137+
uses: r-lib/actions/setup-r@v1
138+
with:
139+
r-version: ${{ matrix.config.r }}
140+
141+
- name: Cache R packages
142+
uses: actions/cache@v2
143+
if: startsWith(runner.os, 'Linux')
144+
with:
145+
path: ${{env.R_LIBS_USER}}
146+
key: test-${{env.UBUNTU_VERSION}}-renv-${{ steps.setup-r.outputs.installed-r-version }}-${{ hashFiles('Rmagic/DESCRIPTION') }}-
147+
restore-keys: |
148+
test-${{env.UBUNTU_VERSION}}-renv-${{ steps.setup-r.outputs.installed-r-version }}-
149+
150+
- name: Install R packages
151+
run: |
152+
if (!require("devtools")) install.packages("devtools", repos="http://cloud.r-project.org")
153+
devtools::install_dev_deps("./Rmagic", upgrade=TRUE)
154+
devtools::install("./Rmagic")
155+
shell: Rscript {0}
156+
157+
- name: Install tinytex
158+
uses: r-lib/actions/setup-tinytex@v1
159+
160+
- name: Run R tests
161+
run: |
162+
cd Rmagic
163+
R CMD build .
164+
R CMD check --as-cran *.tar.gz
165+
cd ..
166+
167+
- name: Upload check results on fail
168+
if: failure()
169+
uses: actions/upload-artifact@master
170+
with:
171+
name: ${{ matrix.config.name }}_results
172+
path: check

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
exclude: \.(ai|gz)$
9+
- repo: https://github.com/timothycrosley/isort
10+
rev: 5.6.4
11+
hooks:
12+
- id: isort
13+
- repo: https://github.com/psf/black
14+
rev: 20.8b1
15+
hooks:
16+
- id: black
17+
args: ['--target-version', 'py36']
18+
- repo: https://github.com/pre-commit/mirrors-autopep8
19+
rev: v1.5.4
20+
hooks:
21+
- id: autopep8
22+
- repo: https://gitlab.com/pycqa/flake8
23+
rev: 3.8.4
24+
hooks:
25+
- id: flake8
26+
additional_dependencies: ['hacking']

0 commit comments

Comments
 (0)