-
Notifications
You must be signed in to change notification settings - Fork 68
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 #40 from phargogh/bugfix/binary-builds-on-github-a…
…ctions Bugfix/binary builds on GitHub actions
- Loading branch information
Showing
10 changed files
with
253 additions
and
142 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,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.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.