Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup requirements a little and remove setup.cfg file. #64

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/checkout/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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: "includes"

steps:
- name: 🧰 Checkout
uses: actions/checkout@v2
with:
# Always clone the full depth so git-describe works.
fetch-depth: 0
submodules: true
46 changes: 46 additions & 0 deletions .github/actions/download-and-run-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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: Download and run tests
description: "Download the tests from GitHub and run them."

runs:
using: "includes"

steps:

- name: Smoke Test - Run fasm tool
run: |
fasm --help

- name: Smoke Test - Import fasm module
shell: python
run: |
import fasm

- name: Smoke Test - Print fasm version info
includes-script: fasm-version.py

- name: Getting the tests
includes-script: get-tests.sh

- name: List Tests
shell: bash
run: |
echo "::group::Top directory"
ls -l tests
echo "::endgroup::"
echo "::group::Files found"
find tests -type f | sort
echo "::endgroup::"

- name: Run Tests
shell: bash
run: |
cd tests
python test_simple.py
26 changes: 26 additions & 0 deletions .github/actions/download-and-run-tests/fasm-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python

import fasm.version

l = []

print()
print(' FASM library version info')
print('='*75)

kl = max(len(k) for k in dir(fasm.version))
for k in dir(fasm.version):
if '__' in k:
continue
v = getattr(fasm.version, k)
if isinstance(v, str) and '\n' in v:
l.append((k,v))
else:
print(" {!s}: {!r}".format(k.rjust(kl), v))

for k, v in l:
print()
print(k)
print('-'*75)
print(v)
print('-'*75)
54 changes: 54 additions & 0 deletions .github/actions/download-and-run-tests/get-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
if [ -d tests ]; then
echo "::group::Using existing tests"
ls -l tests
echo "::endgroup::"
else
echo "::group::Event info"
cat ${GITHUB_EVENT_PATH}
echo "::endgroup::"
echo "::group::GitHub info"
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
echo " GITHUB_ACTOR: ${GITHUB_ACTOR}"
echo " GITHUB_REF: ${GITHUB_REF}"
echo " GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
echo " GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}"
echo " GITHUB_SHA: ${GITHUB_SHA}"
echo "::endgroup::"
echo "::group::Downloading tests from ${GITHUB_REPOSITORY}"
set -x
mkdir .checkout-tests
cd .checkout-tests
git init
git config core.sparseCheckout true
if [ -f .git/info/sparse-checkout ]; then
rm .git/info/sparse-checkout
fi
echo "tests/*" >> .git/info/sparse-checkout
echo "examples/*" >> .git/info/sparse-checkout
git remote add origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git
git fetch --all
git remote -v
if [ ! -z "${GITHUB_REF}" ]; then
git fetch --refmap='' origin ${GITHUB_REF}:refs/remotes/origin/merge || true
fi
if [ ! -z "${GITHUB_BASE_REF}" ]; then
git fetch --refmap='' origin refs/heads/${GITHUB_BASE_REF}:refs/remotes/origin/base || true
fi
if [ ! -z "${GITHUB_HEAD_REF}" ]; then
git fetch --refmap='' origin refs/heads/${GITHUB_HEAD_REF}:refs/remotes/origin/head || true
fi
git remote show origin
git branch -v -a

git show-ref ${GITHUB_SHA} || true
git rev-parse --verify "sha^${GITHUB_SHA}" || true

git fetch -q https://github.com/SymbiFlow/fasm.git ${GITHUB_SHA}
git rev-parse FETCH_HEAD
git checkout ${GITHUB_SHA}
for i in *; do
cp -rvf $i ..
done
cd ..
echo "::endgroup::"
fi
93 changes: 93 additions & 0 deletions .github/actions/system-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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:
python-version:
description: 'Python version to use.'
required: true
default: 3.x
os:
description: 'Operating system in use.'
required: true
default: ubuntu-latest
system-dependencies:
description: 'Install the system dependencies on the operating system.'
required: true
default: true
packaging-tools:
description: 'Install the tools required for packaging.'
required: false
default: false
git-checkout:
description: 'Download the repository from git.'
required: true
default: true
development-tools:
description: 'Install the tools required for development.'
required: true
default: false

runs:
using: "includes"

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

- name: Install latest pip
run: |
pip install -U pip

- name: Install package's system dependencies (Ubuntu)
if: inputs.system-dependencies && startsWith(inputs.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y cmake default-jre-headless uuid-dev libantlr4-runtime-dev

- name: Install package's system dependencies (Mac OS X)
if: inputs.system-dependencies && startsWith(inputs.os, 'macos')
run: |
true

- name: Install package's system dependencies (Windows)
if: inputs.system-dependencies && startsWith(inputs.os, 'windows')
run: |
true

- name: Install packaging tooling
if: inputs.packaging-tools
run: |
pip install twine auditwheel build

- includes: /checkout
if: inputs.git-checkout

- name: Install developer tooling's system dependencies (Ubuntu)
if: inputs.development-tools && startsWith(inputs.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y clang-format

- name: Install developer tooling's system dependencies (Mac OS X)
if: inputs.development-tools && startsWith(inputs.os, 'macos')
run: |
true

- name: Install developer tooling's system dependencies (Windows)
if: inputs.development-tools && startsWith(inputs.os, 'windows')
run: |
true

- name: Install development tools
if: inputs.development-tools
run: |
pip install -r requirements.txt
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/*
46 changes: 46 additions & 0 deletions .github/workflows-src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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)
@echo
@echo Updating $@
@echo ------------------------------------------------
$(ACTIVATE) python -m actions_includes $< $@
@echo ------------------------------------------------

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 }}
Loading