From be6b02859bb83c7095f488c850637eb69aa72cf9 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 10 Jan 2025 18:24:14 +0100 Subject: [PATCH 1/4] Setup GHDL on Ubuntu 2024.04. --- .editorconfig | 17 ++++++ .github/dependabot.yml | 16 +++++ .github/pull_request_template.md | 30 ++++++++++ .github/workflows/Pipeline.yml | 27 +++++++++ README.md | 70 +++++++++++++++++++++- action.yml | 100 +++++++++++++++++++++++++++++++ 6 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/Pipeline.yml create mode 100644 action.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7b0afb1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +charset = utf-8 +# end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = 2 +tab_width = 2 + +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e91b107 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + # Maintain GitHub Action runners + - package-ecosystem: "github-actions" + directory: "/" + target-branch: dev + commit-message: + prefix: "[Dependabot]" + labels: + - Dependencies + assignees: + - Paebbels + reviewers: + - Paebbels + schedule: + interval: "daily" # Checks on Monday trough Friday. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..4ed2d90 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,30 @@ +# New Features + +* tbd +* tbd + +# Changes + +* tbd +* tbd + +# Bug Fixes + +* tbd +* tbd + +# Documentation + +* tbd +* tbd + +# Unit Tests + +* tbd +* tbd + +---------- +# Related Issues and Pull-Requests + +* tbd +* tbd diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml new file mode 100644 index 0000000..00e22a1 --- /dev/null +++ b/.github/workflows/Pipeline.yml @@ -0,0 +1,27 @@ +name: Verification of setup-ghdl + +on: + push: + workflow_dispatch: + +jobs: + Setup-GHDL-Nightly: + name: ${{ matrix.os.icon }} Setup GHDL on ${{ matrix.os.name }} + runs-on: ${{ matrix.os.image }} + strategy: + fail-fast: false + matrix: + os: + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'backend': 'mcode'} + - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14', 'backend': 'mcode'} + - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022', 'backend': 'mcode'} + defaults: + run: + shell: bash + + steps: + - name: Setup GHDL + uses: paebbels/setup-ghdl@dev + with: + version: nightly + backend: ${{ matrix.os.backend }} diff --git a/README.md b/README.md index 87f27de..7577cbb 100644 --- a/README.md +++ b/README.md @@ -1 +1,69 @@ -# `setup-ghdl` GitHub Action +# Setup GHDL in GitHub Action Workflows + +This composite action, installs GHDL in a GitHub Action's workflow job. + + +## Features + +* Select GHDL version (tagged release or nightly build). +* Select GHDL backend (LLVM, LLVM-JIT, mcode, GCC) +* Activate an investigation mode (check and show GHDL installation, ...) +* Supported runner OS' (automatically detected): Ubuntu 2024.04, macOS (x86-64), macOS (aarch64), Windows + +## Usage + +```yaml +jobs: + MyJob: + steps: + - name: Run VHDL Simulation + uses: paebbels/setup-ghdl@v1 + with: + version: nightly + backend: mcode + investigate: true +``` + + +### Input Parameters + +| Parameter | Required | Default | Description | +|----------------------------|:--------:|-------------|----------------------------------------------------------| +| `version` | no | `'nightly'` | A tagged GHDL version starting at `v5.0.0` or `nightly`. | +| `backend` | no | `'mcode'` | GHDL backend: `llvm`, `llvm-jit`, `mcode`, `gcc`. | +| `investigate` | no | `false` | If enabled, details and check GHDL installation. | + + +### Output Parameters + +| Parameter | Description | +|--------------------|-------------| +| `ghdl-binary-dir` | tbd | +| `ghdl-library-dir` | tbd | + + +## Dependencies + +### On Linux (Ubuntu) + +* Further dependencies will be installed using `apt-get`. +* GHDL will be added to `PATH`. + +### On macOS + +*tbd* + +### On Windows (native) + + +### On Windows + MSYS2 + +## Contributors + +* [Patrick Lehmann](https://GitHub.com/Paebbels) (Maintainer) +* [and more...](https://GitHub.com/ghdl/setup-ghdl/graphs/contributors) + +### Credits + +This GitHub Action replaces `setup-ghdl-ci`, a Javascript Action developed by Umarcor, with a composite action using +simples instructions (`curl`, `tar`, `apt-get`) written in Bash. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..6b4564a --- /dev/null +++ b/action.yml @@ -0,0 +1,100 @@ +name: Setup GHDL +branding: + icon: play + color: gray-dark +description: Install and setup GHDL downloaded from GHDL's release pages at GitHub. +author: Patrick Lehmann (@Paebbels) + +inputs: + version: + type: string + required: false + default: 'nightly' + backend: + type: string + required: false + default: 'mcode' + install-directory: + type: string + required: false + default: 'install' + investigate: + type: boolean + required: false + default: false + +runs: + using: composite + steps: + - name: Variables + id: variables + shell: bash + run: | + tee "${GITHUB_OUTPUT}" < Date: Fri, 10 Jan 2025 20:46:38 +0100 Subject: [PATCH 2/4] Try other runner OS' in parallel. --- action.yml | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 6b4564a..65bae0c 100644 --- a/action.yml +++ b/action.yml @@ -95,6 +95,127 @@ runs: ) printf "Setting environment variable 'GHDL_PREFIX' ...\n" - tee "${$GITHUB_ENV}" < Date: Fri, 10 Jan 2025 21:03:23 +0100 Subject: [PATCH 3/4] Added grouping of outputs for Linux variant. --- .github/workflows/Pipeline.yml | 17 +++++++++++++---- action.yml | 33 ++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index 00e22a1..93fa803 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -12,12 +12,16 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'backend': 'mcode'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14', 'backend': 'mcode'} - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022', 'backend': 'mcode'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'mcode'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'llvm'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'llvm-jit'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'gcc'} + - {'icon': '🍎', 'name': 'macOS', 'image': 'macos-13', 'shell': 'bash', 'backend': 'mcode'} + - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14', 'shell': 'bash', 'backend': 'llvm'} + - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022', 'shell': 'bash', 'backend': 'mcode'} defaults: run: - shell: bash + shell: ${{ matrix.os.shell }} steps: - name: Setup GHDL @@ -25,3 +29,8 @@ jobs: with: version: nightly backend: ${{ matrix.os.backend }} + investigate: true + + - name: Verify + run: | + ghdl --version diff --git a/action.yml b/action.yml index 65bae0c..b7ce256 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,9 @@ runs: if: runner.os == 'Linux' && runner.arch == 'X64' shell: bash run: | + ANSI_LIGHT_BLUE="\e[94m" + ANSI_NOCOLOR=$'\x1b[0m' + source /etc/lsb-release if [[ "${DISTRIB_RELEASE}" != "24.04" ]]; then @@ -70,11 +73,11 @@ runs: exit 1 fi - if [[ "${{ inputs.backend }}" != "mcode" ]]; then + if [[ "${{ inputs.backend }}" =~ ^mcode|llvm(-jit)?|gcc$ ]]; then + printf "Backend: %s\n" "${{ inputs.backend }}" + else printf "::error title=%s::%s\n" "setup-ghdl" "Unsupported GHDL backend '${{ inputs.backend }}'." exit 1 - else - printf "Backend: %s\n" "${{ inputs.backend }}" fi ( @@ -82,16 +85,20 @@ runs: mkdir -p "${{ inputs.install-directory }}" cd "${{ inputs.install-directory }}" - printf "Downloading asset and extracting tar.gz file ...\n" - curl -L "https://github.com/ghdl/ghdl/releases/download/${VERSION_IN_URL}/ghdl-${{ inputs.backend }}-${VERSION_IN_FILE}-ubuntu${DISTRIB_RELEASE}-x86_64.tar.gz" | tar -xz --strip-components 1 - ( - cd bin - pwd - ls -lAh . - ) - # tree . - printf "Installing dependencies from './ubuntu.requirements' using 'apt-get' ...\n" + DOWNLOAD_URL="https://github.com/ghdl/ghdl/releases/download/${VERSION_IN_URL}/ghdl-${{ inputs.backend }}-${VERSION_IN_FILE}-ubuntu${DISTRIB_RELEASE}-x86_64.tar.gz" + printf "::group::${ANSI_LIGHT_BLUE}%s${ANSI_NOCOLOR}\n" "Downloading asset and extracting '${DOWNLOAD_URL}' file ..." + curl -L "${DOWNLOAD_URL}" | tar -xz --strip-components 1 + printf "::endgroup::\n" + + if [[ "${{ inputs.investigate }}" == "true" ]]; then + printf "::group::${ANSI_LIGHT_BLUE}%s.${ANSI_NOCOLOR}\n" "Content of '$(pwd)'" + tree -pash . + printf "::endgroup::\n" + fi + + printf "::group::${ANSI_LIGHT_BLUE}%s.${ANSI_NOCOLOR}\n" "Installing dependencies from './ubuntu.requirements' using 'apt-get' ..." sudo xargs --no-run-if-empty -a ./ubuntu.requirements -- apt-get install -y --no-install-recommends + printf "::endgroup::\n" ) printf "Setting environment variable 'GHDL_PREFIX' ...\n" @@ -187,7 +194,7 @@ runs: exit 1 fi - if [[ "${{ inputs.backend }}" != "mcode" ]]; then + if [[ "${{ inputs.backend }}" != "llvm" ]]; then printf "::error title=%s::%s\n" "setup-ghdl" "Unsupported GHDL backend '${{ inputs.backend }}'." exit 1 else From 9c656d8f0526ebe113cecf11e87b29ee095cb377 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sat, 11 Jan 2025 01:47:12 +0100 Subject: [PATCH 4/4] Checking UCRT64 support. --- .github/workflows/Pipeline.yml | 28 ++++++++---- action.yml | 82 +++++++++++++++++----------------- 2 files changed, 60 insertions(+), 50 deletions(-) diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index 93fa803..f2ecff7 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -6,29 +6,39 @@ on: jobs: Setup-GHDL-Nightly: - name: ${{ matrix.os.icon }} Setup GHDL on ${{ matrix.os.name }} + name: ${{ matrix.os.icon }} Setup GHDL ${{ matrix.os.backend }} on ${{ matrix.os.name }} runs-on: ${{ matrix.os.image }} strategy: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'mcode'} - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'llvm'} - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'llvm-jit'} - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'backend': 'gcc'} - - {'icon': '🍎', 'name': 'macOS', 'image': 'macos-13', 'shell': 'bash', 'backend': 'mcode'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14', 'shell': 'bash', 'backend': 'llvm'} - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022', 'shell': 'bash', 'backend': 'mcode'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'runtime': '', 'backend': 'mcode'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'runtime': '', 'backend': 'llvm'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'runtime': '', 'backend': 'llvm-jit'} + - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04', 'shell': 'bash', 'runtime': '', 'backend': 'gcc'} + - {'icon': '🍎', 'name': 'macOS', 'image': 'macos-13', 'shell': 'bash', 'runtime': '', 'backend': 'mcode'} + - {'icon': '🍎', 'name': 'macOS', 'image': 'macos-13', 'shell': 'bash', 'runtime': '', 'backend': 'llvm'} + - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14', 'shell': 'bash', 'runtime': '', 'backend': 'llvm'} + - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022', 'shell': 'powershell','runtime': '', 'backend': 'mcode'} + - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022', 'shell': 'msys2 {0}', 'runtime': 'ucrt64', 'backend': 'mcode'} defaults: run: shell: ${{ matrix.os.shell }} steps: - - name: Setup GHDL + - name: 🟦 Setup MSYS2 for ${{ matrix.os.runtime }} + uses: msys2/setup-msys2@v2 + if: startsWith(matrix.os.shell, 'msys2') + with: + msystem: ${{ matrix.os.runtime }} + update: true + + - name: Setup GHDL ${{ matrix.os.backend }} uses: paebbels/setup-ghdl@dev with: version: nightly backend: ${{ matrix.os.backend }} + runtime: ${{ matrix.os.runtime }} investigate: true - name: Verify diff --git a/action.yml b/action.yml index b7ce256..8c71f4d 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: type: string required: false default: 'mcode' + runtime: + type: string + required: false + default: '' install-directory: type: string required: false @@ -113,14 +117,24 @@ runs: printf "Writing step outputs 'xxx' ...\n" - - name: Download and install GHDL on macOS x86-64 + - name: Download and install GHDL on macOS (${{ runner.arch }}) id: macOSIntel - if: runner.os == 'macOS' && runner.arch == 'X64' + if: runner.os == 'macOS' && ( runner.arch == 'X64' || runner.arch == 'ARM64' ) shell: bash run: | - # TODO: check macOS version - OS_RELEASE=13 + # TODO: check macOS version + if [[ "${{ runner.arch }}" == "X64" ]]; then + OS_RELEASE=13 + OS_ARCH=x86_64 + elif [[ "${{ runner.arch }}" == "ARM64" ]]; then + OS_RELEASE=14 + OS_ARCH=aarch64 + else + printf "::error title=%s::%s\n" "setup-ghdl" "Unsupported macOS architecture '${{ runner.arch }}'." + exit 1 + fi + printf "macOS: macOS %s - %s\n" "${OS_RELEASE}" "${OS_ARCH//_/-}" if [[ "${{ inputs.version }}" == "nightly" ]]; then VERSION_IN_URL="nightly" @@ -137,11 +151,11 @@ runs: exit 1 fi - if [[ "${{ inputs.backend }}" != "mcode" ]]; then + if [[ "${{ inputs.backend }}" =~ ^mcode|llvm(-jit)?$ ]]; then + printf "Backend: %s\n" "${{ inputs.backend }}" + else printf "::error title=%s::%s\n" "setup-ghdl" "Unsupported GHDL backend '${{ inputs.backend }}'." exit 1 - else - printf "Backend: %s\n" "${{ inputs.backend }}" fi ( @@ -150,7 +164,7 @@ runs: cd "${{ inputs.install-directory }}" printf "Downloading asset and extracting tar.gz file ...\n" - curl -L "https://github.com/ghdl/ghdl/releases/download/${VERSION_IN_URL}/ghdl-${{ inputs.backend }}-${VERSION_IN_FILE}-macos${OS_RELEASE}-x86_64.tar.gz" | tar -xz --strip-components 1 + curl -L "https://github.com/ghdl/ghdl/releases/download/${VERSION_IN_URL}/ghdl-${{ inputs.backend }}-${VERSION_IN_FILE}-macos${OS_RELEASE}-${OS_ARCH}.tar.gz" | tar -xz --strip-components 1 ( cd bin pwd @@ -170,15 +184,19 @@ runs: printf "Writing step outputs 'xxx' ...\n" - - name: Download and install GHDL on macOS aarch64 - id: macOSArm - if: runner.os == 'macOS' && runner.arch == 'ARM64' - shell: bash + - name: Download and install GHDL on Windows (native) + id: Windows + if: runner.os == 'Windows' && runner.arch == 'X64' && inputs.runtime == '' + shell: powershell run: | - # TODO: check macOS version + curl -L "https://github.com/ghdl/ghdl/releases/download/${VERSION_IN_URL}/mingw-w64-ucrt-x86_64-ghdl-mcode-5.0.0.dev-1-any.pkg.tar.zst" -o ghdl.pkg.tar.zst - OS_RELEASE=14 + - name: Download and install GHDL on Windows + UCRT64 (x86-64) + id: UCRT64 + if: runner.os == 'Windows' && runner.arch == 'X64' && ( inputs.runtime == 'mingw64' || inputs.runtime == 'ucrt64' ) + shell: ${{ inputs.shell }} + run: | if [[ "${{ inputs.version }}" == "nightly" ]]; then VERSION_IN_URL="nightly" VERSION_IN_FILE="${{ steps.variables.outputs.nightly-version }}" @@ -194,35 +212,17 @@ runs: exit 1 fi - if [[ "${{ inputs.backend }}" != "llvm" ]]; then + if [[ "${{ inputs.backend }}" =~ ^mcode|llvm(-jit)?$ ]]; then + printf "Backend: %s\n" "${{ inputs.backend }}" + else printf "::error title=%s::%s\n" "setup-ghdl" "Unsupported GHDL backend '${{ inputs.backend }}'." exit 1 - else - printf "Backend: %s\n" "${{ inputs.backend }}" fi - ( - printf "Creating installation directory '${{ inputs.install-directory }}' ...\n" - mkdir -p "${{ inputs.install-directory }}" - cd "${{ inputs.install-directory }}" - - printf "Downloading asset and extracting tar.gz file ...\n" - curl -L "https://github.com/ghdl/ghdl/releases/download/${VERSION_IN_URL}/ghdl-${{ inputs.backend }}-${VERSION_IN_FILE}-macos${OS_RELEASE}-aarch64.tar.gz" | tar -xz --strip-components 1 - ( - cd bin - pwd - ls -lAh . - ) - ) - - printf "Setting environment variable 'GHDL_PREFIX' ...\n" - tee "${GITHUB_ENV}" <> $GITHUB_ENV" + echo "GHDL_PREFIX=$(realpath $(dirname $(which ghdl))/../lib/ghdl)" >> $GITHUB_ENV