Skip to content

Commit

Permalink
Merge pull request #40 from phargogh/bugfix/binary-builds-on-github-a…
Browse files Browse the repository at this point in the history
…ctions

Bugfix/binary builds on GitHub actions
  • Loading branch information
phargogh authored Feb 28, 2020
2 parents 47f844a + f74b23c commit 4fd660c
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 142 deletions.
191 changes: 191 additions & 0 deletions .github/workflows/binary-applications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Build InVEST App Binaries

on: [push, pull_request, check_run]

jobs:
check-syntax-errors:
name: "Check for syntax errors"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

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

- name: Set up environment
run: python -m pip install --upgrade pip setuptools setuptools_scm flake8

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
python -m flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
python -m flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
build-windows-binaries:
name: "Build windows binaries"
needs: check-syntax-errors
runs-on: windows-latest
env:
PYTHON_VERSION: 3.7
PYTHON_ARCH: x86
steps:
- uses: actions/checkout@v1

- name: Restore pip cache
uses: actions/cache@v1
with:
path: ~\AppData\Local\pip\Cache
key: windows-py${{ env.PYTHON_VERSION }}-${{ env.PYTHON_ARCH}}-pip-${{ hashFiles('**/requirements*.txt') }}-exe

- name: Set up python
uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ env.PYTHON_ARCH }}

- name: Install python dependencies
shell: powershell
env:
PIP_EXTRA_INDEX_URL: "http://pypi.naturalcapitalproject.org/simple/"
PIP_TRUSTED_HOST: "pypi.naturalcapitalproject.org"
PIP_PREFER_BINARY: 1
run: |
python -m pip install --upgrade pip nose setuptools
python -m pip install -r requirements.txt -r requirements-dev.txt -r requirements-gui.txt
python -m pip install .
- name: Install build dependencies
shell: powershell
run: |
# Appveyor build scripts expects PYTHON to point to the dir containing python.
$env:PYTHON = python -c "import sys, os; print(os.path.dirname(sys.executable))"
./ci/windows-ci-binary-install.ps1
- name: Clone dependent repositories
run: make -j2 doc/users-guide data/invest-sample-data

- name: Build sampledata
run: make -j3 sampledata

- name: Build windows binaries
run: make binaries

- name: Build installer
run: make windows_installer

- name: Set up GCP
# Secrets not available in PR so don't use GCP.
if: github.event_name != 'pull_request'
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '281.0.0'
service_account_key: ${{ secrets.GOOGLE_SERVICE_ACC_KEY }}

- name: Sign binaries
# Secrets not available in PR so don't use GCP.
if: github.event_name != 'pull_request'
shell: powershell
run: |
# figure out the path to signtool.exe (it keeps changing with SDK updates)
$env:SIGNTOOL_PATH = @(Get-ChildItem -Path 'C:\Program Files (x86)\\Windows Kits\\10' `
-Include 'signtool.exe' -File -Recurse `
-ErrorAction SilentlyContinue)[0] | Select-Object -ExpandProperty FullName
$env:INSTALLER_BINARY = @(gci 'dist/*.exe')[0] | Select-Object -ExpandProperty FullName
$env:GSUTIL_PATH = (Get-Command gsutil).path
# Specify which python version we want to use (it's the one we're using
# in actions/setup-python.
$env:CLOUDSDK_PYTHON = (Get-Command python).path
$env:CLOUDSDK_GSUTIL_PYTHON = (Get-Command python).path
make CERT_KEY_PASS=${{ secrets.STANFORD_CERT_KEY_PASS }} `
GSUTIL=$env:GSUTIL_PATH `
BIN_TO_SIGN=$env:INSTALLER_BINARY `
SIGNTOOL=$env:SIGNTOOL_PATH `
signcode_windows
- name: Deploy artifacts to GCS
# Secrets not available in PR so don't use GCP.
if: github.event_name != 'pull_request'
run: |
$env:GSUTIL_PATH = (Get-Command gsutil).path
# Specify which python version we want to use (it's the one we're using
# in actions/setup-python.
$env:CLOUDSDK_PYTHON = (Get-Command python).path
$env:CLOUDSDK_GSUTIL_PYTHON = (Get-Command python).path
make GSUTIL=$env:GSUTIL_PATH deploy
- name: Save build artifacts
uses: actions/upload-artifact@v1
with:
name: InVEST Windows build artifacts
path: dist

build-mac-binaries:
name: "Build mac binaries"
needs: check-syntax-errors
runs-on: macos-10.15
env:
PYTHON_VERSION: 3.7
PYTHON_ARCH: x86
steps:
- uses: actions/checkout@v1

- name: Install homebrew dependencies
run: |
brew update
brew install mercurial pandoc
- name: Restore conda cache
uses: actions/cache@v1
with:
path: ~/opt/anaconda3
key: mac-py${{ env.PYTHON_VERSION }}-${{ env.PYTHON_ARCH}}-conda-${{ hashFiles('**/requirements*.txt') }}-exe

- name: Set up conda
uses: s-weigand/setup-conda@v1
with:
python-version: 3.7

- name: Install python dependencies
run: pip install --upgrade pip setuptools requests setuptools_scm cython numpy

- name: Build conda env
shell: bash
run: |
python ./scripts/convert-requirements-to-conda-yml.py \
requirements.txt \
requirements-dev.txt \
requirements-gui.txt > requirements-all.yml
conda env create -p ./env --file requirements-all.yml
conda init bash
- name: Build binaries
shell: bash
run: |
make PYTHON=$(pwd)/env/bin/python install
make PYTHON=$(pwd)/env/bin/python mac_zipfile userguide
- name: Set up GCP
# Secrets not available in PR so don't use GCP.
if: github.event_name != 'pull_request'
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '281.0.0'
service_account_key: ${{ secrets.GOOGLE_SERVICE_ACC_KEY }}

- name: Deploy artifacts to GCS
# Secrets not available in PR so don't use GCP.
if: github.event_name != 'pull_request'
run: make deploy

- name: Save build artifacts
uses: actions/upload-artifact@v1
with:
name: InVEST Mac build artifacts
path: dist
File renamed without changes.
12 changes: 9 additions & 3 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
Unreleased Changes
------------------
* Binary builds for Windows and Mac OS X have been moved to GitHub Actions from
AppVeyor. All AppVeyor-specific configuration has been removed.
* Fixing an issue with the InVEST Makefile where ``make deploy`` was
attempting to synchronize nonexistent sample data zipfiles with a storage
bucket on GCP. Sample data zipfiles are only built on Windows, and so
``make deploy`` will only attempt to upload them when running on Windows.
* Fixed a bug in CLI logging where logfiles created by the CLI were
incompatible with the ``natcap.invest.datastack`` operation that
allows the UI to load model arguments from logfiles.
* Added error-handling in Urban Flood Risk Mitigation to tell users to
"Check that the Soil Group raster does not contain values other than
(1, 2, 3, 4)" when a ``ValueError`` is raised from ``_lu_to_cn_op``.
* Updated the ``Makefile`` to use the new git location of the InVEST User's
Guide repository at https://github.com/natcap/invest.users-guide
* Fixed a bug in CLI logging where logfiles created by the CLI were
incompatible with the ``natcap.invest.datastack`` operation that
allows the UI to load model arguments from logfiles.
* Automated tests are now configured to use Github Actions for 32- and 64-bit
build targets for Python 3.6 and 3.7 on Windows. We are still using
AppVeyor for our binary builds for the time being.
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ BUILD_DIR := build
# The fork name will need to be set manually (e.g. make FORKNAME=natcap/invest)
# if someone wants to build from source outside of git (like if they grabbed
# a zipfile of the source code).
FORKNAME := $(filter-out ssh: http: https: git@,$(subst /, ,$(subst :, ,$(shell git remote get-url origin))))
FORKUSER := $(word 2, $(subst /, ,$(FORKNAME)))
FORKNAME := $(word 2, $(subst github.com/, ,$(shell git remote get-url origin)))
FORKUSER := $(word 1, $(subst /, ,$(FORKNAME)))
ifeq ($(FORKUSER),natcap)
BUCKET := gs://releases.naturalcapitalproject.org
DIST_URL_BASE := $(BUCKET)/invest/$(VERSION)
Expand Down Expand Up @@ -248,7 +248,7 @@ $(APIDOCS_ZIP_FILE): $(APIDOCS_HTML_DIR)

userguide: $(USERGUIDE_HTML_DIR) $(USERGUIDE_ZIP_FILE)
$(USERGUIDE_HTML_DIR): $(GIT_UG_REPO_PATH) | $(DIST_DIR)
$(MAKE) -C doc/users-guide SPHINXBUILD=sphinx-build BUILDDIR=../../build/userguide html
$(MAKE) -C doc/users-guide SPHINXBUILD="$(PYTHON) -m sphinx" BUILDDIR=../../build/userguide html
-$(RMDIR) $(USERGUIDE_HTML_DIR)
$(COPYDIR) build/userguide/html dist/userguide

Expand Down Expand Up @@ -358,9 +358,12 @@ signcode_windows:
@echo "Installer was signed with signtool"

deploy:
$(GSUTIL) -m rsync -r $(DIST_DIR)/userguide $(DIST_URL_BASE)/userguide
$(GSUTIL) -m rsync -r $(DIST_DIR)/data $(DIST_URL_BASE)/data
$(GSUTIL) -m rsync $(DIST_DIR) $(DIST_URL_BASE)

ifeq ($(OS),Windows_NT)
$(GSUTIL) -m rsync -r $(DIST_DIR)/data $(DIST_URL_BASE)/data
$(GSUTIL) -m rsync -r $(DIST_DIR)/userguide $(DIST_URL_BASE)/userguide
endif
@echo "Binaries (if they were created) can be downloaded from:"
@echo " * $(DOWNLOAD_DIR_URL)/$(subst $(DIST_DIR)/,,$(WINDOWS_INSTALLER_FILE))"
ifeq ($(BUCKET),gs://releases.naturalcapitalproject.org) # ifeq cannot follow TABs, only spaces
Expand Down
66 changes: 0 additions & 66 deletions appveyor.yml

This file was deleted.

24 changes: 0 additions & 24 deletions ci/appveyor-binary-install.ps1

This file was deleted.

42 changes: 0 additions & 42 deletions ci/appveyor-sign-and-upload.ps1

This file was deleted.

Loading

0 comments on commit 4fd660c

Please sign in to comment.