From 3942ecaf51d83560c64f1604b67fd4e098a3ea66 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 21 Feb 2021 12:00:53 -0800 Subject: [PATCH] Rework the github actions workflows. * Create a composite action for setting up the system. * Expand `check-install.yml` to check that installing works from all of; - GitHub - Checked out locally with `python setup.py install` - Checked out locally with `pip install -e .` - Building and then installing wheels. * Remove `wheel.yml` as covered by `check-install.yml`'s building and then installing wheels. Signed-off-by: Tim 'mithro' Ansell --- .github/workflows/check-functionality.yml | 36 +++++++ .github/workflows/check-install.yml | 105 ++++++++++++++++----- .github/workflows/check-style.yml | 31 ++++++ .github/workflows/checkout/action.yaml | 13 +++ .github/workflows/presubmit.yml | 72 -------------- .github/workflows/publish-to-pypi.yml | 98 +++---------------- .github/workflows/system-setup/action.yaml | 85 +++++++++++++++++ .github/workflows/wheel.yml | 50 ---------- 8 files changed, 262 insertions(+), 228 deletions(-) create mode 100644 .github/workflows/check-functionality.yml create mode 100644 .github/workflows/check-style.yml create mode 100644 .github/workflows/checkout/action.yaml delete mode 100644 .github/workflows/presubmit.yml create mode 100644 .github/workflows/system-setup/action.yaml delete mode 100644 .github/workflows/wheel.yml diff --git a/.github/workflows/check-functionality.yml b/.github/workflows/check-functionality.yml new file mode 100644 index 00000000..ef7c3e6a --- /dev/null +++ b/.github/workflows/check-functionality.yml @@ -0,0 +1,36 @@ +name: Functionality + +on: + push: + pull_request: + +jobs: + + Functionality: + runs-on: ubuntu-latest + + 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: + - run: | + echo "${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}" + + - uses: mithro/fasm/.github/workflows/system-setup@setupcfg + 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/check-install.yml b/.github/workflows/check-install.yml index 481778f2..9fa52e42 100644 --- a/.github/workflows/check-install.yml +++ b/.github/workflows/check-install.yml @@ -10,43 +10,106 @@ jobs: GitHub: strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-20.04] + os: [windows-latest, macos-latest, ubuntu-latest] fail-fast: false - name: GitHub runs-on: ${{ matrix.os }} steps: - - name: 🐍 Set up Python - uses: actions/setup-python@v2 + - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' with: - python-version: 3.x + os: ${{ matrix.os }} + git-checkout: false - - name: Install pip + - name: Test installation + shell: bash run: | - pip install --upgrade pip + pip install git+https://github.com/${GITHUB_REPOSITORY}.git@${GITHUB_SHA}#egg=fasm - - name: Install package's system dependencies (Ubuntu) - if: startsWith(matrix.os, 'ubuntu') + - name: Run smoke test run: | - sudo apt-get update - sudo apt-get install -y cmake default-jre-headless uuid-dev libantlr4-runtime-dev + fasm --help + +# - name: Run tests against installed version +# run: | +# cd tests; python test_simple.py + + Checkout: + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] + cmd: + - python setup.py install + - pip install . + - pip install -e . # Editable install + fail-fast: false + + name: Checkout with '${{ matrix.cmd }}' + runs-on: ${{ matrix.os }} - - name: Install package's system dependencies (Mac OS X) - if: startsWith(matrix.os, 'macos') + steps: + - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + with: + os: ${{ matrix.os }} + + - name: Install using '${{ matrix.cmd }}' run: | - true + ${{ matrix.cmd }} - - name: Install package's system dependencies (Windows) - if: startsWith(matrix.os, 'windows') + - name: Run smoke test run: | - true + fasm --help - - name: Test installation - shell: bash + - name: Run tests against installed version run: | - pip install git+https://github.com/${GITHUB_REPOSITORY}.git@${GITHUB_SHA}#egg=fasm + cd tests; python test_simple.py + + Wheel: + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] + fail-fast: false - - name: Run Smoke Test + runs-on: ${{ matrix.os }} + + steps: + - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + 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-latest] + + name: make-env (Conda) + runs-on: ${{ matrix.os }} + + steps: + - uses: '${{ github.repository }}/.github/workflows/checkout@${{ github.sha }}' + + - name: Run tests + run: | + make tests diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml new file mode 100644 index 00000000..4b3cc8c7 --- /dev/null +++ b/.github/workflows/check-style.yml @@ -0,0 +1,31 @@ +name: Style + +on: + push: + pull_request: + +jobs: + + Style: + runs-on: ubuntu-latest + + steps: + - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' + 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/checkout/action.yaml b/.github/workflows/checkout/action.yaml new file mode 100644 index 00000000..f3f575d3 --- /dev/null +++ b/.github/workflows/checkout/action.yaml @@ -0,0 +1,13 @@ +name: 🧰 Checkout +description: "Checkout the git repository correctly" + +runs: + using: "composite" + + steps: + - name: 🧰 Checkout + uses: actions/checkout@v2 + with: + # Always clone the full depth so git-describe works. + fetch-depth: 0 + submodules: true diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml deleted file mode 100644 index aca2f95f..00000000 --- a/.github/workflows/presubmit.yml +++ /dev/null @@ -1,72 +0,0 @@ -# Checks code that code meets requirements for a pull request. -# Any automated checks for code quality and compliance belongs here. -name: presubmit -on: [push, pull_request] -jobs: - check: - name: Source checks - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - with: - # Always clone the full depth so git-describe works. - fetch-depth: 0 - submodules: true - - name: Set up Python - uses: actions/setup-python@v2 - - name: Install dependencies - run: | - sudo apt update - sudo apt install clang-format - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Python style check - run: | - make format lint - test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; } - - name: C++ style check - run: | - make format-cpp - test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; } - - name: Check license - run: make check-license - - name: Python checks - run: make check-python-scripts - test: - name: Test Python package - runs-on: ubuntu-20.04 - strategy: - matrix: - antlr_runtime_type: [static, shared] - python_version: [3.5, 3.6, 3.7, 3.8, 3.9] - 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 - steps: - - uses: actions/checkout@v2 - with: - # Always clone the full depth so git-describe works. - fetch-depth: 0 - submodules: true - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - sudo apt update - sudo apt install cmake default-jre-headless uuid-dev libantlr4-runtime-dev - python -m pip install --upgrade pip - pip install -r requirements.txt - python update_version.py - - name: Tox - run: ANTLR4_RUNTIME_TYPE=${{ matrix.antlr_runtime_type }} tox -e ${{ matrix.TOXENV }} diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 7d7f57cb..2b0c8500 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -8,35 +8,12 @@ on: jobs: Source: - runs-on: ubuntu-20.04 name: Source steps: - - name: 🧰 Checkout - uses: actions/checkout@v2 + - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' with: - # Always clone the full depth so git-describe works. - fetch-depth: 0 - submodules: true - - - name: 🐍 Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install packaging tooling - run: | - pip install -U pip - pip install twine - - - name: Update version - run: | - python update_version.py - - - name: Install package's system dependencies (Ubuntu) - run: | - sudo apt-get update - sudo apt-get install -y cmake default-jre-headless uuid-dev libantlr4-runtime-dev + packaging-tools: true - name: Install package run: | @@ -70,50 +47,26 @@ jobs: strategy: matrix: include: - - { name: '3.6', python-version: 'cp36-cp36m' } - - { name: '3.7', python-version: 'cp37-cp37m' } - - { name: '3.8', python-version: 'cp38-cp38' } - - { name: '3.9', python-version: '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' - runs-on: ubuntu-latest steps: - - name: 🧰 Checkout - uses: actions/checkout@v2 + - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' with: - # Always clone the full depth so git-describe works. - fetch-depth: 0 - submodules: true - - - name: 🐍 Set up Python - uses: actions/setup-python@v2 - - - name: Install packaging tooling - run: | - pip install -U pip - pip install twine auditwheel - - - name: Update version - run: | - python update_version.py - - # The "Install package's system dependencies" and "Install package" steps - # are /actually/ included in the `python-wheels-manylinux-build` action. - - name: Install package's system dependencies - run: | - true - - name: Install package - run: | - true + python-version: ${{ matrix.python-version }} + 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.python-version }} + python-versions: ${{ matrix.manylinux-python }} #pip-wheel-args: '-w ./dist --no-deps --verbose' - name: List distribution 📦 @@ -172,36 +125,11 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: 🧰 Checkout - uses: actions/checkout@v2 - with: - # Always clone the full depth so git-describe works. - fetch-depth: 0 - submodules: true - - - name: 🐍 Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + - uses: '${{ github.repository }}/.github/workflows/system-setup@${{ github.sha }}' with: + os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} - - - name: Install packaging tooling - run: | - pip install -U pip - pip install twine auditwheel - - - name: Update version - run: | - python update_version.py - - - name: Install package's system dependencies (Mac OS X) - if: startsWith(matrix.os, 'macos') - run: | - true - - - name: Install package's system dependencies (Windows) - if: startsWith(matrix.os, 'windows') - run: | - true + packaging-tools: true - name: Install package run: | diff --git a/.github/workflows/system-setup/action.yaml b/.github/workflows/system-setup/action.yaml new file mode 100644 index 00000000..4b3461ec --- /dev/null +++ b/.github/workflows/system-setup/action.yaml @@ -0,0 +1,85 @@ +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: "composite" + + steps: + - name: 🐍 Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ input.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 + + - uses: ./.github/workflows/checkout + if: inputs.git-checkout + + - name: Install development 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) + if: inputs.development-tools && startsWith(inputs.os, 'macos') + run: | + true + + - name: Install development system dependencies (Windows) + if: inputs.development-tools && startsWith(inputs.os, 'windows') + run: | + true + + - name: Install development tooling + if: inputs.development-tools + run: | + pip install -r requirements.txt diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml deleted file mode 100644 index ce201578..00000000 --- a/.github/workflows/wheel.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Builds a binary distibutable package. -# Minimal functionality checks may be run as part of the build process, but -# source code checks and extensive functionality checks (e.g. tox) belong in presubmit.yml -name: Python wheels -on: [push, pull_request] -jobs: - wheels: - runs-on: ubuntu-20.04 - strategy: - matrix: - python-version: [3.6, 3.7, 3.8, 3.9] - fail-fast: false - steps: - - uses: actions/checkout@v2 - with: - # Always clone the full depth so git-describe works. - fetch-depth: 0 - submodules: true - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install package's system dependencies - run: | - sudo apt update - sudo apt install cmake default-jre-headless uuid-dev libantlr4-runtime-dev - - - name: Generate version - run: | - python update_version.py - - - name: Install dependencies - run: | - python -m pip install --upgrade -r requirements.txt - - - name: Build wheels - run: | - python setup.py bdist_wheel - - - name: Test wheel installation - run: | - python -m pip install dist/*.whl - (cd tests; python test_simple.py) - - - uses: actions/upload-artifact@v2 - with: - name: fasm - path: dist