-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from khaeru/setup-ci
Set up continuous integration
- Loading branch information
Showing
7 changed files
with
244 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
name: pytest | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
schedule: | ||
- cron: "0 5 * * *" | ||
|
||
|
||
env: | ||
GAMS_VERSION: 25.1.1 | ||
# See description in lint.yml | ||
depth: 100 | ||
|
||
jobs: | ||
pytest: | ||
strategy: | ||
matrix: | ||
os: | ||
- macos-latest | ||
- ubuntu-latest | ||
- windows-latest | ||
python-version: | ||
- "3.7" # Earliest version supported by genno; matches xarray | ||
- "3.8" # Latest version testable on GitHub Actions | ||
|
||
# For development versions of Python, compiled binary wheels are not | ||
# available for some dependencies, e.g. llvmlite, numba, numpy, and/or | ||
# pandas. Compiling these on the job runner requires a more elaborate | ||
# build environment, currently out of scope for the ixmp project. | ||
# - "3.9" # Latest Python release | ||
# - "3.10.0-alpha.1" # Development version | ||
|
||
exclude: | ||
# This job triggers error when importing ixmp.testing: no module named | ||
# ixmp.backend. Not critical, since it's upstream. | ||
- os: windows-latest | ||
python-version: "3.7" | ||
|
||
fail-fast: false | ||
|
||
runs-on: ${{ matrix.os }} | ||
name: ${{ matrix.os }}-py${{ matrix.python-version }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: genno | ||
fetch-depth: ${{ env.depth }} | ||
|
||
- name: Fetch tags (for setuptools-scm) | ||
working-directory: genno | ||
run: git fetch --tags --depth=${{ env.depth }} | ||
|
||
- name: Check out ixmp | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: iiasa/ixmp | ||
path: ixmp | ||
fetch-depth: ${{ env.depth }} | ||
|
||
- name: Fetch tags (for setuptools-scm) | ||
working-directory: ixmp | ||
run: git fetch --tags --depth=${{ env.depth }} | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Use OpenJDK 14 (macOS only) | ||
# Using the default OpenJDK 1.8 on the macos-latest runner produces | ||
# "Abort trap: 6" when JPype1 starts the JVM | ||
if: ${{ startsWith(matrix.os, 'macos') }} | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: '14' | ||
|
||
- name: Cache GAMS installer, Python packages, and R packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
gams | ||
~/.cache/pip | ||
~/Library/Caches/pip | ||
~/appdata/local/pip/cache | ||
${{ env.R_LIBS_USER }} | ||
key: ${{ matrix.os }}-gams${{ env.GAMS_VERSION }}-py${{ matrix.python-version }} | ||
restore-keys: | | ||
${{ matrix.os }}-gams${{ env.GAMS_VERSION }}- | ||
${{ matrix.os }}- | ||
- name: Install GAMS and Graphviz | ||
env: | ||
CI_OS: ${{ matrix.os }} | ||
working-directory: genno | ||
shell: bash | ||
run: | | ||
ci/install-gams.sh | ||
ci/install-graphviz.sh | ||
- name: Check GAMS | ||
run: gams | ||
shell: bash | ||
|
||
- name: Upgrade pip, wheel, setuptools-scm | ||
run: python -m pip install --upgrade pip wheel setuptools-scm | ||
|
||
- name: Install ixmp and dependencies, including testing dependencies | ||
working-directory: ixmp | ||
run: pip install .[tests] | ||
|
||
- name: Install Python package and dependencies | ||
working-directory: genno | ||
run: pip install .[docs,tests] | ||
|
||
- name: Run test suite using pytest | ||
working-directory: genno | ||
run: pytest genno --trace-config --verbose --cov-report=xml --color=yes | ||
|
||
- name: Test documentation build using Sphinx | ||
if: ${{ startsWith(matrix.os, 'ubuntu') }} | ||
working-directory: genno/doc | ||
run: make html | ||
|
||
- name: Upload test coverage to Codecov.io | ||
uses: codecov/codecov-action@v1.2.1 | ||
with: | ||
root_dir: genno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
|
||
python: | ||
version: 3.8 | ||
install: | ||
- method: pip | ||
path: . | ||
extra_requirements: | ||
- docs | ||
- tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/sh | ||
# Install GAMS. | ||
# | ||
# The environment variables CI_OS and GAMS_VERSION must be set. | ||
|
||
BASE=$PWD/gams | ||
mkdir -p $BASE | ||
|
||
# GAMS source URL fragment, and path fragment for extracted files | ||
case $CI_OS in | ||
linux* | ubuntu*) | ||
GAMS_OS=linux | ||
FRAGMENT=${GAMS_OS}_x64_64_sfx | ||
;; | ||
macos*) | ||
GAMS_OS=macosx | ||
FRAGMENT=osx_x64_64_sfx | ||
;; | ||
windows*) | ||
GAMS_OS=windows | ||
FRAGMENT=${GAMS_OS}_x64_64 | ||
;; | ||
esac | ||
|
||
# Retrieve | ||
BASE_URL=https://d37drm4t2jghv5.cloudfront.net/distributions | ||
URL=$BASE_URL/$GAMS_VERSION/$GAMS_OS/$FRAGMENT.exe | ||
|
||
if [ -x $BASE/gams.exe ]; then | ||
# Don't retrieve if the remote file is older than the cached one | ||
TIME_CONDITION=--remote-time --time-cond $BASE/gams.exe | ||
fi | ||
|
||
curl --silent $URL --output $BASE/gams.exe $TIME_CONDITION | ||
|
||
# TODO confirm checksum | ||
|
||
# Path fragment for extraction or install | ||
DEST=gams$(echo $GAMS_VERSION | cut -d. -f1-2)_$FRAGMENT | ||
|
||
if [ $GAMS_OS = "windows" ]; then | ||
cat << EOF >install-gams.ps1 | ||
# Windows-format equivalent of BASE | ||
\$BASE = "\$PWD\gams" | ||
# Install to the same directory as Linux/macOS unzip | ||
Start-Process "\$BASE\gams.exe" "/SP-", "/SILENT", "/DIR=\$BASE\\$DEST", \` | ||
"/NORESTART" -Wait | ||
EOF | ||
cat install-gams.ps1 | ||
pwsh install-gams.ps1 | ||
else | ||
# Extract files | ||
unzip -q -d $BASE $BASE/gams.exe | ||
fi | ||
|
||
# Update PATH | ||
export PATH=$BASE/$DEST:$PATH | ||
|
||
# For GitHub Actions | ||
echo "$BASE/$DEST" >> $GITHUB_PATH | ||
|
||
# Show location | ||
which gams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
# Install Graphviz. | ||
|
||
case $CI_OS in | ||
linux* | ubuntu*) | ||
sudo apt install --quiet graphviz | ||
;; | ||
macos*) | ||
brew install graphviz | ||
;; | ||
windows*) | ||
# Temporary; see https://github.com/iiasa/ixmp/pull/387 | ||
choco install --no-progress --version 2.38.0.20190211 graphviz | ||
;; | ||
esac | ||
|
||
# Print version | ||
dot -V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Include ixmp test fixtures, e.g. pre-populated Scenario objects | ||
# TODO remove this dependency | ||
# NB genno must follow ixmp, since pytest prefers fixtures etc. from later in the list | ||
pytest_plugins = ["ixmp.testing", "genno.testing"] | ||
pytest_plugins = ("ixmp.testing", "genno.testing") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters