From 88b1f9b173af5d511ea6161d47f6efb8af063102 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 11 Sep 2026 13:20:27 +0200 Subject: [PATCH] GitHub Actions: Sync with DMD master After: * dlang/dmd#23823 * dlang/dmd#23824 --- .github/workflows/main.yml | 137 +++++++++---------------------------- 1 file changed, 31 insertions(+), 106 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b23b6433540..2219a68031d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,28 +35,52 @@ jobs: - job_name: Windows x86 os: windows-2022 model: 32 + # FreeBSD (VM on Ubuntu) + - job_name: FreeBSD 14.4 x64 + os: ubuntu-latest + vm_os: freebsd + vm_os_version: '14.4' + dflags: -version=TARGET_FREEBSD14 name: ${{ matrix.job_name }} runs-on: ${{ matrix.os }} container: ${{ matrix.container_image }} timeout-minutes: ${{ matrix.timeout-minutes || 40 }} env: # for ci/run.sh: - OS_NAME: ${{ startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || (startsWith(matrix.os, 'windows') && 'windows' || '')) }} + OS_NAME: ${{ matrix.vm_os || (startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || (startsWith(matrix.os, 'windows') && 'windows' || ''))) }} MODEL: ${{ matrix.model || '64' }} HOST_DMD: ${{ matrix.host_dmd || 'dmd' }} + CI_DFLAGS: ${{ matrix.dflags }} # N is set dynamically below FULL_BUILD: false # work around https://issues.dlang.org/show_bug.cgi?id=23517 MACOSX_DEPLOYMENT_TARGET: '11' defaults: run: - shell: bash + # cpa.sh comes with cross-platform-actions and delegates to the VM. + # Use it by default for all `run` steps below, i.e., run them in the VM (with a bash shell). + shell: ${{ matrix.vm_os && 'cpa.sh {0} --sync-files runner-to-vm --environment-variables OS_NAME MODEL HOST_DMD CI_DFLAGS N FULL_BUILD' || 'bash' }} steps: + - name: Start VM + if: matrix.vm_os + uses: cross-platform-actions/action@v1.5.0 + with: + operating_system: ${{ matrix.vm_os }} + version: ${{ matrix.vm_os_version }} + shell: bash + memory: 12G + cpu_count: 4 + sync_files: runner-to-vm + - name: 'Alpine container: Pre-install bash, git and sudo' if: startsWith(matrix.container_image, 'alpine') shell: sh run: apk add bash git sudo - - uses: actions/checkout@v4 + - name: 'FreeBSD VM: Pre-install git' + if: matrix.vm_os == 'freebsd' + run: sudo pkg install -y git + + - uses: actions/checkout@v7 with: fetch-depth: 50 - name: Clone DMD @@ -81,13 +105,14 @@ jobs: - name: Set environment variable N (parallelism) run: echo "N=$(${{ runner.os == 'macOS' && 'sysctl -n hw.logicalcpu' || 'nproc' }})" >> $GITHUB_ENV + shell: bash # don't run in VM, but host runner (for exporting env var) - name: 'Posix: Install prerequisites' if: runner.os != 'Windows' run: cd ../dmd && ${{ runner.os == 'macOS' && 'ci/cirrusci.sh' || 'sudo -E ci/cirrusci.sh' }} - name: 'Windows: Set up MSVC environment' if: runner.os == 'Windows' - uses: seanmiddleditch/gha-setup-vsdevenv@v4 + uses: seanmiddleditch/gha-setup-vsdevenv@v5 with: arch: ${{ env.MODEL == '64' && 'x64' || 'x86' }} @@ -96,118 +121,18 @@ jobs: run: cd ../dmd && ci/run.sh install_host_compiler - name: 'Windows: Install host compiler' if: runner.os == 'Windows' - uses: dlang-community/setup-dlang@v1.3.0 + uses: dlang-community/setup-dlang@v2 with: compiler: ldc-latest - name: Build run: cd ../dmd && ci/run.sh build - env: - # on Windows, `ci/run.sh build` expects the DMD env var to be set to the DMD-CLI-compatible host compiler - DMD: ${{ runner.os == 'Windows' && 'ldmd2' || '' }} - # work around the LDC host compiler on Windows assuming the first link.exe in PATH is the MSVC one - # (VSINSTALLDIR is set, but GHA uses Git's bin\bash.exe for `shell: bash`, which prepends Git's usr\bin to PATH, with GNU link.exe) - LDC_VSDIR_FORCE: ${{ runner.os == 'Windows' && '1' || '' }} - name: Test dmd run: cd ../dmd && ci/run.sh test_dmd - name: Test druntime run: cd ../dmd && ci/run.sh test_druntime - name: 'Windows x86: Add 32-bit libcurl.dll to PATH (required for Phobos unittests)' if: runner.os == 'Windows' && env.MODEL == '32' - run: echo "$(dirname "$(which $DC)")/../lib32" >> $GITHUB_PATH + run: echo "$(dirname "$DC")/../lib32" >> $GITHUB_PATH - name: Test phobos run: cd ../dmd && ci/run.sh test_phobos - - freebsd-vm: - strategy: - fail-fast: false - matrix: - include: - - job_name: FreeBSD 14.4 x64 - freebsd_version: '14.4' - name: ${{ matrix.job_name }} - runs-on: ubuntu-latest - timeout-minutes: 20 # Should complete in 11 minutes - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 50 - - name: Start VM - uses: cross-platform-actions/action@v1.3.0 - with: - operating_system: freebsd - memory: 12G - cpu_count: 4 - sync_files: runner-to-vm - version: ${{ matrix.freebsd_version }} - shell: bash - - name: Run in VM - timeout-minutes: 19 - shell: cpa.sh {0} - run: | - set -uexo pipefail - - freebsd_version='${{ matrix.freebsd_version }}' - freebsd_major="${freebsd_version:0:2}" - - export OS_NAME=freebsd - export MODEL=64 - export HOST_DMD=dmd - export N="$(nproc)" - export FULL_BUILD=false - export CI_DFLAGS="-version=TARGET_FREEBSD${freebsd_major}" - - #if [[ "$freebsd_major" == 12 ]]; then - # sudo sed -i '' -e 's|pkg.FreeBSD.org|mirrors.xtom.com/freebsd-pkg|' /etc/pkg/FreeBSD.conf - #fi - - bash --version - - # compiler/test/dshell/dwarf.d needs objdump from binutils. - # It will also optionally use llvm-dwarfdump from llvm. - # So, this installs both. - sudo pkg install -y binutils llvm - - echo '::group::Install git' - sudo pkg install -y git - echo '::endgroup::' - - echo '::group::Clone DMD' - ref='${{ github.ref }}' - if [[ "$ref" =~ ^refs/pull/ ]]; then - REPO_BRANCH="$GITHUB_BASE_REF" - elif [[ "$ref" =~ ^refs/(heads|tags)/(.*)$ ]]; then - REPO_BRANCH="${BASH_REMATCH[2]}" - else - echo "Error: unexpected GitHub ref '$ref'" >&2 - exit 1 - fi - - git clone --branch "$REPO_BRANCH" --depth 1 https://github.com/dlang/dmd.git ../dmd - echo '::endgroup::' - - cd ../dmd - - echo '::group::Install prerequisites' - sudo -E ci/cirrusci.sh - echo '::endgroup::' - - echo '::group::Install host compiler' - ci/run.sh install_host_compiler - echo '::endgroup::' - - echo '::group::Build' - ci/run.sh build - echo '::endgroup::' - - echo '::group::Test dmd' - ci/run.sh test_dmd - echo '::endgroup::' - - echo '::group::Test druntime' - ci/run.sh test_druntime - echo '::endgroup::' - - echo '::group::Test phobos' - ci/run.sh test_phobos - echo '::endgroup::'