From dfba517233f9063beda98d028972a6d018ba4ada Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 24 Feb 2021 15:07:11 -0800 Subject: [PATCH] Rework the GitHub Actions files. - Use the new mithro/actions-includes for common functionality. - Refactor common functionality into their own include actions. Signed-off-by: Tim 'mithro' Ansell --- .../checkout/action.yaml | 10 +- .../download-and-run-tests/action.yaml | 46 + .../download-and-run-tests/fasm-version.py | 26 + .../download-and-run-tests/get-tests.sh | 53 ++ .../system-setup/action.yaml | 24 +- .github/actions/upload-to-pypi/action.yaml | 60 ++ .github/workflows-src/Makefile | 46 + .github/workflows-src/check-functionality.yml | 40 + .github/workflows-src/check-install.yml | 199 ++++ .github/workflows-src/check-style.yml | 39 + .github/workflows-src/publish-to-pypi.yml | 115 +++ .github/workflows-src/requirements.txt | 1 + .github/workflows/check-functionality.yml | 97 +- .github/workflows/check-install.yml | 858 ++++++++++++++++-- .github/workflows/check-style.yml | 74 +- .github/workflows/publish-to-pypi.yml | 288 ++++-- Makefile | 18 + requirements.txt | 2 + 18 files changed, 1831 insertions(+), 165 deletions(-) rename .github/{workflows => actions}/checkout/action.yaml (51%) create mode 100644 .github/actions/download-and-run-tests/action.yaml create mode 100644 .github/actions/download-and-run-tests/fasm-version.py create mode 100644 .github/actions/download-and-run-tests/get-tests.sh rename .github/{workflows => actions}/system-setup/action.yaml (77%) create mode 100644 .github/actions/upload-to-pypi/action.yaml create mode 100644 .github/workflows-src/Makefile create mode 100644 .github/workflows-src/check-functionality.yml create mode 100644 .github/workflows-src/check-install.yml create mode 100644 .github/workflows-src/check-style.yml create mode 100644 .github/workflows-src/publish-to-pypi.yml create mode 100644 .github/workflows-src/requirements.txt diff --git a/.github/workflows/checkout/action.yaml b/.github/actions/checkout/action.yaml similarity index 51% rename from .github/workflows/checkout/action.yaml rename to .github/actions/checkout/action.yaml index f3f575d3..7da7fe73 100644 --- a/.github/workflows/checkout/action.yaml +++ b/.github/actions/checkout/action.yaml @@ -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 diff --git a/.github/actions/download-and-run-tests/action.yaml b/.github/actions/download-and-run-tests/action.yaml new file mode 100644 index 00000000..b4eaceac --- /dev/null +++ b/.github/actions/download-and-run-tests/action.yaml @@ -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 diff --git a/.github/actions/download-and-run-tests/fasm-version.py b/.github/actions/download-and-run-tests/fasm-version.py new file mode 100644 index 00000000..dc0abd3c --- /dev/null +++ b/.github/actions/download-and-run-tests/fasm-version.py @@ -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) diff --git a/.github/actions/download-and-run-tests/get-tests.sh b/.github/actions/download-and-run-tests/get-tests.sh new file mode 100644 index 00000000..f692ca6f --- /dev/null +++ b/.github/actions/download-and-run-tests/get-tests.sh @@ -0,0 +1,53 @@ +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} + git rev-parse --verify 'sha^${GITHUB_SHA}' + 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 diff --git a/.github/workflows/system-setup/action.yaml b/.github/actions/system-setup/action.yaml similarity index 77% rename from .github/workflows/system-setup/action.yaml rename to .github/actions/system-setup/action.yaml index 4b3461ec..f832dff0 100644 --- a/.github/workflows/system-setup/action.yaml +++ b/.github/actions/system-setup/action.yaml @@ -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: @@ -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: | @@ -58,28 +66,28 @@ runs: - name: Install packaging tooling if: inputs.packaging-tools run: | - pip install twine auditwheel + pip install twine auditwheel build - - uses: ./.github/workflows/checkout + - includes: /checkout if: inputs.git-checkout - - name: Install development system dependencies (Ubuntu) + - 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 development system dependencies (Mac OS X) + - name: Install developer tooling's system dependencies (Mac OS X) if: inputs.development-tools && startsWith(inputs.os, 'macos') run: | true - - name: Install development system dependencies (Windows) + - name: Install developer tooling's system dependencies (Windows) if: inputs.development-tools && startsWith(inputs.os, 'windows') run: | true - - name: Install development tooling + - name: Install development tools if: inputs.development-tools run: | pip install -r requirements.txt diff --git a/.github/actions/upload-to-pypi/action.yaml b/.github/actions/upload-to-pypi/action.yaml new file mode 100644 index 00000000..f4736267 --- /dev/null +++ b/.github/actions/upload-to-pypi/action.yaml @@ -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/* diff --git a/.github/workflows-src/Makefile b/.github/workflows-src/Makefile new file mode 100644 index 00000000..9e02ad59 --- /dev/null +++ b/.github/workflows-src/Makefile @@ -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 diff --git a/.github/workflows-src/check-functionality.yml b/.github/workflows-src/check-functionality.yml new file mode 100644 index 00000000..67e602b7 --- /dev/null +++ b/.github/workflows-src/check-functionality.yml @@ -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 }} diff --git a/.github/workflows-src/check-install.yml b/.github/workflows-src/check-install.yml new file mode 100644 index 00000000..ff629970 --- /dev/null +++ b/.github/workflows-src/check-install.yml @@ -0,0 +1,199 @@ +# 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: + + # Install directly using pip from GitHub + # ---------------------------------------------------------------------- + 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: Installing directly from GitHub + shell: bash + run: | + pip install --verbose git+https://github.com/${GITHUB_REPOSITORY}.git@${GITHUB_SHA}#egg=fasm + + - includes: /download-and-run-tests + # ---------------------------------------------------------------------- + + # Install using a local checkout + # ---------------------------------------------------------------------- + Checkout: + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-20.04] + cmd: + - python setup.py install + - pip install --verbose . + - pip install --verbose -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: Installing using '${{ matrix.cmd }}' + run: | + ${{ matrix.cmd }} + + - includes: /download-and-run-tests + # ---------------------------------------------------------------------- + + # Install into self-contained `make-env` environment. + # ---------------------------------------------------------------------- + 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 test + # ---------------------------------------------------------------------- + + # Install from a sdist package + # ---------------------------------------------------------------------- + BuildSdist: + strategy: + matrix: + os: [ubuntu-20.04] + fail-fast: false + + runs-on: ${{ matrix.os }} + + steps: + - includes: /system-setup + with: + os: ${{ matrix.os }} + packaging-tools: true + + - name: Build wheel + run: | + python -m build --sdist + + - name: Upload wheel + uses: actions/upload-artifact@v2 + with: + name: fasm-sdist + path: dist + + sdist: + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-20.04] + fail-fast: false + + runs-on: ${{ matrix.os }} + needs: BuildSdist + + steps: + - includes: /system-setup + with: + os: ${{ matrix.os }} + git-checkout: false + + - name: Download sdist + uses: actions/download-artifact@v2 + with: + name: fasm-sdist + path: dist + + - name: Installing using the sdist + shell: bash + run: | + ls -l dist/* + pip install --verbose dist/* + + - includes: /download-and-run-tests + # ---------------------------------------------------------------------- + + # Install from a binary wheel package + # ---------------------------------------------------------------------- + BuildWheel: + 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 }} + packaging-tools: true + + - name: Build wheel + run: | + python -m build --wheel + + - name: Upload wheel + uses: actions/upload-artifact@v2 + with: + name: fasm-wheel-${{ matrix.os }} + path: dist + + Wheel: + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-20.04] + fail-fast: false + + runs-on: ${{ matrix.os }} + needs: BuildWheel + + steps: + - includes: /system-setup + with: + os: ${{ matrix.os }} + git-checkout: false + + - name: Download wheel + uses: actions/download-artifact@v2 + with: + name: fasm-wheel-${{ matrix.os }} + path: dist + + - name: Installing using the wheel + run: | + ls -l dist/* + pip install --verbose dist/*.whl + + - includes: /download-and-run-tests + # ---------------------------------------------------------------------- diff --git a/.github/workflows-src/check-style.yml b/.github/workflows-src/check-style.yml new file mode 100644 index 00000000..f9ab4f7e --- /dev/null +++ b/.github/workflows-src/check-style.yml @@ -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.04 + + 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; } diff --git a/.github/workflows-src/publish-to-pypi.yml b/.github/workflows-src/publish-to-pypi.yml new file mode 100644 index 00000000..2a1e4eae --- /dev/null +++ b/.github/workflows-src/publish-to-pypi.yml @@ -0,0 +1,115 @@ +# 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: PyPI + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + + Source: + name: Source + runs-on: ubuntu-20.04 + + steps: + - includes: /system-setup + with: + packaging-tools: true + + - name: Install package + run: | + pip install -e . + + - name: 🚧 Build distribution 📦 + run: | + python -m build --sdist . + + - includes: /upload-to-pypi + with: + root_repo: SymbiFlow/fasm + type: source + + Linux: + strategy: + matrix: + include: + - { python-version: '3.6', manylinux-python: 'cp36-cp36m' } + - { python-version: '3.7', manylinux-python: 'cp37-cp37m' } + - { python-version: '3.8', manylinux-python: 'cp38-cp38' } + - { python-version: '3.9', manylinux-python: 'cp39-cp39' } + fail-fast: false + + name: '${{ matrix.python-version }} • manylinux' + runs-on: ubuntu-latest + + steps: + - includes: /system-setup + with: + python-version: ${{ matrix.python-version }} + system-dependencies: false + packaging-tools: true + + - name: 🚧 Build distribution 📦 + uses: RalfG/python-wheels-manylinux-build@v0.3.3-manylinux2010_x86_64 + with: + build-requirements: 'cython' + pre-build-command: 'bash .github/workflows/manylinux-install-cmake.sh' + python-versions: ${{ matrix.manylinux-python }} + #pip-wheel-args: '-w ./dist --no-deps --verbose' + + - name: List distribution 📦 + run: | + # Fix permissions + echo "::group::Fixing permission" + ls -l dist/* + echo $USER + whoami + sudo chown -R $USER dist + ls -l dist/* + echo "::endgroup::" + # Remove the non-manylinux versions + rm -v dist/*linux_x86_64*.whl + ls -l dist/* + + - includes: /upload-to-pypi + with: + root_repo: SymbiFlow/fasm + type: wheels + + MacAndWindows: + strategy: + matrix: + os: [windows-latest, macos-latest] + python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy-3.6', 'pypy-3.7' ] + fail-fast: false + + name: ${{ matrix.python-version }} • ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + steps: + - includes: /system-setup + with: + os: ${{ matrix.os }} + python-version: ${{ matrix.python-version }} + packaging-tools: true + + - name: Install package + run: | + pip install -e . + + - name: 🚧 Build distribution 📦 + run: | + python setup.py bdist_wheel + + - includes: /upload-to-pypi + with: + root_repo: SymbiFlow/fasm + type: wheels diff --git a/.github/workflows-src/requirements.txt b/.github/workflows-src/requirements.txt new file mode 100644 index 00000000..b64c895d --- /dev/null +++ b/.github/workflows-src/requirements.txt @@ -0,0 +1 @@ +git+https://github.com/mithro/actions-includes.git#egg=actions-includes diff --git a/.github/workflows/check-functionality.yml b/.github/workflows/check-functionality.yml index ef7c3e6a..9ad66599 100644 --- a/.github/workflows/check-functionality.yml +++ b/.github/workflows/check-functionality.yml @@ -1,36 +1,89 @@ -name: Functionality +# 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 + +# !! WARNING !! +# Do not modify this file directly! +# !! WARNING !! +# +# It is generated from: ../workflows-src/check-functionality.yml +# using the script from https://github.com/mithro/actions-includes@main on: push: pull_request: - +name: Functionality jobs: - - Functionality: - runs-on: ubuntu-latest - + functionality: + runs-on: ubuntu-20.04 strategy: matrix: - antlr_runtime_type: [static, shared] + 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 } + - 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: - - run: | - echo "${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}" - - - uses: mithro/fasm/.github/workflows/system-setup@setupcfg + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false + with: + workflow: .github/workflows/check-functionality.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 with: - development-tools: true python-version: ${{ matrix.python-version }} - - - name: Run Tests + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith('ubuntu-latest', '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: true && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith('ubuntu-latest', 'windows') + run: | + true + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: true && startsWith('ubuntu-latest', 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y clang-format + - name: Install developer tooling's system dependencies (Mac OS X) + if: true && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: true && startsWith('ubuntu-latest', 'windows') run: | - ANTLR4_RUNTIME_TYPE=${{ matrix.antlr_runtime_type }} tox -e ${{ matrix.TOXENV }} + true + - name: Install development tools + run: | + pip install -r requirements.txt + - name: Run Tests + run: ANTLR4_RUNTIME_TYPE=${{ matrix.antlr_runtime_type }} tox -e ${{ matrix.TOXENV }} diff --git a/.github/workflows/check-install.yml b/.github/workflows/check-install.yml index 9fa52e42..b46e702b 100644 --- a/.github/workflows/check-install.yml +++ b/.github/workflows/check-install.yml @@ -1,115 +1,857 @@ -name: Install from +# 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 + +# !! WARNING !! +# Do not modify this file directly! +# !! WARNING !! +# +# It is generated from: ../workflows-src/check-install.yml +# using the script from https://github.com/mithro/actions-includes@main on: push: pull_request: - - +name: Install from jobs: - GitHub: strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: + - windows-latest + - macos-latest + - ubuntu-20.04 fail-fast: false - runs-on: ${{ matrix.os }} - steps: - - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false with: - os: ${{ matrix.os }} - git-checkout: false - - - name: Test installation + workflow: .github/workflows/check-install.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true + - name: Installing directly from GitHub shell: bash run: | - pip install git+https://github.com/${GITHUB_REPOSITORY}.git@${GITHUB_SHA}#egg=fasm - - - name: Run smoke test + pip install --verbose git+https://github.com/${GITHUB_REPOSITORY}.git@${GITHUB_SHA}#egg=fasm + - 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 + run: | + #!/usr/bin/env python + + import fasm.version + + l = [] -# - name: Run tests against installed version -# run: | -# cd tests; python test_simple.py + 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) + shell: python + - name: Getting the tests + run: | + 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} + git rev-parse --verify 'sha^${GITHUB_SHA}' + 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 + shell: bash + - 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 Checkout: strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: + - windows-latest + - macos-latest + - ubuntu-20.04 cmd: - - python setup.py install - - pip install . - - pip install -e . # Editable install + - python setup.py install + - pip install --verbose . + - pip install --verbose -e . fail-fast: false - - name: Checkout with '${{ matrix.cmd }}' + name: Checkout with '${{ matrix.cmd }}' (${{ matrix.os }}) runs-on: ${{ matrix.os }} - steps: - - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false with: - os: ${{ matrix.os }} - - - name: Install using '${{ matrix.cmd }}' + workflow: .github/workflows/check-install.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true + - name: Installing using '${{ matrix.cmd }}' run: | ${{ matrix.cmd }} - - - name: Run smoke test + - 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 + run: | + #!/usr/bin/env python + + import fasm.version + + l = [] - - name: Run tests against installed version + 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) + shell: python + - name: Getting the tests run: | - cd tests; python test_simple.py + 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 - Wheel: + git show-ref ${GITHUB_SHA} + git rev-parse --verify 'sha^${GITHUB_SHA}' + 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 + shell: bash + - 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 + make-env: strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: + - windows-latest + - macos-latest + - ubuntu-20.04 fail-fast: false - + name: make-env (Conda) runs-on: ${{ matrix.os }} - steps: - - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false with: - os: ${{ matrix.os }} - + workflow: .github/workflows/check-install.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true + - name: Run tests + run: | + make test + BuildSdist: + strategy: + matrix: + os: + - ubuntu-20.04 + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false + with: + workflow: .github/workflows/check-install.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: Install packaging tooling + run: | + pip install twine auditwheel build + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true - name: Build wheel run: | - python setup.py bdist_wheel - + python -m build --sdist - name: Upload wheel uses: actions/upload-artifact@v2 with: - name: fasm + name: fasm-sdist path: dist - - - name: Install wheel + sdist: + strategy: + matrix: + os: + - windows-latest + - macos-latest + - ubuntu-20.04 + fail-fast: false + runs-on: ${{ matrix.os }} + needs: BuildSdist + steps: + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false + with: + workflow: .github/workflows/check-install.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip run: | - pip install dist/*.whl - - - name: Run smoke test + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true + - name: Download sdist + uses: actions/download-artifact@v2 + with: + name: fasm-sdist + path: dist + - name: Installing using the sdist + shell: bash + run: | + ls -l dist/* + pip install --verbose dist/* + - 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 + run: | + #!/usr/bin/env python - - name: Run tests against installed version + 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) + shell: python + - name: Getting the tests run: | - cd tests; python test_simple.py + 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 - make-env: + git show-ref ${GITHUB_SHA} + git rev-parse --verify 'sha^${GITHUB_SHA}' + 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 + shell: bash + - 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 + BuildWheel: strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] - - name: make-env (Conda) + os: + - windows-latest + - macos-latest + - ubuntu-20.04 + fail-fast: false runs-on: ${{ matrix.os }} - steps: - - uses: '${{ github.repository }}/.github/workflows/checkout@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false + with: + workflow: .github/workflows/check-install.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: Install packaging tooling + run: | + pip install twine auditwheel build + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true + - name: Build wheel + run: | + python -m build --wheel + - name: Upload wheel + uses: actions/upload-artifact@v2 + with: + name: fasm-wheel-${{ matrix.os }} + path: dist + Wheel: + strategy: + matrix: + os: + - windows-latest + - macos-latest + - ubuntu-20.04 + fail-fast: false + runs-on: ${{ matrix.os }} + needs: BuildWheel + steps: + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false + with: + workflow: .github/workflows/check-install.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true + - name: Download wheel + uses: actions/download-artifact@v2 + with: + name: fasm-wheel-${{ matrix.os }} + path: dist + - name: Installing using the wheel + run: | + ls -l dist/* + pip install --verbose dist/*.whl + - 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 + run: | + #!/usr/bin/env python - - name: Run tests + 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) + shell: python + - name: Getting the tests + run: | + 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} + git rev-parse --verify 'sha^${GITHUB_SHA}' + 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 + shell: bash + - 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: | - make tests + cd tests + python test_simple.py diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml index 4b3cc8c7..f8a6d4c2 100644 --- a/.github/workflows/check-style.yml +++ b/.github/workflows/check-style.yml @@ -1,31 +1,81 @@ -name: Style +# 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 + +# !! WARNING !! +# Do not modify this file directly! +# !! WARNING !! +# +# It is generated from: ../workflows-src/check-style.yml +# using the script from https://github.com/mithro/actions-includes@main on: push: pull_request: - +name: Style jobs: - Style: - runs-on: ubuntu-latest - + runs-on: ubuntu-20.04 steps: - - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false with: - development-tools: true - + workflow: .github/workflows/check-style.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith('ubuntu-latest', '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: true && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith('ubuntu-latest', 'windows') + run: | + true + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: true && startsWith('ubuntu-latest', 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y clang-format + - name: Install developer tooling's system dependencies (Mac OS X) + if: true && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: true && startsWith('ubuntu-latest', 'windows') + run: | + true + - name: Install development tools + run: | + pip install -r requirements.txt - 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: | + run: |- make format-cpp test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; } diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 2b0c8500..babc6cae 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,74 +1,180 @@ -name: PyPI +# 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 + +# !! WARNING !! +# Do not modify this file directly! +# !! WARNING !! +# +# It is generated from: ../workflows-src/publish-to-pypi.yml +# using the script from https://github.com/mithro/actions-includes@main on: push: pull_request: workflow_dispatch: - +name: PyPI jobs: - Source: name: Source - + runs-on: ubuntu-20.04 steps: - - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false with: - packaging-tools: true - + workflow: .github/workflows/publish-to-pypi.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ '3.x' }} + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith('ubuntu-latest', '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: true && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith('ubuntu-latest', 'windows') + run: | + true + - name: Install packaging tooling + run: | + pip install twine auditwheel build + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith('ubuntu-latest', 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y clang-format + - name: Install developer tooling's system dependencies (Mac OS X) + if: false && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith('ubuntu-latest', 'windows') + run: | + true - name: Install package run: | pip install -e . - - name: 🚧 Build distribution 📦 run: | - python setup.py sdist - - - name: Check distribution 📦 + python -m build --sdist . + - name: ✔︎ Check 📦 run: | - twine check dist/* - - - name: 📤 Publish source to Test PyPI + 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 ${{ 'source' }} 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/*.tar.gz - + twine upload --skip-existing --verbose --repository testpypi dist/* - name: 📤 Publish source to PyPI - if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'SymbiFlow/fasm' + if: |- + (github.ref == 'refs/heads/master') && + (github.event_name != 'pull_request') && + (github.repository == 'SymbiFlow/fasm') && + env.TWINE_PASSWORD != null env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | twine upload dist/* - Linux: strategy: matrix: include: - - { python-version: '3.6', manylinux-python: 'cp36-cp36m' } - - { python-version: '3.7', manylinux-python: 'cp37-cp37m' } - - { python-version: '3.8', manylinux-python: 'cp38-cp38' } - - { python-version: '3.9', manylinux-python: 'cp39-cp39' } + - python-version: '3.6' + manylinux-python: cp36-cp36m + - python-version: '3.7' + manylinux-python: cp37-cp37m + - python-version: '3.8' + manylinux-python: cp38-cp38 + - python-version: '3.9' + manylinux-python: cp39-cp39 fail-fast: false - - name: '${{ matrix.name }} • manylinux' - + name: ${{ matrix.python-version }} • manylinux + runs-on: ubuntu-latest steps: - - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false + with: + workflow: .github/workflows/publish-to-pypi.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - packaging-tools: true - + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: false && startsWith('ubuntu-latest', '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: false && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: false && startsWith('ubuntu-latest', 'windows') + run: | + true + - name: Install packaging tooling + run: | + pip install twine auditwheel build + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith('ubuntu-latest', 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y clang-format + - name: Install developer tooling's system dependencies (Mac OS X) + if: false && startsWith('ubuntu-latest', 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith('ubuntu-latest', 'windows') + run: | + true - name: 🚧 Build distribution 📦 uses: RalfG/python-wheels-manylinux-build@v0.3.3-manylinux2010_x86_64 with: - build-requirements: 'cython' - pre-build-command: 'bash .github/workflows/manylinux-install-cmake.sh' + build-requirements: cython + pre-build-command: bash .github/workflows/manylinux-install-cmake.sh python-versions: ${{ matrix.manylinux-python }} - #pip-wheel-args: '-w ./dist --no-deps --verbose' - - name: List distribution 📦 run: | # Fix permissions @@ -82,8 +188,7 @@ jobs: # Remove the non-manylinux versions rm -v dist/*linux_x86_64*.whl ls -l dist/* - - - name: Check distribution 📦 + - name: ✔︎ Check 📦 run: | for WHEEL in dist/*.whl; do echo @@ -97,67 +202,122 @@ jobs: echo echo "::endgroup::" done - - - name: 📤 Publish wheels to Test PyPI + - name: 📤 Publish ${{ 'wheels' }} 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/*.whl - - - name: 📤 Publish wheels to PyPI - if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'SymbiFlow/fasm' + twine upload --skip-existing --verbose --repository testpypi dist/* + - name: 📤 Publish source to PyPI + if: |- + (github.ref == 'refs/heads/master') && + (github.event_name != 'pull_request') && + (github.repository == 'SymbiFlow/fasm') && + env.TWINE_PASSWORD != null env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - twine upload dist/*.whl - + twine upload dist/* MacAndWindows: strategy: matrix: - os: [windows-latest, macos-latest] - python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy-3.6', 'pypy-3.7' ] + os: + - windows-latest + - macos-latest + python-version: + - '3.6' + - '3.7' + - '3.8' + - '3.9' + - pypy-3.6 + - pypy-3.7 fail-fast: false - name: ${{ matrix.python-version }} • ${{ matrix.os }} runs-on: ${{ matrix.os }} - steps: - - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + - uses: mithro/actions-includes@main + if: runner.os == 'Linux' + continue-on-error: false + with: + workflow: .github/workflows/publish-to-pypi.yml + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 with: - os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} - packaging-tools: true - + - name: Install latest pip + run: | + pip install -U pip + - name: Install package's system dependencies (Ubuntu) + if: true && startsWith(matrix.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: true && startsWith(matrix.os, 'macos') + run: | + true + - name: Install package's system dependencies (Windows) + if: true && startsWith(matrix.os, 'windows') + run: | + true + - name: Install packaging tooling + run: | + pip install twine auditwheel build + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + - name: Install developer tooling's system dependencies (Ubuntu) + if: false && startsWith(matrix.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: false && startsWith(matrix.os, 'macos') + run: | + true + - name: Install developer tooling's system dependencies (Windows) + if: false && startsWith(matrix.os, 'windows') + run: | + true - name: Install package run: | pip install -e . - - name: 🚧 Build distribution 📦 run: | python setup.py bdist_wheel - - - name: Check distribution 📦 - shell: bash + - name: ✔︎ Check 📦 run: | - python -m zipfile -l dist/* - echo - twine check dist/* - - - name: 📤 Publish wheels to Test PyPI + 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 ${{ 'wheels' }} 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/*.whl - - - name: 📤 Publish wheels to PyPI - if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'SymbiFlow/fasm' + twine upload --skip-existing --verbose --repository testpypi dist/* + - name: 📤 Publish source to PyPI + if: |- + (github.ref == 'refs/heads/master') && + (github.event_name != 'pull_request') && + (github.repository == 'SymbiFlow/fasm') && + env.TWINE_PASSWORD != null env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - twine upload dist/*.whl + twine upload dist/* diff --git a/Makefile b/Makefile index b9ed7321..0464a064 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,13 @@ install: setup.py | $(CONDA_ENV_PYTHON) .PHONY: install +# Info about the environment +info: + @make --no-print-directory env-info + @echo + @$(IN_CONDA_ENV) python -W ignore .github/actions/download-and-run-tests/fasm-version.py + +.PHONY: info # Build/install locally rather than inside the environment. # ------------------------------------------------------------------------ @@ -120,6 +127,17 @@ format-cpp: .PHONY: format-cpp +# Format the GitHub workflow files +GHA_WORKFLOW_SRCS = $(wildcard .github/workflows-src/*.yml) +GHA_WORKFLOW_OUTS = $(addprefix .github/workflows/,$(notdir $(GHA_WORKFLOW_SRCS))) + +.github/workflows/%.yml: .github/workflows-src/%.yml $(CONDA_ENV_PYTHON) + $(IN_CONDA_ENV) python -m actions_includes $< $@ + +format-gha: $(GHA_WORKFLOW_OUTS) + echo $(GHA_WORKFLOW_OUTS) + @true + # Format all the files! format: format-py format-cpp true diff --git a/requirements.txt b/requirements.txt index b0780b84..a238cc05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,5 @@ pytest tox twine yapf==0.24.0 +# CI expansion +git+https://github.com/mithro/actions-includes.git#egg=actions-includes