Skip to content

Commit

Permalink
BUILD: Add GitHub CI & CD workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSWang committed Oct 9, 2024
1 parent 0924082 commit 22257fe
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Provide continuous delivery (CD).
#
# CD deliverables currently include:
# - Cuba shared library (built from C sources);
#
name: continuous-delivery

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.post[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+'
paths:
- .github/workflows/cd.yml
workflow_dispatch:
inputs:
rebuild_sharedlib:
description: 'Rebuild shared library'
type: boolean
default: false
required: false
version_tag:
description: 'Version tag for delivery'
type: string
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_sharedlib:
name: Build shared library

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
compiler: [gcc, llvm]
exclude:
- os: ubuntu-latest
compiler: llvm

runs-on: ${{ matrix.os }}

timeout-minutes: 20

if: >
github.event_name != 'workflow_dispatch' ||
github.event.inputs.rebuild_sharedlib == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Override compiler (macOS)
if: runner.os == 'macOS'
run: |
if [ "${{ matrix.compiler }}" == 'gcc' ]; then
export CC=$(find $(brew --prefix gcc)/bin -type f -name 'gcc*')
fi
if [ "${{ matrix.compiler }}" == 'llvm' ]; then
export CC=$(brew --prefix llvm@15)/bin/clang
fi
- name: Build shared library
run: ./make_sharedlib.sh

- name: Upload shared library
uses: actions/upload-artifact@v4
with:
name: libcuba-${{ github.ref_name }}
path: dist/libcuba.*
95 changes: 95 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Perform continuous integration (CI) checks.
#
# CI tasks include but are not limited to:
# - development builds (on all supported OS);
# - unit/integration tests;
# - code linting.
#
name: continuous-integration

on:
push:
branches:
- main
paths:
- src/**
- patches/**
- make*
- config*
- setup.py
- pyproject.toml
- .gitignore
- .github/workflows/ci.yml
pull_request:
types: [opened, synchronize, reopened]
paths:
- src/**
- patches/**
- make*
- config*
- setup.py
- pyproject.toml
- .gitignore
- .github/workflows/ci.yml
pull_request_review:
types: [submitted, edited]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-test-dev:
name: Build & test (in dev mode)

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}

timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Python build requirements
run: python -m pip install --upgrade pip

- name: Build and install
run: python -m pip install --editable . -vvv

- name: Demo test
run: python -c "from pycuba import demo; demo()"

lint:
name: Lint

runs-on: ubuntu-latest

timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Python linting requirements
run: python -m pip install flake8

- name: Lint
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --statistics

0 comments on commit 22257fe

Please sign in to comment.