Skip to content

Code CI

Code CI #302

Workflow file for this run

name: Code CI
# When to trigger
on:
push:
branches:
- master
- main
tags:
- "*"
pull_request:
schedule:
# Run every Monday at 8am
- cron: '0 8 * * MON'
# Global environment
# env:
# # EPICS Base version for system block IOC
# EPICS_BASE_VER: R3.14.12.7
# EPICS_BASE_DIR: epics_base
# Jobs
jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.7.2"]
# pipenv: ["skip-lock"] # Use latest available dependencies
# Extra job for publishing using Pipfile.lock
include:
- python-version: "3.7.2"
pipenv: "deploy"
publish: true
name: build/${{ matrix.python-version }}/${{ matrix.pipenv }}
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
# require all of history to see all tagged versions' docs
fetch-depth: 0
- name: Install packages
run: sudo apt-get install graphviz
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setup Git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "Mr. Malcolm"
# - name: Cache EPICS Base
# uses: actions/cache@v2
# id: epics-base-cache
# with:
# path: ${{ env.EPICS_BASE_DIR }}
# key: epics_base-${{ runner.os }}-${{ env.EPICS_BASE_VER }}
# - name: Install EPICS Base
# if: steps.epics-base-cache.outputs.cache-hit != 'true'
# run: |
# wget -nv https://github.com/epics-base/epics-base/archive/${EPICS_BASE_VER}.tar.gz
# tar -zxf ${EPICS_BASE_VER}.tar.gz
# mv epics-base-${EPICS_BASE_VER} ${EPICS_BASE_DIR}
# make -isj -C ${EPICS_BASE_DIR}/
# - name: Set EPICS Base path
# run: echo "EPICS_BASE=`pwd`/${EPICS_BASE_DIR}" >> $GITHUB_ENV
- name: Install Python dependencies
run: |
env
pip install pipenv
pipenv install --dev --${{ matrix.pipenv }} --python ${{ matrix.python-version }} && pipenv graph
- name: Create Sdist and Wheel
# for reproducible builds set SOURCE_DATE_EPOCH to the date of the last commit
# See here for more info : https://reproducible-builds.org/
# Also use the same version of wheel as inside DLS
run: |
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
pip install "wheel==0.37.0"
python setup.py sdist bdist_wheel
- name: Flake8
run: pipenv run flake8
- name: Pytest
run: |
set -o pipefail
pipenv run tests
# - name: Coverage
# if: matrix.publish
# uses: codecov/codecov-action@v2
# with:
# fail_ci_if_error: true # optional (default = false)
# files: ./coverage.xml
- name: Publish Sdist and Wheel to PyPI
# Only once when on a tag
if: matrix.publish && startsWith(github.ref, 'refs/tags')
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 # v1.4.2
with:
user: __token__
password: ${{ secrets.pypi_token }}