Skip to content

Commit

Permalink
Rework the GitHub Actions files.
Browse files Browse the repository at this point in the history
 - Use the new mithro/actions-includes for common functionality.
 - Refactor common functionality into their own include actions.

Signed-off-by: Tim 'mithro' Ansell <[email protected]>
  • Loading branch information
mithro committed Mar 2, 2021
1 parent 3942eca commit 2137848
Show file tree
Hide file tree
Showing 13 changed files with 995 additions and 149 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Copyright (C) 2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

name: 🧰 Checkout
description: "Checkout the git repository correctly"

runs:
using: "composite"
using: "includes"

steps:
- name: 🧰 Checkout
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Copyright (C) 2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

name: "Setup system for package"
description: "Set up system with Python environment and dependencies ready for the package."
inputs:
Expand Down Expand Up @@ -27,13 +35,13 @@ inputs:
default: false

runs:
using: "composite"
using: "includes"

steps:
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ input.python-version }}
python-version: ${{ inputs.python-version }}

- name: Install latest pip
run: |
Expand All @@ -60,7 +68,7 @@ runs:
run: |
pip install twine auditwheel
- uses: ./.github/workflows/checkout
- includes: /checkout
if: inputs.git-checkout

- name: Install development system dependencies (Ubuntu)
Expand Down
60 changes: 60 additions & 0 deletions .github/actions/upload-to-pypi/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (C) 2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

name: "Publish packages into PyPI"
description: "Check the packages and then publish packages onto Test and real versions."
inputs:
type:
description: 'Type of packages to publish to PyPi.'
required: true
root_repo:
description: 'Repository name that should be publishing packages to PyPi.'
required: true
root_branch:
description: 'Default branch to publish packages from.'
required: true
default: refs/heads/master

runs:
using: "includes"

steps:
- name: ✔︎ Check 📦
run: |
for WHEEL in dist/*.whl; do
echo
echo "::group::Checking $WHEEL"
echo
python -m zipfile --list $WHEEL
echo
auditwheel show $WHEEL
echo
twine check $WHEEL
echo
echo "::endgroup::"
done
- name: 📤 Publish ${{ inputs.type }} to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }}
if: env.TWINE_PASSWORD != null
run: |
twine upload --skip-existing --verbose --repository testpypi dist/*
- name: 📤 Publish source to PyPI
if: |
(github.ref == inputs.root_branch) &&
(github.event_name != 'pull_request') &&
(github.repository == inputs.root_repo) &&
env.TWINE_PASSWORD != null
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
42 changes: 42 additions & 0 deletions .github/workflows-src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (C) 2017-2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

# Set up a Python environment to run the actions_include tool on.
ENV_DIR = venv
PYTHON = $(ENV_DIR)/bin/python3
ACTIVATE = source $(ENV_DIR)/bin/activate;

env: requirements.txt
rm -rf $(ENV_DIR)
virtualenv --copies $(ENV_DIR)
$(ACTIVATE) pip install -r $<
touch --reference=$< $(PYTHON)

.PHONY: env

$(PYTHON): requirements.txt
make env

# Generate the output files
SRC_YAML = $(wildcard *.yml)
OUT_YAML = $(addprefix ../workflows/,$(SRC_YAML))

../workflows/%.yml: %.yml | $(PYTHON)
$(ACTIVATE) python -m actions_includes $< $@

update:
@for F in $(SRC_YAML); do touch $$F; done
make build

build: $(OUT_YAML) | $(PYTHON)
@true

info:
@echo 'Output files: $(OUT_YAML)'

.PHONY: info
40 changes: 40 additions & 0 deletions .github/workflows-src/check-functionality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (C) 2017-2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

on:
push:
pull_request:

name: Functionality
jobs:

functionality:
runs-on: ubuntu-20.04

strategy:
matrix:
antlr_runtime_type: [static, shared]
include:
- { python-version: 3.5, TOXENV: py35 }
- { python-version: 3.6, TOXENV: py36 }
- { python-version: 3.7, TOXENV: py37 }
- { python-version: 3.8, TOXENV: py38 }
- { python-version: 3.9, TOXENV: py39 }
fail-fast: false

name: Functionality on Python ${{ matrix.python-version }} (with ${{ matrix.antlr_runtime_type}} antlr)

steps:
- includes: /system-setup
with:
development-tools: true
python-version: ${{ matrix.python-version }}

- name: Run Tests
run: |
ANTLR4_RUNTIME_TYPE=${{ matrix.antlr_runtime_type }} tox -e ${{ matrix.TOXENV }}
126 changes: 126 additions & 0 deletions .github/workflows-src/check-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Copyright (C) 2017-2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

name: Install from

on:
push:
pull_request:


jobs:

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

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

steps:
- includes: /system-setup
with:
os: ${{ matrix.os }}
git-checkout: false

- name: Test installation
shell: bash
run: |
pip install git+https://github.com/${GITHUB_REPOSITORY}.git@${GITHUB_SHA}#egg=fasm
- name: Run smoke test
run: |
fasm --help
# - name: Run tests against installed version
# run: |
# cd tests; python test_simple.py

Checkout:
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-20.04]
cmd:
- python setup.py install
- pip install .
- pip install -e . # Editable install
fail-fast: false

name: Checkout with '${{ matrix.cmd }}' (${{ matrix.os }})
runs-on: ${{ matrix.os }}

steps:
- includes: /system-setup
with:
os: ${{ matrix.os }}

- name: Install using '${{ matrix.cmd }}'
run: |
${{ matrix.cmd }}
- name: Run smoke test
run: |
fasm --help
- name: Run tests against installed version
run: |
cd tests; python test_simple.py
Wheel:
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-20.04]
fail-fast: false

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

steps:
- includes: /system-setup
with:
os: ${{ matrix.os }}

- name: Build wheel
run: |
python setup.py bdist_wheel
- name: Upload wheel
uses: actions/upload-artifact@v2
with:
name: fasm
path: dist

- name: Install wheel
run: |
pip install dist/*.whl
- name: Run smoke test
run: |
fasm --help
- name: Run tests against installed version
run: |
cd tests; python test_simple.py
make-env:
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-20.04]
fail-fast: false

name: make-env (Conda)
runs-on: ${{ matrix.os }}

steps:
- includes: /system-setup
with:
os: ${{ matrix.os }}

- name: Run tests
run: |
make tests
39 changes: 39 additions & 0 deletions .github/workflows-src/check-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC

name: Style

on:
push:
pull_request:

jobs:

Style:
runs-on: ubuntu-20.10

steps:
- includes: /system-setup
with:
development-tools: true

- name: Check license headers
run: make check-license

- name: Python style check
run: |
make format lint
test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
- name: Python script checks
run: make check-python-scripts

- name: C++ style check
run: |
make format-cpp
test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
Loading

0 comments on commit 2137848

Please sign in to comment.