Skip to content

bag-pr-ci

bag-pr-ci #20

Workflow file for this run

# CI flow
name: bag-pr-ci
on:
push:
schedule:
- cron: '0 9 * * *' # 9AM UTC = 2AM PST
env:
CONDA_ENV_NAME: bag_py3d7_c
jobs:
build_pybag:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash -el {0}
continue-on-error: true
strategy:
matrix:
python-version: ["3.7"]
steps:
- name: Checkout submodule
uses: actions/checkout@v3
with:
submodules: recursive
# Phase 1: Conda setup
- name: Setup conda
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
python-version: ${{ matrix.python-version }}
auto-activate-base: false
- name: Save Conda Env
# Workaround, this isn't working otherwise.
run: |
echo "CONDA=$CONDA"
echo "CONDA=$CONDA" >> "$GITHUB_ENV"
- name: Cache Conda env
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs/${{ env.CONDA_ENV_NAME }}
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('environment.yml') }}-${{
env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache-conda
- name: Install packages
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
sudo apt update
sudo apt -y install \
autoconf \
curl \
gcc-8 \
g++-8 \
git \
libtool \
libltdl-dev \
pkg-config \
make \
- name: Update conda environment
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
echo "env.conda=${{ env.CONDA }}"
conda env update -n ${{ env.CONDA_ENV_NAME }} -f environment.yml
- name: Install additional dependencies
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
cd pybag/setup
mkdir install
cp setup_script.sh install/
cp render_template.py install/
cp project-config.template install/
cd install
./setup_script.sh
# Phase 2: Build pybag
- name: Get pybag commit string
run: |
cd pybag
export PYBAG_COMMIT="$(git rev-parse HEAD)"
echo $PYBAG_COMMIT
echo "PYBAG_COMMIT=$PYBAG_COMMIT" >> "$GITHUB_ENV"
- name: Cache pybag
id: cache-pybag
uses: actions/cache@v4
with:
path: pybag/_build
key:
pybag-${{ runner.os }}--${{ runner.arch }}--${{
hashFiles('environment.yml') }}-${{
env.PYBAG_COMMIT }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
- name: Build pybag
if: (steps.cache-pybag.outputs.cache-hit != 'true') || (steps.cache-conda.outputs.cache-hit != 'true')
id: cpp-build
run: |
cd pybag
export PYBAG_PYTHON=python
echo "PYBAG_PYTHON=$PYBAG_PYTHON"
./run_test.sh
tests:
needs: build_pybag
defaults:
run:
shell: bash -el {0}
runs-on: ubuntu-latest
continue-on-error: true
outputs:
pytestOutput: ${{ steps.unit-tests.outputs.test }}
mypyOutput: ${{ steps.type-checks.outputs.test }}
strategy:
matrix:
python-version: ["3.7"]
steps:
- name: Checkout submodule
uses: actions/checkout@v3
with:
submodules: recursive
# Phase 1: Conda cache load
- name: Setup conda
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
python-version: ${{ matrix.python-version }}
auto-activate-base: false
- name: Save Conda Env
# Workaround, this isn't working otherwise.
run: |
echo "CONDA=$CONDA"
echo "CONDA=$CONDA" >> "$GITHUB_ENV"
- name: Cache Conda env
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs/${{ env.CONDA_ENV_NAME }}
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('environment.yml') }}-${{
env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache-conda
# Phase 2: Pybag cache load
- name: Get pybag commit string
run: |
cd pybag
export PYBAG_COMMIT="$(git rev-parse HEAD)"
echo $PYBAG_COMMIT
echo "PYBAG_COMMIT=$PYBAG_COMMIT" >> "$GITHUB_ENV"
- name: Cache pybag
id: cache-pybag
uses: actions/cache@v4
with:
path: pybag/_build
key:
pybag-${{ runner.os }}--${{ runner.arch }}--${{
hashFiles('environment.yml') }}-${{
env.PYBAG_COMMIT }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
# Phase 3: Run tests
- name: Set python path
run: |
export PYTHONPATH="$(pwd)/tests:$(pwd)/pybag/_build/lib:$(pwd)/src"
echo $PYTHONPATH
echo "PYTHONPATH=$PYTHONPATH" >> "$GITHUB_ENV"
- name: Run simple test
id: simple-test
run: |
python tests/run_core.py
- name: Run unit tests
id: unit-tests
run: |
pytest tests/ -v