Skip to content

Commit

Permalink
Add GitHub Actions job (#5)
Browse files Browse the repository at this point in the history
* Add GitHub Actions job

* Fix docs requirements

* Add build requirements

* Add basic build action

* Add pandoc dependency

* Fix spelling of sudo

* Test Cache

* Ensure wget is cache

* Experiement with caching

* Move Cache to home directory

* Try home dir

* Move wget output path

* Test cache

* Add caching for PySCIPOpt

* Fix PySCIPOpt install

* Fix PySCIPOpt build path

* Test PySCIPOpt cache

* Make only one apt-get install

* Deploy docs to GitHub pages

* Fix typo in CI user email

* Allow empty commits for documentation

* Create setup-scipoptsuite.zml

* Create setup-pyscipopt.yml

* Make setup-pyscipopt an action

* Make setup-scipoptsuite action

* Use custom actions

* Checkout repository first

* Fix path

* Fix inputs

* Fix inputs again

* Add missing shell

* Use shell

* Setup scip-8 branch

* Quiet download of SCIPOptSuite

* Add release workflow

* Finish release workflow

* Create release-test.yml
  • Loading branch information
steffanschlein authored Dec 10, 2021
1 parent e7ef130 commit 97a23ba
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 7 deletions.
31 changes: 31 additions & 0 deletions .github/actions/setup-pyscipopt-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Setup PySCIPOpt"

inputs:
ref:
description: "PySCIPOpt ref that will be checked out"
required: true
default: "master"

runs:
using: "composite"
steps:
- name: Checkout PySCIPOpt
uses: actions/checkout@v2
with:
repository: scipopt/PySCIPOpt.git
ref: ${{ inputs.ref }}
path: PySCIPOpt
- run: echo "PySCIPOpt_HASH=$(cd PySCIPOpt && git rev-parse HEAD)" >> $GITHUB_ENV
shell: bash

- name: Cache PySCIPOpt Build
uses: actions/cache@v2
with:
path: ~/PySCIPOpt_dist
key: ${{ runner.os }}-PySCIPOpt-${{ env.PySCIPOpt_HASH }}

- name: Build & Install PySCIPOpt
run: |
[ ! -f ~/PySCIPOpt_dist/*.whl ] && pip install wheel && python -m build --no-isolation --wheel --outdir ~/PySCIPOpt_dist/ PySCIPOpt/
pip install ~/PySCIPOpt_dist/*.whl
shell: bash
22 changes: 22 additions & 0 deletions .github/actions/setup-scipoptsuite-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Setup SCIPOptSuite"

inputs:
version:
description: "SCIPOptSuite version to install"
required: true
default: "8.0.0"

runs:
using: "composite"
steps:
- name: Cache SCIPOptSuite Package
uses: actions/cache@v2
with:
path: ~/SCIPOptSuite-${{ inputs.version }}-Linux-ubuntu.deb
key: ${{ runner.os }}-SCIPOptSuite-${{ env.version }}-home

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --timestamping --directory-prefix=$HOME https://scipopt.org/download/release/SCIPOptSuite-${{ inputs.version }}-Linux-ubuntu.deb
sudo apt-get install -y pandoc ~/SCIPOptSuite-${{ inputs.version }}-Linux-ubuntu.deb
shell: bash
67 changes: 67 additions & 0 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build Package

on: [push]

jobs:
Build-Package-Linux:
runs-on: ubuntu-20.04
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Setup SCIPOptSuite
uses: ./.github/actions/setup-scipoptsuite-action

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
requirements.txt
docs/requirements.txt
- name: Prepare Python Environment
run: |
pip install -r requirements.txt
pip install -r docs/requirements.txt
- name: Setup PySCIPOpt
uses: ./.github/actions/setup-pyscipopt-action
with:
ref: scip-8

- name: Build PyGCGOpt
run: |
python -m build --sdist --no-isolation --outdir dist/
- name: Install PyGCGOpt
run: |
pip install dist/*.tar.gz
- name: Build Documentation
run: make html
working-directory: ./docs

- name: Checkout Documentation Branch
uses: actions/checkout@v2
with:
ref: gh-pages
path: gh-pages

- name: Deploy Documentation
run: |
rm -rf gh-pages/*
cp -r docs/_build/html/* gh-pages/
cd gh-pages
git config user.name "GCG CI Bot"
git config user.email "[email protected]"
git add .
git commit --allow-empty -m "Deploy docs to GitHub Pages, GitHub Actions build: ${GITHUB_RUN_ID}" -m "Commit: ${GITHUB_SHA}"
git push
- name: Archive Documentation
uses: actions/upload-artifact@v2
with:
name: sphinx-documentation
path: docs/_build/html
12 changes: 12 additions & 0 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Release Package to Test Environment

on:
workflow_dispatch:

jobs:
release-test:
uses: scipopt/PyGCGOpt/.github/workflows/release.yml@f2599b88caf1731cd0585a92e89b8e0d6e4670f2
with:
production: false
secrets:
PYPI_API_TOKEN: ${{ secrets.TESTPYPI_API_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release Package

on:
workflow_call:
inputs:
production:
type: boolean
required: true
default: false

jobs:
Build-Package-Linux:
runs-on: ubuntu-20.04
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Setup SCIPOptSuite
uses: ./.github/actions/setup-scipoptsuite-action

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
requirements.txt
- name: Prepare Python Environment
run: |
pip install -r requirements.txt
- name: Setup PySCIPOpt
uses: ./.github/actions/setup-pyscipopt-action
with:
ref: scip-8

- name: Build PyGCGOpt
run: |
python -m build --sdist --no-isolation --outdir dist/
- name: Install PyGCGOpt
run: |
pip install dist/*.tar.gz
- name: Upload PyGCGOpt dist artifacts
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/

Release-PyPI:
needs: [Build-Package-Linux]
runs-on: ubuntu-20.04
steps:
- name: Download PyGCGOpt dist artifacts
uses: actions/download-artifact@v2
with:
name: dist

- name: "Publish to pypi.org"
if: ${{ inputs.production }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
packages_dir: dist/

- name: "Publish to test.pypi.org"
if: ${{ !inputs.production }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
packages_dir: dist/
13 changes: 6 additions & 7 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sphinx
sphinx_copybutton
furo
myst_parser
nbsphinx
jupyter

Sphinx==4.3.1
sphinx_copybutton==0.4.0
furo==2021.11.23
myst-parser==0.15.2
nbsphinx==0.8.7
jupyter==1.0.0
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build==0.7.0
Cython==0.29.24

0 comments on commit 97a23ba

Please sign in to comment.